In widget, delete/copy JS-links are hidden too often

Created on 10 January 2024, about 1 year ago
Updated 26 January 2024, 12 months ago

Problem/Motivation

In js/office_hours.js file, the following line of code will not only influence the appearance of the 'add timeslot' link, but also the 'delete slot' and 'copy previous day' links.
$('.js-office-hours-add-link').each(showAddLink);
They are erroneously hidden on the first slot of a day, when a day has multiple/all slots filled.

Steps to reproduce

Edit a node with a day what has multiple/all slots maintained. All 3 links are hidden.

Proposed resolution

For some reason, the php-added classes are concatenated in the JS-links.
Let us change from using the class to using the ID.
This also prepares us for [#135259], where the css class is not used anymore, or at least has an alternative.

🐛 Bug report
Status

Fixed

Version

1.12

Component

Code - widget

Created by

🇳🇱Netherlands johnv

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

Comments & Activities

  • Issue created by @johnv
  • 🇳🇱Netherlands johnv

    Below the list of selected links. you see that link classes are concatenated TO 'js-office-hours-add-link', hence the wrong results.

    0: a#edit-field-officehours2-office-hours-0-value-0-operations-data-add.js-office-hours-add-link.office-hours-link
    1: a#edit-field-officehours2-office-hours-0-value-0-operations-data-delete.js-office-hours-add-link.office-hours-link.js-office-hours-delete-link
    2: a#edit-field-officehours2-office-hours-0-value-0-operations-data-copy.js-office-hours-add-link.office-hours-link.js-office-hours-delete-link.js-office-hours-copy-link
    3: a#edit-field-officehours2-office-hours-0-value-2-operations-data-add.js-office-hours-add-link.office-hours-link
    4: a#edit-field-officehours2-office-hours-0-value-2-operations-data-delete.js-office-hours-add-link.office-hours-link.js-office-hours-delete-link
    5: a#edit-field-officehours2-office-hours-0-value-2-operations-data-copy.js-office-hours-add-link.office-hours-link.js-office-hours-delete-link.js-office-hours-copy-link
    6: a#edit-field-officehours2-office-hours-0-value-4-operations-data-add.js-office-hours-add-link.office-hours-link
    7: a#edit-field-officehours2-office-hours-0-value-4-operations-data-delete.js-office-hours-add-link.office-hours-link.js-office-hours-delete-link
    [...]
    • johnv committed 55c24b70 on 8.x-1.x
      Issue #3413798: In widget, delete/copy JS-links are hidden too often
      
  • 🇳🇱Netherlands johnv

    The proposed patch inserts $(document).ready(function () to the top of the document. This function is already present.
    So preparing the current code to have a cleaner changing patch, by only moving code, not changing anything.

  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024