Problem/Motivation
The office_hours.js hide every add button on the page
Steps to reproduce
1. install office_hours
2. install Inline Entity Form or any other module that add Add button
3. Add field reference for exemple field_ref refer to page content and choose the widget Inline entity form - Complex with the option "Allow users to add new nodes."
4. Add office hours field
5. Go to Add article form page:
The button to add new content is hidden because the office_hours.js add this code $('[id$=add]').each(showAddLink);
which hide every button with ID ends with add.
Article add page with office hours
Article add page without office hours
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#18 | office_hours_3422607-17_javascript.patch | 6.14 KB | johnv |
#10 | office_hours-fix_hides_other_add_btns-3422607_10.patch | 1.87 KB | berramou |
| |||
#2 | office_hours-fix_js_hide_all_add_buttons-3422607-1.patch | 512 bytes | berramou |
| |||
Screenshot-without_office-hours.png | 73.84 KB | berramou | |
Screenshot-with_office-hours.png | 212.49 KB | berramou |
Comments
Comment #2
berramou CreditAttribution: berramou as a volunteer commentedPatch 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 to other elements that added by other modules/themes with ids ends with copy, clear, or add.Comment #3
berramou CreditAttribution: berramou as a volunteer commentedComment #4
johnvThis 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:
Comment #5
berramou CreditAttribution: berramou as a volunteer commentedThank you @johnv for your quick reply, and yes it should be scoped within specific element like a DIV.
Comment #6
johnvI am sorry I cannot help you with that.
As a maintainer, I only copy&paste&test the js code.
Comment #7
berramou CreditAttribution: berramou as a volunteer commentedThank 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.
Comment #8
johnvIndeed, 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.
Comment #9
johnvHaving 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.
Comment #10
berramou CreditAttribution: berramou as a volunteer commentedHere 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.
Comment #11
berramou CreditAttribution: berramou as a volunteer commentedComment #12
johnvDoes this issue also solve the problem? #3424112: Unable to add, remove or copy timeslot
Comment #13
berramou CreditAttribution: berramou as a volunteer commentedYes @johnv #3424112: Unable to add, remove or copy timeslot is duplicate of this issue, and yes this fixes the other issue too.
Comment #14
johnvThanks,
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.
Comment #15
skyriter CreditAttribution: skyriter at CivicActions for Department of Veterans Affairs commented#10 worked for me, but the other 3424112-1.patch on Unable to add, remove or copy timeslot did not.
Comment #16
johnvThat 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.
Comment #18
johnvAdding explicitly a more specific (but not unique) 'id' should do the trick. See patch.
Comment #19
berramou CreditAttribution: berramou as a volunteer commentedI 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.
Apply the patch and create 2 fields of type office hours in the same content type like article, you will have multiple html elements with the id office-hours-add
Comment #21
johnvndeed, 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.
Comment #22
berramou CreditAttribution: berramou as a volunteer commentedThank you all for your reactivity, support, and contribution.
Comment #23
skyriter CreditAttribution: skyriter at CivicActions for Department of Veterans Affairs commentedjohnv, do you know when a new release will be created?
Comment #24
johnvComment #25
johnvI just created a new version.
Comment #26
skyriter CreditAttribution: skyriter at CivicActions for Department of Veterans Affairs commentedTerrific. Thank you!
Comment #27
jonas139 CreditAttribution: jonas139 at iO commentedI 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 again.
A new issue has been created which mentions the same issue I had: https://www.drupal.org/project/paragraphs/issues/3426406.
Comment #28
johnvAre you using Paragraphs module like described in #3426406: Office_hours Action links always point to frontpage on uncollapsed paragraphs ? (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.