- Issue created by @berramou
- π«π·France berramou
Patch that fix it for, it still needs works to target only add button added by the office hours module and not target other buttons in the page.
Maybe look at the other selectors like$('[id$=copy]')
,$('[id$=clear]')
to not apply those callbacks on the other elements that added by other modules / themes with ids ends copy, clear, or add. - Status changed to Needs work
10 months ago 2:52pm 20 February 2024 - π³π±Netherlands johnv
This needs more investigation.
The proposed solution breaks the 'add' link usage in the office_hours widget.The better solution must restrict the scope for (amongst others) the following lines. Only the id's within a certain DIV must be regarded:
$('[id*="all-day"]').bind('click', setAllDayTimeSlot); $('[id$=add]').bind('click', addTimeSlot); $('[id$=add]').each(showAddLink); $('[id$=clear]').bind('click', clearTimeSlot); $('[id$=copy]').bind('click', copyPreviousDay);
- π«π·France berramou
Thank you @johnv for your quick reply, and yes it should be scoped within specific element like a DIV.
- π³π±Netherlands johnv
I am sorry I cannot help you with that.
As a maintainer, I only copy&paste&test the js code. - π«π·France berramou
Thank you for your reply @johnv
The js is in the module and it breaks the other modules features so it should be fixed in the module, otherwise every one want to use the module will patch it.
- π³π±Netherlands johnv
Indeed, it should be fixed in this module.
My point was that I do not have the knowledge to do that in a limited timeframe. For that, I need help from contributors. - π³π±Netherlands johnv
Having said that, the second best option is to replace all binded/bound link-ID's (as listed below) and change the ID in js and php to e.g., 'office-hours-clear', with a comment in the php file as to why the ID is so long.
$('[id*="all-day"]').bind('click', setAllDayTimeSlot); $('[id$=add]').bind('click', addTimeSlot); $('[id$=clear]').bind('click', clearTimeSlot); $('[id$=copy]').bind('click', copyPreviousDay);
- π«π·France berramou
Here is a path that wrap all office hours operations buttons in a specific DIV and then in the JS only target it's OP buttons.
- Status changed to Needs review
10 months ago 11:38am 24 February 2024 - last update
10 months ago 10 pass - last update
10 months ago 10 pass - π³π±Netherlands johnv
Does this issue also solve the problem? π Unable to add, remove or copy timeslot Needs review
- π«π·France berramou
Yes @johnv it's duplicated of this issue, and the fix it will cause the same issue if other modules add [Add] buttons with the same attribute
data-drupal-selector finish with add clear or copy.
I think it's better to wrap all operation in div with specific selector like that are sure that JS target only buttons added by the module. - π³π±Netherlands johnv
Thanks,
Actually, my question was the other way around: Does the solution of issue 3424112 also solve your problem from 3422607?
I like the other approach a bit better, since it does not add the extra DIV. - π³π±Netherlands johnv
That would be because the drupal selector is common for all drupal modules of course. The name or the div should be unique for this module only.
- last update
10 months ago Patch Failed to Apply - π³π±Netherlands johnv
Adding explicitly a more specific (but not unique) 'id' should do the trick. See patch.
- π«π·France berramou
I don't think it's a good idea, if we have multiple fields of office hours, you will have more than one identical ID within the same HTML page, which is not recommended.
-
johnv β
committed 7115ce00 on 8.x-1.x authored by
berramou β
Issue #3422607 by berramou, jonas139, johnv, skyriter: office_hours.js...
-
johnv β
committed 7115ce00 on 8.x-1.x authored by
berramou β
- Status changed to Fixed
10 months ago 1:27pm 29 February 2024 - π³π±Netherlands johnv
ndeed, non-unquye ID's are not preferred.
I committed #10 with slight changes.
I tried to re-use the 'office-hours-link' class that already exists, but did not succeed.Thanks all for your detailed initial postings, the fast responses and the contributions.
I will wait 48 hours before creating a new release. - π«π·France berramou
Thank you all your reactivity, support, and contribution.
- πΊπΈUnited States skyriter
johnv, do you know when a new release will be created?
- π§πͺBelgium jonas139
I haven't reviewed the changes yet but my colleague has tested the latest release and we are having the same issue from https://www.drupal.org/project/office_hours/issues/3424112 π Unable to add, remove or copy timeslot Needs review again.
A new issue has been created which mentions the same issue I had: https://www.drupal.org/project/paragraphs/issues/3426406 π Office_hours Action links always point to frontpage on uncollapsed paragraphs Active .
- π³π±Netherlands johnv
Are you using Paragraphs module like described in π Office_hours Action links always point to frontpage on uncollapsed paragraphs Active ? (I just finished enriching that issue).
office_hours should now be affecting only the own elements.I think it just depends on some sort order (alphabetically module name?) to tell what modules affects what.
Automatically closed - issue fixed for 2 weeks with no activity.