Hi,

The date field widget repeat options, whilst very flexible, are overkill for some simple use cases. For example, a birthday or anniversary reminder where the repeat rule will be every year. (It's also a bit off-putting when asked for the end date in a birthday/anniversary context!)

It would be great to be able to set a field up with a preset rule so that the user is presented with a checkbox labelled something like 'every year'. One example is the Amazon 'create reminders' form which has a single 'every year' check box. Looking at iCal I see there are selections for every day, every week, every month, and every year, plus a custom option which leads to the full repeat options form.

As I couldn't see any mention of this sort of functionality I took the liberty of making a small patch which supports the basic use of a single checkbox to invoke a single preset rule. To enable the checkbox (and disable the standard repeat form) there is a setting in the date widget settings page, together with settings to enter the preset rule and to give the checkbox a label.

An example rule would be: RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20120615T230000Z;WKST=SU. There has to be an UNTIL in there but in this context I would set it to the expected life of the site. I think there are plans to remove the requirement for UNTIL but from what I've seen that's a major change.

If there's any interest I'm sure it wouldn't be too hard to roll something more substantial.

Andy

Comments

chaps2’s picture

StatusFileSize
new20.92 KB

oh, and here's the patch:

chaps2’s picture

Priority: Minor » Normal
StatusFileSize
new23.49 KB

Anybody?...

Here's a slightly improved version. Check out a demo on http://demo1.locologic.co.uk. Log in as cckfp/cckfp to get admin rights over content types and edit event type to see the admin interface. Create events or edit user profile to see it in action.

arlinsandbulte’s picture

I checked out your demo, looks nice, but I think this is a better approach: #272404: Make 'until' field optional.
If we just make the until date optional, you would not need a check box for every year (or every month, or every week, or every day, or every hour........), and it could use the current repeat options, which are already in place.

Also, we don't need to eliminate the year requirement for things like birthdays and anniversaries. Those items could just be set as yearly repeating with no until date (goes forever). After all, they DID really happen on an actual date with a year.

I do agree that the current repeat options can be overkill and confusing, but they are quite powerful, allowing for all sorts of repeat options. Instead of reducing the functionality, though, the interface could be improved. Also, if you don't want to expose all that power on your site, how about using some hook_form_alter or theming to adjust?

What do other people think? Do my thoughts above make sense? What direction should the Date module take?

chaps2’s picture

@arlinsandbulte - thanks for your comments - great to have some feedback.

IMO this patch and #272404 address different issues. Removing the need for the until field helps - being prompted for an end date can be a very unnatural thing in some contexts - but it's not the whole story.

In my demo I have two fields birthday and anniversary on the user profile node which are implicitly repeating dates. The user shouldn't be prompted for any repeat date information. This patch allows you to do that.

NB the lack of year field is nothing to do with the patch but how I configured the date field widgets. If I wanted the year then the fields would be labelled date of birth and marriage date respectively! Also repeating dates store a row in the database for each repeat (although the #272404 issue should fix that) - if somebody entered the birthdays of all their elderly relatives there would be 80 odd rows for each birthday entered most of which are serving no purpose whatsoever (I mean rows not relatives!). If I do need the year they were born I'd probably capture it in a separate field.

In answer to your last point I think this patch compliments the existing repeat date functionality. It certainly doesn't reduce it. Of course you can do much with hook_form_alter and theming but IMHO this is a regular feature that should be accessible to all.

karens’s picture

I agree there is a need for a simpler UI for repeats, but there is no agreement about exactly what that would look like. I think your concept is interesting, a number of preset rules with simple labels, 'yearly', 'weekly', 'every Monday, Wednesday, and Friday', etc. The problem is deciding what those presets should be and coming up with a list that is long enough to be useful without being overwhelming.

We can easily add in a field setting to allow a switch from the 'simple' to the 'advanced' form, or keep the advanced options hidden away in a collapsed fieldset, or whatever.

Before spending time writing code though, I would like to see some thought go into exactly what this UI would look like -- what options would be shown in our 'simple' model.

I have been looking at other calendar systems for guidance -- Google calendar, Yahoo calendar, Upcoming.org, Meetup.com, etc. I think it is perfectly acceptable to take screenshots from them and make notes and changes on them and saying 'we should make it look like this'.

chaps2’s picture

Looking at iCal (I will look at some others) here's what I would want it to look like:

From a user's perspective we should support the following types of repeat date UI:

  1. Implicit preset. Set by admin and applied automatically - so no UI
  2. Explicit presets. One or more labelled presets for user to choose from - i.e. every year, every month etc to support common use cases - user may select one only. Presets and labels set by admin.
  3. Full repeating date with until date as exists.
  4. Full repeating date but without until date. Until date is preset by admin (per field or system? - per field with system default). Takes some pressure off a proper implementation of #272404: Make 'until' field optional although export would reveal hidden UNTIL.
  5. Combination of 2 + 3 or 4. I don't see any sense in combining 1 + 3 or 4. List of presets includes a custom option.

For the administrator the date widget admin interface needs:

  1. Table of presets. On each row there are the following columns:
    1. checkbox to enable the preset rule
    2. select field to select common pre-configured preset rules (to save admin the necessity and complexity of entering an iCal rrule). Select box has custom option to allow admin to enter any arbitrary iCal rrule in the next column
    3. text field to allow custom rrule entry as described above.
    4. text field for label entry - may default for pre-configured preset rules
  2. Checkbox to show/hide full repeat date UI
  3. Checkbox to choose whether first enabled preset is applied automatically (a bit wooly - could have separate section for this with own rule entry)
  4. Checkbox to hide and preset until date.
  5. Field to enter the until date - similar to the "date to" field.

I suppose an alternative to admin preset rule entry would be to use the full repeat date UI in place of a text field - clunky but easier.

@KarenS - having used cck, date, and calendar, I really appreciate the time and effort you (and others) have put into them - truly impressive!

arlinsandbulte’s picture

Hmmm, all good thoughts here.
Here is another one:
What if we are approaching this from the wrong direction? In the case of a birthday or anniversary, in reality, these ARE SINGLE dates (I was born on mm/dd/yy at hh:mn), but they are recognized annually (or monthly or weekly in the case of young love-sick couples anniversaries’ ;-).
We could keep the date as such (just a single date event)...
BUT....
In our views, we should be able to filter ignoring the year. So, we could make a list with all birthdays this month or all brithdays today. Or somehow, show all birthdays on the calendar regardless of the calendar year.
This would also be useful for those that want to do some sort of "on this day in history" type queries.

This approach places the burden on how the view display is configured and not how the date is entered, which I think is appealing. Users would have a simple date enty from, but all the heavy lifting would be done by the site builder.

Maybe this is possible now?

chaps2’s picture

@arlinsandbulte - your proposal addresses implicitly repetitive dates only as it doesn't give the user any option to specify any repeat rule - whether preset or not.

It probably is possible to do it this way but I don't think that negates the need to do it the other way as well. You propose to make a single date look like a repeating date - putting that repeating logic in any view, notifications, or other code/configuration that needs to treat a single date as such. That may be acceptable for very simple use cases but doesn't support the general case very well. If a date represents a repeating event (and I do think a birthday is such an event - but lets not limit the discussion to birthdays and anniversaries) then it is more correct (and more valuable) to codify that information with the date.

arlinsandbulte’s picture

Ahhh, wait. I get it now (at least I think so). I was ignoring the title here. We are really talking about 2 different things.
Your proposal is ONLY about adding another widget type or options for simpler repeat options. The underlying data structure and format need not change, just the options presented to the user. Not quite as all-inclusive, but that is not always needed.
Great! I wholeheartedly agree!
Sorry for confusing the issue.

I was trying to promote the #272404: Make 'until' field optional issue, which I now understand is something completely different than what you intended (although as you said, quite desirable).
I will put the "on this day in history" feature request in another issue.

chaps2’s picture

Perhaps I'm guilty of confusing the issue by including an until date work-around in the list of features for the UI. I'll remove it as it doesn't really belong in this issue.

linksync’s picture

Hi chaps 2 - love your patch - had a client that needed to add several hundred pages to their site, all with anniversaries, and your repeat option saved them.

Any chance you could post a patch version for the most recent dev version of Date?

Thanks again.

xkater’s picture

subscribe

entrigan’s picture

I like the simplified interface. Now if it only supported multiple presets then this could be a viable widget.

entrigan’s picture

chaps2: Have you considered splitting this out into a separate module? that might make it easier to work with and hack on.

entrigan’s picture

I tested the patch from #2 against 2.x-dev and I am getting several of the following error:

warning: date_format() expects parameter 1 to be DateTime, string given in /Applications/MAMP/htdocs/repo/date/sites/all/modules/date/date_api.module on line 710.

However the patch works, and it is correctly saving the repeated dates. Thanks for the great patch!

entrigan’s picture

StatusFileSize
new11.67 KB

I hard-coded and hacked the widget a bit so that it is a select list with a predetermined rrule set of options (see image).

I tried splitting it out into its own module, unsuccessfully. I had trouble integrating with the existing date widgets/fields (it seemed like a few things were hard coded). Anyway my code is not well designed, so I am not going to post it, but if anyone wants more info I am glad to share.

nadav’s picture

THANK YOU!
chaps2 from #2
You are #1!!

bmblack’s picture

@entrigan - I'm trying to accomplish exactly what your screenshot shows. Could you please share your info w/ me?

twistedindustries’s picture

@entrigan - I second that, please post some code.

I applied the patch from #2 into Date 6.x-2.6 and it didn't seem to work.

chaps2’s picture

StatusFileSize
new21.75 KB

Thanks for all your comments.

Here's an updated patch that works with Date 6.x-2.6 and the latest 6.x-2.x-dev versions. Enjoy!

Marlies’s picture

I've installed the patch but I'm getting an error now when i go to the specific content type to edit: - manage fields - date:

Fatal error: require_once() [function.require]: Failed opening required './sites/all/modules/date/date/date_admin.inc' (include_path='.;C:\php5\pear') in C:\wamp\www\website\sites\all\modules\date\date\date.module on line 546

chaps2’s picture

Is it possible that you have applied the patch incorrectly? Is the date_admin.inc file still there?. Which version have you applied it to and what steps did you take to apply the patch?

Marlies’s picture

It was my first patch ever..

but I applied it to date 6.x

my steps were;

I put the patch file at C:/
opened Cygwin.bat (like cmd)

with cd I went to the specific map of the date module
then i patched it;
c:/cygwin/bin/patch.exe -p0 <
this should be correct, i followed cygwin steps @ drupal website

it patched 3 files:
date/date_admin.inc
date/date_repeat.inc
date_repeat/date_repeat-form.inc

so after it did that, i tried to go to content type - manage fields - date.. but then I get the error.

The file date_admin.inc is still there..

Marlies’s picture

it works now! Don't know why, I copied the patched files to a seperate folder, then I downloaded my (working) website again with the normal files, than I copied the pathed files and overwrited the normal files, now it does work! I am so glad!! Thank you so much!

chaps2’s picture

StatusFileSize
new4.51 KB

I finally got round to putting this stuff in a separate module.

The module supports two types of preset:

  1. Select a preset repeat from a list. (E.g. every year, every month, every week). Up to 5 configurable preset repeat rules are allowed as well as the options to not repeat or, if configured, to specify a custom repeat rule via the standard form. This is similar to the way iCal on OS X does it.
  2. A single configurable preset rule which is either applied automatically for a specialised date field (e.g. your birthday, anniversary etc) or via a checkbox for a more general "is this an annual event" type field. This is the functionality that was added by the patch above.

It's a bit rough and ready but please have a play!

Andy

chaps2’s picture

A quick demo of what it does: http://screencast.com/t/D0hSzdjgy2cl

kirkcaraway’s picture

chaps2, I've installed the presets module and activated it, but can't find where to set the presets. Very excited about this module. Saves me a lot of hacking. Thanks.

chaps2’s picture

@kirkcaraway - in a nutshell, the configuration options are added to any CCK repeat date field widget options after the "Repeat Display" setting at the botton of the form. The widget type of the date field must have "with Repeat options".

kirkcaraway’s picture

Thanks, I found it and it works fine. Great job. I can see a lot of people who will find this very useful.

chaps2’s picture

Status: Needs work » Needs review
StatusFileSize
new8.08 KB

Here is a much improved version although it now has a dependency on the ahah_helper module.

I've set this to "needs review" as I have requested CVS access to release this module on d.o. and would appreciate some feedback as to whether that is the best way to go with this requirement.

chaps2’s picture

There's a demo at drpdemo.locologic.co.uk.

entrigan’s picture

Just tested it out, it works great and as expected.

In my opinion, this simplified widget is in most cases superior and more appropriate than the current date repeat selection widget, and therefor this module should be (once ready) included in the date module.

However understandably there are a lot of reasons why adding ui complexity to an "api" module would be unwanted, in which case I say we get this released as a separate contrib module ASAP.

eL’s picture

Nice, I am looking for this solution for two days. Thanks!

But module itself is not working very well... If I chose Preset type, web freeze... and AHAH module is in conflict with HS module at all.

And there are some warnings:

Warning: Call-time pass-by-reference has been deprecated in C:\wamp\www\sites\all\modules\date_repeat_presets\date_repeat_presets.module on line 8

clintthayer’s picture

Subscribe

entrigan’s picture

@eL, I did not have any of these erros. What versios of each module are you using? and by HS are you referring to hierarchical select?

chaps2’s picture

Status: Needs review » Fixed

Now released as a module - http://drupal.org/project/date_repeat_presets!

@entrigan, thanks for the code review.

@eL, thanks for the feedback. I've cleared those warnings in the released version but I would need more info on the "web freeze". Would you open an issue on the new project page please?

Andy

Status: Fixed » Closed (fixed)

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