Problem/Motivation
The use case I have for this module is a tracker to share progress with people.
We have one field for when something is started, then another for when it is estimated to be done (which can get changed when it is done along with a status change in another field). It's cleaner to have these as two different fields and it's how the historical data has been entered.
I can select two date fields in the "customize fields" option at the top, but it just renders as a infinitely long event ending at today. This happens whether one or two fields is selected and might just be a bug due to lack of non smart date support.
We have a working setup in fullcalendar_view - it seems like this new version here is a response to the v6 branch there going premium. Interestingly the maintainer there seems to have regretted his stance on making a premium version https://www.drupal.org/project/fullcalendar_view/issues/3466648#comment-...
Some advantages of not using smartdate for our use case:
SmartDate fields would make it more complicated to copy over date fields with ECA, though it's been a while since we looked at this. If there's a way to just copy over the single date fields into a smartdate field on that entity via ECA that's used in the calendar that would work as there are times in a view where we want to only show the start or end field, or to have each of them in their own column in a table view, but being able to have a nice way to grab duration is useful as well.
If we can find a way to copy over the two single/core date fields into a corresponding smartdate field via ECA on an entity
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | data.png | 179.61 KB | erutan |
| #26 | view.png | 347.13 KB | erutan |
| #26 | dupe.png | 236.29 KB | erutan |
| #26 | content.png | 160.92 KB | erutan |
| #22 | After-No-duplicates.jpg | 56.13 KB | mithun-a-sridharan |
Issue fork fullcalendar-3480947
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
erutan commentedComment #3
mandclu commentedHave you tried not selecting any fields in the "Customize Fields" option?
Comment #4
erutan commentedI did, it still did the infinitely long events ending at today.
I can go back and try again in a few days, but with either one or two standard drupal date fields added to the view it wasn't creating reasonable events.
Comment #5
erutan commentedUsing a standard date field on that entity as start, then referencing a standard date field in a related (storage) entity leads to a blank calendar. I've tried selecting no date fields, one date field, and both. There are no other date fields in the view.
If I switch to unformatted list all the fields show up, so I'm not just messing up the relation.
If I have two dates on the same entity it's the same infinite past to present day list of entries. Again I've tried selecting no date fields, one date field, and both.
Comment #6
mandclu commentedCould you post a screen grab that shows the fields you're trying to use? Also, you mentioned that you have this working with Fullcalendar View. Would you be willing to post a screen grab of that config?
Comment #7
erutan commentedUpgraded, testing against rc1 entries start and stop when they should! Selecting fields or not selecting fields doesn't seem to make any difference.
There are two issues:
1) Each entry shows up twice. I assume that this is because it loads a date field for the start, and then another one for the end.
2) Each entry has a 5p or 12a even though the fields are "date only" and don't have any time associated with them. I don't see an option for "all day events only" etc in the config settings, but regardless it probably shouldn't make up a fake time if none is present.
Comment #8
erutan commentedComment #9
erutan commentedComment #10
erutan commentedComment #11
erutan commentedAs per https://www.drupal.org/project/fullcalendar/issues/3475373#comment-15860986 times should now be able to be hidden, so it's really just the duplicate entries showing up. Anyone able to replicate this?
Comment #14
vinayakmk47Here is the patch if you want to test and check the unique events for the same.
Comment #15
vinayakmk47Sorry for the comment #14 please look into this patch.
Comment #16
vinayakmk47Please use this patch DuplicateAllDayEvents-3480947-15.patch for the Duplicate entries for all day events with multiple standard (non smartdate) date fields issue.
Comment #17
vinayakmk47Duplicate entries for all day events with multiple standard (non smartdate) date fields
Comment #18
vinayakmk47Comment #19
vinayakmk47Comment #20
erutan commentedThanks for the patch, I'll try and get this tested in a few days - things are hectic now.
Comment #21
erutan commentedThis works great, thanks!
Comment #22
mithun-a-sridharan commentedI can confirm the duplicate entries on the frontend when assigning start and end dates to an event. Following the comment #7 by @erutan, I removed the end date and the duplicates don't show up on the front end. I've attached screenshots that demonstrate this behavior. Please merge the fix and issue a new release.
PS: Edited after posting this comment this morning. I also logged another issue - similar to this one and with another - possibly related cause - here. I tracked this conversation after logging the other bug report.
Comment #23
mithun-a-sridharan commentedDear all,
I can also confirm that this patch works. I've added my comments and screenshots to the other related issue I posted here. The patch seems to fix the issues I was facing. Shout out to @vinayakmk47 for the patch and all the contributions from this community.
Thanks a ton!
Mithun A. Sridharan
Comment #24
mandclu commentedI appreciate the work done to date here, but unfortunately there are a few things needed before this will be ready to merge. First, there are a variety of code standards issues, in fact the changes in the MR that actually introduce code standards failures outnumber the lines required for the actual solution. If it were as simple as that, I would have made a new MR with only the actual proposed solution.
My bigger concern is that the proposed solution does a pass for deduplication at the very end, after all the processing has been done for all the rows in the view. That means that the back end is still doing all its work on duplicate rows, we're just stopping them from all being passed to the front end. I would suggest that there's a much more efficient way to address the cited problem.
Consider this code towards the end of the unmodified
prepareEvent()method:The proposed changes include this line:
$uniqueKey = $event['id'] ?? $event['start'] . '_' . $event['end'];We could generate the
$uniqueKeyvalue and check for an existing value in the $events array BEFORE calling the prepareEvent method, and then add the current row to the $events array using the $uniqueKey as the index. Then the method could return the array values of the $events array directly.I would be happy to help this along more directly myself but since neither this issue nor the one closed as a duplicate include detailed steps to reproduce the problem on a clean install, I don't want to guess how to replicate an issue I haven't yet come across myself.
Comment #25
erutan commentedIt's been a while since I looked at this, but to reproduce this simply use non smartdate (core) date fields for the beginning and end dates for a multiday event. The ones I were using were date only, not date+time. I can spin up a new install and document it better if you'd have time to dig into this soon.
Comment #26
erutan commentedDrupal 10.4.8 and FullCalendar 3.0.3, steps to reproduce on a fresh install:
1) Choose an entity/bundle with two or more core date fields.
2) Create a view with fullcalendar as a view display
3) Add date fields to the view
All entries are duplicated.
4) Optionally select two date fields for the view to use.
All entries are duplicated.
That's pretty straightforward IMO.
I'm not sure how long this will be up, but admin:admin on https://master-tb3wj0kram2h8gdhhswittxkcve9fq07.tugboatqa.com/admin/stru...
Comment #27
erutan commentedComment #29
mandclu commentedThanks for the additional work here. I see now (having done a little testing) that my earlier optimism that we could skip processing by generating the $uniqueKey before calling the prepareEvent method was unfounded, since the logic for generating it depends on start and end keys that will not be available until after the method has been called.
@erutan thanks to your steps to reproduce, I was able to see the problem, and validate that the proposed code resolves it.
I do see a bigger problem, however. The patch also prevents multivalue date range fields from displaying as expected. That also means that recurring Smart Date fields only display the first value.
I suspect we need a deeper refactoring, to use different logic for date fields that are ranges (where it's reasonable to expect multiple events per entity) from entities that need multiple fields for a single value (and where multiple events per entity are less likely). We currently have some of this logic within the getEventStartEndDates() method, but some different logic might be needed at a different level.
Comment #31
mandclu commentedHere's a new MR with a tweaked approach. In my testing it eliminates the duplicate display for datetime fields, but preserves the multivalue display for ranges.
Comment #32
erutan commentedThanks for coming back to module mandclu, and taking a deeper look into this issue!
#70 works on my end, though I did not test multi-value ranges.