Replace operation links in the widget with a dropbutton

Created on 10 May 2020, almost 5 years ago
Updated 12 January 2024, about 1 year ago

Problem/Motivation

The operation links in the widget look plain and take up a lot of space.

Proposed resolution

Replace the links with a dropbutton so they are more in line with the rest of the Drupal interface (e.g. entity operations)

Remaining tasks

Create a patch, review the patch, update tests (if necessary).

User interface changes

The operation links are replaced with a dropbutton.

Feature request
Status

Needs work

Version

1.0

Component

Code - widget

Created by

🇧🇪Belgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    This would be a wonderful addition and in my eyes definitely needed for a better UX.
    But unfortunately this is not applying anymore on the latest dev version.

    • johnv committed 0096ee4b on 8.x-1.x
      Issue #3135259: In widget, replace operation links with a dropbutton -...
  • 🇳🇱Netherlands johnv

    To prepare for this, the sorting of links is changed in above patch, since '#type' operations does not seem to support the weights.

    • johnv committed 120bbc84 on 8.x-1.x
      Issue #3135259: In widget office_hours.js, replace operation links -...
    • johnv committed 16f651a3 on 8.x-1.x
      Issue #3135259: In widget office_hours.js, factor out the functions
      
    • johnv committed 31a9df86 on 8.x-1.x
      Issue #3135259: Widget office_hours.js - phpcs
      
    • johnv committed c40b2c29 on 8.x-1.x
      Issue #3135259: Widget office_hours.js - phpcs
      
  • 🇳🇱Netherlands johnv

    Please find a reroll against current code base. I have re-arranged the code base, to the patch only contains the intended changes.
    Please check if the patch is correct.

    I have some remarks:
    - from UX perspective, it is undesirable that an extra click is needed to see all available options.
    - not sure what 'close the dropbutton'. also, 2 calls are done against different classes 'open' vs. 'dropbutton-open'.
    - when the first operation is hidden, an empty operation is added. this is not so in the original code. perhaps the class 'open' can be set always?
    - operation 'add time slot' works fine, but is initially not set ok.(must only be shown if no next slot exist)
    - operation 'clear/remove' does not work. I cannot find why
    - operation 'copy previous day' works fine.

    • johnv committed d20c10f2 on 8.x-1.x
      Issue #3135259: Widget office_hours.js - fix Clear/Remove/Delete link...
  • 🇳🇱Netherlands johnv

    Above commit fixes the problem with operation 'clear/remove'.

  • 🇳🇱Netherlands johnv

    This reroll fixes the lost functionality of sorting the operations, according to the 'weight' attribute (Note: not '#weight').
    It still contains the 'bind's to the old links. They must be removed, eventually.

    • johnv committed 5bf7da4a on 8.x-1.x
      Issue #3135259: Each operation link on its own line
      
  • 🇳🇱Netherlands johnv

    Above patch makes sure each link is on its own line.
    Much like permanently expanded dropbutton.

    • johnv committed f909739b on 8.x-1.x
      Issue #3135259: Each operation link on its own line
      
  • 🇳🇱Netherlands johnv

    For further work, see also #3476793-15: Fix accessibility issues in form , that also changes the links to buttons, taking another approach.

  • 🇩🇪Germany hexabinaer Berlin, Germany

    For context, using links (especially empty links) are setting up barriers. Since all action links are in fact triggers for functions, we provided a patch (see related issue) replacing them with submit buttons and providing audible feedback.

    The approach to bundle the action links in a dropbutton was so appealing that we transformed that into a button-based dropbutton (see Paragraphs for reference).

    Well aware now having two different further development approaches in two different issues. Hope we can merge that somehow.

  • 🇳🇱Netherlands johnv

    I am dropping the dropbutton for now.
    I tried to implement the 2 provided patches. I did not succeed in targeting the correct action with the dropbutton.

    Help is needed.

    Also, I have the following UX-problems with dropbuttons:
    - extra click needed, to open the dropbuttons. Can they be open by default, and stay open after clicking on it?
    - when hiding the link 'Add time slot', there is an empty line in the dropbuttons.

  • First commit to issue fork.
  • Pipeline finished with Success
    about 1 month ago
    Total: 152s
    #406473
  • 🇩🇪Germany tobiasb Berlin

    Extra click for more secondary actions is for a drop-button the expected behavior, because this is a drop-button form-element.

    When configured only 1 time-slot then Clear is the primary action.

    • johnv committed b9280e17 on 8.x-1.x
      Issue #3135259: Replace operation links - remove js-office-hours-...
  • 🇳🇱Netherlands johnv

    Moving slowly towards perhaps applying the patch, by removing noise.

    The mentioned const definitions were already changed, but I will create a separate issue for updating all const definitions, raising the php and drupal version bar.
    In priciple, my doubts expressed above and in 📌 Fix accessibility issues in form Active still exist.

    • johnv committed 46cc32ce on 8.x-1.x
      Issue #3135259: Make code more moveable in OfficeHoursBaseSlot.php
      
    • johnv committed 010e3594 on 8.x-1.x
      Issue #3135259: Add better reference in OfficeHoursSeasonHeader.php
      
  • 🇳🇱Netherlands johnv

    Above patch factors out the $title and $weight variables, so the button can be easily inserted by adding the following lines after each definition of $title (already in current code):

            $title = sprintf('<button type="button" class="button" data-drupal-selector="clear">%s</button>', $title);
            $title = Markup::create($title);
    

    However, that adds Action buttons, taking up unreasonable amount of space in my Olivero/Claro theme, so dropping that for now, and concentrating on pure dropbuttons.

    • johnv committed 284433cc on 8.x-1.x
      Issue #3135259: Make code more moveable in OfficeHoursBaseSlot.php
      
    • johnv committed 2d1780b9 on 8.x-1.x
      Issue #3135259 by dieterholvoet, johnv, wangshy: Add $(document).ready(...
  • 🇳🇱Netherlands johnv

    OK, leaving this for now.
    The code base is rationalized, so that the differences between codebase and pathc are minimalized.
    Chunks from the patch have been committed to codebase.
    Classes are added to the operation, they were omitted in the patch.

    Please see attached files:
    - the patch contains the changes to enable dropbuttons. 'clear' action does work. something is wrong for 'add' and 'copy' - I believe they did work before.
    - the 'remaining' text file are the chunks from the patch that have not been used, for your reference.
    - there is no setting to switch the UX, yet.
    - see comment #32 about the 'action buttons'
    - see comment #14 for UX and an older patch.

  • 🇳🇱Netherlands johnv

    Regarding the 'action buttons', that apparently are not supported.
    In another module, I have the following form settings:

        $form['basic']['options'] = [
          '#type' => 'select',
          '#title' => $this->t('How to show the available...'),
          '#required' => FALSE,
          '#default_value' => ...,
          '#options' => [
            // These options are taken from options.module.
            'select' => $this->t('Select list'),
            'radios' => $this->t('Radio buttons'),
            'buttons' => $this->t('Action buttons'),
            'dropbutton' => $this->t('Drop button'),
          ],
          '#description' => $this->t(Decide which is the best way to show them.'),
        ];
    

    But perhaps you want the 'button' inside a 'select' list?

  • 🇳🇱Netherlands johnv

    It would be helpful if the js is identical for both cases. I tried adding class = "js-office-hours-operation-$action", but that lead to the last operation having 3 such classes

Production build 0.71.5 2024