Problem/Motivation
#2786577: The Views integration Datetime Range fields should extend the views integration for regular Datetime fields will add proper support for date plugins for data range fields, but specific filters that take into account both start and end date are needed.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#63 | 2924061-nr-bot.txt | 10.01 KB | needs-review-queue-bot |
#53 | interdiff_51-53.txt | 4.01 KB | Suresh Prabhu Parkala |
#53 | 2924061-53.patch | 38.74 KB | Suresh Prabhu Parkala |
#51 | 2924061-51.patch | 37.99 KB | karishmaamin |
#51 | interdiff_2924061_47-51.txt | 5.28 KB | karishmaamin |
Issue fork drupal-2924061
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
geertvd CreditAttribution: geertvd at Geert van Dort commentedFor #2699477: Steps towards handling end dates in Calendar 8 we'd need some specific date range arguments.
At the moment we just add arguments filtering on a date range's start date, this gives problems for events overlapping multiple months.
For our use case I think there's 2 options:
Once #2786577: The Views integration Datetime Range fields should extend the views integration for regular Datetime fields is in we could create an arguments for both the start date en end date and set the operator to ">=" and "<="
Comment #3
geertvd CreditAttribution: geertvd at Geert van Dort commentedTo be clear, I don't think we need the "Calculated Date" argument as proposed in #2544832: Views argument for the datetime module should use maths., I'm just talking about the configurable operators which is talked about in that issue.
Comment #4
geertvd CreditAttribution: geertvd at Geert van Dort commentedI needed something like to be able to create a calendar view with date ranges. For now I opted for my first suggestion.
This patch if far from complete but I might unblock some people in #2699477: Steps towards handling end dates in Calendar 8.
Keeping to postponed until #2786577: The Views integration Datetime Range fields should extend the views integration for regular Datetime fields is in.
Comment #5
jhedstromComment #7
jibran#2786577: The Views integration Datetime Range fields should extend the views integration for regular Datetime fields is in.
Comment #8
dwwThere's no reason this is postponed anymore, right? Needs work given patch #4, "needs tests", etc, but someone could start moving this forward at this point, no?
Thanks,
-Derek
Comment #9
mpdonadioYeah, the blocking issues are in 8.6.x, so this can start up again.
Comment #10
plachThe attached patch builds on #4 and implements approach 2: i.e. it provides an operator to filter on date range. In fact solution 1 requires two arguments in a Calendar view, which was breaking pagers in my installation.
To achieve this cleanly the patch adds a
DateRange
argument extending the existingDate
one. It also provides a subclass for each supported granularity, to be consistent withDatetime
, however I'm not sure why we need this and we don't just provide a granularity selector on the parent class.Tests still missing as this will likely need at very least some refinement.
Comment #11
AnybodyComment #14
catchRe-rolled.
Comment #15
AnybodyGreat, thank you! I'll review this further, but so far RTBC +1
Comment #16
codeclarified CreditAttribution: codeclarified at Oomph, Inc. commentedRe-rolled 2924061-10.patch for 8.6.16Actually, ignore me, 10 should still apply cleanly to 8.6.16, composer decided to mess with me by bumping my core version to 8.7 which is where the patch failed to apply
Comment #17
Anybody#14 is working for me with 8.7.1 while #16 failed to apply.
Comment #18
AnybodyComment #19
yogeshmpawar#14 working for me as well & #16 failed to apply on 8.8.x branch, also no interdiff added for #16 so removing this patch from the issue for now. @codeclarified - if you want you can add your patch again with an interdiff so that It will be really helpful for reviewers to review (See here details about how to create an interdiff).
Comment #20
slefevre@ccad.edu CreditAttribution: slefevre@ccad.edu commentedBoth #14 and #16 fail to apply for me on 8.7.3Scratch that, I wasn't applying them correctly.
Comment #21
imclean CreditAttribution: imclean commentedThis sounds very useful but I can't quite follow what this patch is supposed to do beyond "specific filters that take into account both start and end date". Would it be possible for someone to please update the IS with a full explanation of the goals here? For example, what filters, arguments and sort options it will offer.
Comment #22
imclean CreditAttribution: imclean commentedOr will specific filters etc. be possible via plugins with this patch?
Comment #24
FiNeX CreditAttribution: FiNeX as a volunteer commentedHi, the patch works if I create a field using the Drupal UI. It doesn't if the field has been created programmatically. Do I need to implement something extra on my code?
The following is the field definition on my Entity:
I've also reported the problem on the following issue: https://www.drupal.org/project/drupal/issues/2786577?page=1#comment-1337...
Comment #25
ckaotikSo far, the patch in #14 adds
datetime_range
variants of the argument handlers. It can filter on both start and end value at once (via the "Range intersects" operator in the newdatetime_range*
argument handlers), and allows configuring an operator for datetime field arguments in the first place.However, the new
datetime_range
argument handler does so far only seem to support theintersect_range
operator, and only adds an empty condition for all other operators? Potentially useful filtering might include queries such as (START and END being the argument/filter inputs):What I'm missing so far is
datetime.views.schema.yml
)Comment #26
imclean CreditAttribution: imclean commentedI've added some filters in Views Daterange Filters. It would be good to add the equivalent ones here as a minimum.
Comment #27
holist CreditAttribution: holist at Siili Solutions commentedI'm having the expected results by applying patch from #14 and adding two contextual filters in my view. Both filters refer to the same date field (date range starting date to be exact). The first one contains formula "greater than or equal" and the second one has formula "less than or equal". Now I add URL parameters to my view like
2020-01-01/2020-02-01
and I get rows with date from Jan 1st to Feb 1st.Maybe this explanation could help someone write the issue summary in a meaningful way.
Comment #29
brulain CreditAttribution: brulain commentedEverybody uses dates, but date management in D8 is very very much worse than date management in D7: How is it possible ? Is it a (stupid) choice ? A mistake ? An oversight ?
I dont understand, because many unnecessary gadgets have been added into D8.
Comment #30
colan#29: Drupal 8 core was almost a complete re-architecture. As such, modules generally had to be rewritten. So in order to make D8 shippable within a reasonable time frame, minimal requirements were set for planned features, which includes date functionality. Enhanced features were left for later.
Rather than complaining about it, you can help move things along by either directly helping with these issues yourself (by uploading patches, etc.), or paying someone else to do it. That's how open-source software development works.
Comment #31
brulain CreditAttribution: brulain commentedOK, and for what ? A modern gaz factory (french expression) ?
How many years or major versions will we have to wait for a decent date module ? D10, D11, ... ?
Well done man, the argument that kills. Rather, I suggest you do it right, starting with the basics: managing dates is part of the basics.
Comment #32
MrPaulDriver CreditAttribution: MrPaulDriver commentedI understand your frustration @brulain but I think you should stand down; this isn't how we cooperate and get stuff done around around here. Maybe Drupal isn't for you?
I agree that development of the date ecosystem has been hit and miss with Drupal 8. Hopefully this will improve as we move forward.
And yes, I agree that dates should be part of the basics; but the trouble is dates are not basic, they are very complicated. Time zones, different faith calendars, not to mention different ways of storing such information in a database.
Picking fights doesn't help. Please stop.
Comment #33
brulain CreditAttribution: brulain commentedThanks for your answer @MrPaulDriver.
This is more than frustration: it hasn't changed for 4 years.
So Drupal (8) isn't for me because the date module is still pathetic.
I do hope it will improve and not regress: but when ?...
I know that. But Drupal 8 implements many other more complex features (maybe more attractive): it is a matter of choice and prioritization.
Yes, sometimes it does.
I stop here, all is said. I have to be patient and have faith.
Comment #34
dipakmdhrm CreditAttribution: dipakmdhrm as a volunteer and at QED42 for Drupal India Association commentedHere's a try for the filter plugin for date range field:
I tried this with the most common application that I believe a date range filter could have: event search.
I may have over-engineered this in an effort to cover all possibilities.
Here's a list of the possibilities based on the following diagram:
What this patch does:
- Adds a new all-in-one filter for date range field (in addition to existing ones for end and start date components of the field) to cover all above possibilities.
- Uses HTML5 date field for exposed form for the field with date only storage.
- Uses combination of HTML5 date & time field for exposed form for the field with date & time storage.
Things still to do:
- Add argument (from #10) & sort plugins.
- Add tests
- Update hook to add schema for sites where this module is already installed
Gotchas:
- Filter for a field with both date & time storage doesn't work properly because states don't work for datetime field. See: https://www.drupal.org/project/drupal/issues/2419131
Comment #35
dipakmdhrm CreditAttribution: dipakmdhrm as a volunteer and at QED42 for Drupal India Association commentedAdded a couple of comments and removed a debug statement.
Comment #36
dipakmdhrm CreditAttribution: dipakmdhrm as a volunteer and at QED42 for Drupal India Association commentedArrggghhh... I created the patch for 8.8.x.
Will upload a new patch for 9.x version as well.
Comment #37
dwwThanks for your work on this!
However, I think this is turning into big scope creep. For example, we should fix #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter generally, not have daterange-only filters do it differently/better than date filters.
This looks unused (which is good, since I don't think we should care at the Field API level about anything in here).
s/Date/DateRange/
I think this wants {@inheritdoc}, instead.
Maybe move this to an inline comment at the start of the body?
"the" would fit on previous line.
"$rc" is a bit terse as a variable name. Can we be more verbose / self-documenting?
"on/at" seems weird.
A) Missing @param docs for $which.
B) Missing docs for @return
C) s/Provide/Provides/
@todo ;)
Slick, but basically out of scope. Or at least we should postpone this on solving it for 'date' filters, first. See #2648950.
A) s/comparision/comparison/
B) Would fit on previous line (and maybe "in", too).
C) s/sql/SQL/
Nice, but I don't think this will fly. ;)
A) You want @see if you're linking to a URL.
B) I doubt core committers will go for this as a substitute for actual inline docs that explain WTF is going on. ;)
This sure seems like a lot of code and complication. Maybe this is the only way. Haven't had my face deep in the views date* handling recently, so I don't know off the top of my head if this is all necessary, if it already basically exists elsewhere, etc, but raising flag of "wow, do we really need all this?"
Lots of missing PHPDocs here. Not flagging them all. Probably not worth documenting until we decide if we actually need all this.
Thanks again for your effort on this! I think maybe 'postponed' is best, and we make sure existing date* filters use a date form element first. Then we can circle back and do all this. But I won't unilaterally make that decision.
Cheers,
-Derek
Comment #38
dwwp.s. The bot flagged 20 code style errors at https://www.drupal.org/pift-ci-job/1721356 -- those will eventually need to be addressed, too (might be some overlap with what I already pointed out above).
Comment #39
dwwYeah, let's postpone this and get all hands on deck at #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter (and its blockers 🤦♂️).
Thanks,
-Derek
Comment #40
dwwAlso, since #2786577: The Views integration Datetime Range fields should extend the views integration for regular Datetime fields is already in (and there are a bunch of views handlers of various types for datetime_range) the scope of this is only the dedicated datetime_range filter plugin, right?
Comment #41
dipakmdhrm CreditAttribution: dipakmdhrm as a volunteer and at QED42 for Drupal India Association commentedCouple of thoughts on this (I might be wrong and missing something here):
Yep, I do believe I over-engineered it. But I do believe we should work on it so that we provide at least the following major filtering functionalities for something like events search:
Lastly, Thank you for your review of the patch. I'll definitely be more careful in future to avoid all the mistakes I did in this patch.
Comment #42
dww#37:
#39 (45 minutes later) - I do what I just said I wouldn't do. 🤦♂️
#41: You're totally right, these can definitely happen in parallel. 👍Thanks for (rightfully) pushing back.
Thanks for the patch, and you're welcome for the review. 😉 No worries about mistakes in the patch. That's why we have such a thorough review process / culture. It's how we learn. ;) Vastly better to contribute something (with "mistakes") and have to improve it, than to not contribute at all (a far greater "mistake").
Thanks/sorry,
-Derek
Comment #43
dipakmdhrm CreditAttribution: dipakmdhrm as a volunteer and at QED42 for Drupal India Association commentedNo worries at all!! Happens to the best of us.
Amen!
Comment #45
IT-CruAdded to Bug Smash Initiative because I think a lot of people (also me) thinking it is already integrated/possible to filter for a core provided date_range field based on start and end date with views.
Example: Display all events x days before they start and until they end.
Haven't figured out how to configure this with a date_range field and views yet. Please correct me if I'm wrong (currently really late in germany now...)
Comment #46
vakulrai CreditAttribution: vakulrai as a volunteer and at QED42 for QED42 commented@dipakmdhrm , @dww , I have made changes to the patch based on the inputs by #37.
Also I found some problem while saving the view with some default values to the filter config form, it was mainly happening because the the filter schema expects value as "String", but the Datetime was storing drupalDateTime() object to it.
I have added a solution to it , and also added test scenarios to test the new plugin.
Please review !.
Thanks
Comment #47
vakulrai CreditAttribution: vakulrai as a volunteer and at QED42 for QED42 commentedFixing some Cspell issues and coding standards.
Comment #49
JeroenTComment #50
karishmaamin CreditAttribution: karishmaamin at Specbee commentedWorking on re-roll
Comment #51
karishmaamin CreditAttribution: karishmaamin at Specbee commentedTried to fix some of custom command failure errors
Comment #52
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedNeeds to add "Doc comment" for some methods in file "DateRange.php" to fix the "custom command failed" Issues.
Comment #53
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedUpdate the patch as per #52. Please have a look.
Comment #57
Graber CreditAttribution: Graber at Tag1 Consulting for American Federation of Teachers commentedComment #58
Graber CreditAttribution: Graber at Tag1 Consulting for American Federation of Teachers commentedTurned out problems on our project originated elsewhere and patch from #14 still works fine. Added the current work to a fork, maybe it'll be easier to review.
Comment #62
jaime@gingerrobot.com CreditAttribution: jaime@gingerrobot.com at Ginger Robot commentedComment #63
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.