Zone members are matched one by one. So for performance reasons the first one should be the one most likely to match.
The current UI doesn't allow zone members to be arranged.

1) ZoneMemberBase needs to define the "weight" configuration key and matching getter (also add it to the ZoneMemberInterface).
2) ZoneMemberPluginCollection needs the same sortHelper() method that ImageEffectPluginCollection has.
3) ZoneForm needs the tabledrag.

Comments

bojanz created an issue. See original summary.

bojanz’s picture

This is the part I removed from ZoneForm because it was half-baked, it's a start for #3.

  $form['members'] = [
      '#type' => 'table',
      '#header' => [
        $this->t('Type'),
        $this->t('Zone member'),
        $this->t('Weight'),
        $this->t('Operations'),
      ],
      '#tabledrag' => [
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'zone-member-order-weight',
        ],
      ],
      '#empty' => t('There are currently no zone members in this zone. Add one by selecting an option below.'),
      '#weight' => 5,
    ];

    $index = 0;
    foreach ($this->entity->getMembers() as $key => $member) {
      $memberForm = &$form['members'][$index];
     // the actual member form here.

      $memberForm['weight'] = [
        '#type' => 'weight',
        '#title' => $this->t('Weight for @title', ['@title' => $member->getName()]),
        '#title_display' => 'invisible',
        '#default_value' => $weight,
        '#attributes' => [
          'class' => ['zone-member-order-weight'],
        ],
      ];
       // now the remove button
      $index++;
    }

    $plugins = [];
    foreach ($this->zoneMemberManager->getDefinitions() as $plugin => $definition) {
      $plugins[$plugin] = $definition['name'];
    }
    $form['members']['_new'] = [
      '#tree' => FALSE,
      '#attributes' => [
        'class' => ['draggable'],
      ],
    ];
Perignon’s picture

Assigned: Unassigned » Perignon
Perignon’s picture

I did not finish this at Drupalcon but I am still working on it.

  • bojanz committed 6e1dac0 on 8.x-1.x
    Issue #2571727: Allow zone members to be reordered
    
bojanz’s picture

Status: Active » Fixed

Sorry Perignon, had to move forward with this so that we can tag a beta.

Perignon’s picture

No worries. I got distracted on other work and currently on vacation again in Czech :-D

bojanz’s picture

Have fun! See you in the next round :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.