This threw me off at first: when you are trying to add times to the Offiche Hours as an editor, and you copy a previous day, suddenly you can't add any new timeslots anymore.
What happens, is that when you click 'copy previous day', the javascript sets the 'Add timeslot' button to 'display:none' for some reason.

Comments

lordrembo created an issue. See original summary.

mayaslatinek’s picture

Status: Active » Needs review
StatusFileSize
new592 bytes

This patch fixes this issue. But from looking the code it seems that this was intentional, yet it's a bit confusing as to why. If anyone could elaborate on this, please. Also, thinking forward, shouldn't the remove button be present at all times?

johnv’s picture

Status: Needs review » Needs work

Hmm,
i cannot reproduce your error. Can you send a screen shot?
Perhaps you are confused by the following limiting setting: 'Number of time slots per day' in the field settings.

Regarding the 'Remove' link. It is present for all existing lines. Indeed not for lines you added during a page session. Perhaps it can be added. in a new issue.

mayaslatinek’s picture

When you enter values on Monday for example and then click on copy from previous for Tuesday, it copies the values but removes the add time slot option.

johnv’s picture

A picture speaks 100 words!
However, still cannot reproduce your error.
IMO the line in your patch hides the 'Add time slot', then shows it again in some situations.

mayaslatinek’s picture

Status: Needs work » Needs review
StatusFileSize
new699 bytes

I did some more testing on this and figured out that when you have the maximum time slots per day set to 2 and click copy from previous (you copy only one slot from previous, if you copy 2 slots it works fine) it hides the option on the current to add one more slot (when you save and come back to edit the form, add time slot appears). If you have maximum time slots per day set to more it works fine. I’ve made a new patch, tested it for 2 and more time slots per day and it works fine on my end.
I don’t know why you can’t reproduce this @johnv but it happens on my end constantly. Please test this.

johnv’s picture

I can now repeat your error. Your patch did not fix it for me.
I am very basic in JS, but i think we must reuse the function show_time_slot().
BTW, do you also get a JS error on an edit-page about e.preventDefault(); (with or without the patch)?

mayaslatinek’s picture

I don’t get any errors on the edit page

  • var next_add_link = current_selector.next().find('.office-hours-add-link');

The next() function is problematic I think because the selector in place selects the whole day and the first slot of the next day, it then takes that first slot of the next day and goes by it, so the add link of the current stays hidden
The show time slot function is bound to the add time slot link and as I can see it has nothing to do with showing of the add time slot link (on click it shows a slot, not the link), the link hides when you click copy from previous and everything for it happens in the function for copy so I think the problem is there (also the last patch I uploaded solves this issue for me), but please correct me if you find the problem elsewhere.
Could you make a screenshot or something so that I can see what happens on your end?

johnv’s picture

StatusFileSize
new12 KB

Please test attached patch.

Your analysis is correct.
Attached patch includes your change, but also removes duplicate code. (and some code standards)

  • johnv committed 1844cdf on 8.x-1.x
    Issue #3005949 by Mark Slatinek: 'Copy previous day' action hides 'Add...
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.1
Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

johnv’s picture

Component: User interface » Code - widget