I think there is a bug in the widget code that is causing duplicate values to be saved to the RRULE, and I think its because this loop is used multiple times to set default values on the widget:
_.each(RRule.DAYCODES, function (element, index) {
var d = RRule[element];
tmpl += '<label class="inline">';
tmpl += '<input type="checkbox" name="byweekday" value="' + d.weekday + '" />';
tmpl += RRule.DAYNAMES[index] + '</label>';
});
This loops through and sets default values. If I create a node and set a date, lets say I choose Weekly, and pick a few days and save. The first save is fine.
When I go back to edit the node, the RRULE day values are now duplicated - its setting the MONTHLY values and using them in the RRULE creation as well, even though MONTHLY is not selected. This does not seem to affect the date creation, but does impact the saved RRULE information.
Where the widget code is generating the RRULE, it needs to ensure it is only pulling the entered values from the currently active occurrence.
Comments
Comment #2
kevinquillen CreditAttribution: kevinquillen at Velir commentedStill looking for a way to fix this - but it can be worked around for now if you filter duplicate values out of the array of weekday items:
This turns the byweekday item from [0, 2, 4, 0, 2, 4] to just [0, 2, 4] which fixes the UI output in the widget and on the frontend (where the RRULE is displayed in human readable form) and also corrects the RRULE value stored in the database. I believe the bug is in how the values are initially fetched - only the inputs from the currently selected occurrence value should be fetched.
Comment #3
jmuzz CreditAttribution: jmuzz commentedIt does if you try to uncheck one of the weekdays while editing. There's no way to prevent it from adding in the originally selected days even if you uncheck the boxes for them, and the boxes will be checked again if you try to re-edit the item again after.
Comment #4
kevinquillen CreditAttribution: kevinquillen at Velir commentedYeah, now I see where that happens. So while this seemed to work in one case, it fails when you have a date field that can have multiple delta values. (different day/time schedules within the same event). With the duplicates filtered out, it works in some cases, but not all cases.
Is there any reason this widget has to be like 800 lines of jQuery? It makes it really hard to debug and process.
Comment #5
jmuzz CreditAttribution: jmuzz commentedYou are correct, simply removing duplicate values is not sufficient... There could be different values checked in weekly and monthly and they would all be added. I realized this after creating another ineffective workaround. Oh well... I foresee a solution arising next week or sooner.
Comment #6
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #7
blasvicco CreditAttribution: blasvicco commentedHere a patch that seems works fine:
https://www.drupal.org/files/issues/date_recur-weekday_duplication-29453...
Comment #8
kevinquillen CreditAttribution: kevinquillen at Velir commentedThis patch seems to work - I only tested it with weekly so far (my main use case). However I noticed one bug.
If you save a node and edit it, then uncheck "Repeat" but then check it back on - the widget UI has your last saved values pre-selected. However, it does not save these values back at all. If you were to recheck the options that are already selected, then it would work.
Comment #9
kevinquillen CreditAttribution: kevinquillen at Velir commentedHeres another bug... the monthly widget suffers from the same issues, you can see duplicate values in the screenshot.
First, checking off every week option causes the widget to display:
=> TypeError: Cannot read property 'n' of undefined
in the summary area. I am not sure what that means, but this option in the widget is pretty confusing. I want to show this event and it happens monthly, what are these week options? Every other week style option? There is a lot to unpack there, I just wanted to set an event to run every month for six months, two days every week. Perhaps "All month" and "every other week" could be broken out into two new options, but that can be done for a UX feature issue later.
At the same time, selecting week options doubles up on the day values, and vice versa. You can see that in the screenshot.
Comment #10
blasvicco CreditAttribution: blasvicco commentedNew patch.
In order to avoid the use of the same field name for the two select list for week days, I renamed as 'byweekday-pos' in the first patch without realize that there was another field with that name too.
So, in this new patch I renamed as 'byweekday-month', also I added cleaning input values in '_getRRule' method depending the frequency (values['freq']), for example, we don't need to set 'values['byweekday']' if frequency is not monthly or weekly.
https://www.drupal.org/files/issues/date_recur-weekday_duplication-29453...
Comment #11
joelpittetComment #12
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI don't seem to have a date_recur/assets folder in the 1.0 version
Comment #13
dpiComment #14
jacobbell84 CreditAttribution: jacobbell84 commentedQuick reroll to support the new javascript paths in 1.0
Comment #15
imclean CreditAttribution: imclean commentedApplied #14 manually to 8.x-2.x-dev and the widget now correctly updates the RRULE.
Comment #16
tasc#14 works for me with 8.x-2.0-alpha1
Comment #17
jds1Works for me too! Marking as RTBC.
Comment #18
jds1Comment #19
jds1You know, after some more testing I'm finding that the default checkbox selected is the wrong day of the week. RRule output is matching though, and nothing is messed up there. I'm going to try and figure this out/amend the patch if I can unless someone beats me to it. Anyone else having this issue?
Comment #20
electrokate CreditAttribution: electrokate commented@if-jds Did you end up making a patch? I am going to have to do the same.
Comment #21
jds1@electrokate – I was able to get the day of week issue fixed with a patch from here https://www.drupal.org/project/date_recur_interactive/issues/2902733. Hope this helps!
Comment #22
electrokate CreditAttribution: electrokate commented@if-jds thank you so much! I don't know how I missed that!! I really appreciate your response! :)
Comment #23
jenniferhoude CreditAttribution: jenniferhoude commentedPatch #14 works for me. Can we please add this to the next release.
Comment #24
imclean CreditAttribution: imclean commented