Skip to content
Snippets Groups Projects
Unverified Commit 6a74240c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2939634 by kevin.dutra, runeasgar, Sam152, alexpott: Unable to order...

Issue #2939634 by kevin.dutra, runeasgar, Sam152, alexpott: Unable to order transitions if there are more than 20
parent d5841b09
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,7 @@ public function form(array $form, FormStateInterface $form_state) {
);
}
$state_weight_delta = round(count($states) / 2);
foreach ($states as $state) {
$links = [
'edit' => [
......@@ -138,6 +139,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#title_display' => 'invisible',
'#default_value' => $state->weight(),
'#attributes' => ['class' => ['state-weight']],
'#delta' => $state_weight_delta,
],
'operations' => [
'#type' => 'operations',
......@@ -174,7 +176,10 @@ public function form(array $form, FormStateInterface $form_state) {
],
],
];
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 @@ public function form(array $form, FormStateInterface $form_state) {
'#title_display' => 'invisible',
'#default_value' => $transition->weight(),
'#attributes' => ['class' => ['transition-weight']],
'#delta' => $transition_weight_delta,
],
'from' => [
'#theme' => 'item_list',
......
......@@ -389,6 +389,21 @@ public function testSorting() {
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');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment