summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-04-30 12:23:01 (GMT)
committerAlex Pott2018-04-30 12:23:01 (GMT)
commit6a74240ce3e5b53807a738468ff99beb1930f1fc (patch)
tree96e6b769cc8226ca55c6901e2359345b2a006bb9
parentd5841b0956f0243c3de9982b86b79bcc40834c53 (diff)
Issue #2939634 by kevin.dutra, runeasgar, Sam152, alexpott: Unable to order transitions if there are more than 20
-rw-r--r--core/modules/workflows/src/Form/WorkflowEditForm.php8
-rw-r--r--core/modules/workflows/tests/src/Functional/WorkflowUiTest.php15
2 files changed, 22 insertions, 1 deletions
diff --git a/core/modules/workflows/src/Form/WorkflowEditForm.php b/core/modules/workflows/src/Form/WorkflowEditForm.php
index 578f256..84af087 100644
--- a/core/modules/workflows/src/Form/WorkflowEditForm.php
+++ b/core/modules/workflows/src/Form/WorkflowEditForm.php
@@ -112,6 +112,7 @@ class WorkflowEditForm extends EntityForm {
);
}
+ $state_weight_delta = round(count($states) / 2);
foreach ($states as $state) {
$links = [
'edit' => [
@@ -138,6 +139,7 @@ class WorkflowEditForm extends EntityForm {
'#title_display' => 'invisible',
'#default_value' => $state->weight(),
'#attributes' => ['class' => ['state-weight']],
+ '#delta' => $state_weight_delta,
],
'operations' => [
'#type' => 'operations',
@@ -174,7 +176,10 @@ class WorkflowEditForm extends EntityForm {
],
],
];
- foreach ($workflow->getTypePlugin()->getTransitions() as $transition) {
+
+ $transitions = $workflow->getTypePlugin()->getTransitions();
+ $transition_weight_delta = round(count($transitions) / 2);
+ foreach ($transitions as $transition) {
$links['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('entity.workflow.edit_transition_form', ['workflow' => $workflow->id(), 'workflow_transition' => $transition->id()]),
@@ -193,6 +198,7 @@ class WorkflowEditForm extends EntityForm {
'#title_display' => 'invisible',
'#default_value' => $transition->weight(),
'#attributes' => ['class' => ['transition-weight']],
+ '#delta' => $transition_weight_delta,
],
'from' => [
'#theme' => 'item_list',
diff --git a/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php b/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php
index d349220..487e28c 100644
--- a/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php
+++ b/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php
@@ -389,6 +389,21 @@ class WorkflowUiTest extends BrowserTestBase {
foreach ($elements as $key => $element) {
$this->assertEquals($expected_transitions[$key], $element->find('xpath', 'td')->getText());
}
+
+ // Ensure that there are enough weights to satisfy the potential number of
+ // states and transitions.
+ $this->assertSession()
+ ->selectExists('states[three][weight]')
+ ->selectOption('2');
+ $this->assertSession()
+ ->selectExists('states[three][weight]')
+ ->selectOption('-2');
+ $this->assertSession()
+ ->selectExists('transitions[three][weight]')
+ ->selectOption('2');
+ $this->assertSession()
+ ->selectExists('transitions[three][weight]')
+ ->selectOption('-2');
}
}