I was reading the (ancient) feature requests at #91686: Improvement of scheduling workflow because I was looking for a way to add repeating schedule items. I quickly realized that adding and especially managing repeating items would require a lot of code, which probably isn't worth the trouble. However it would make entering schedule items easier if you had the possibility to duplicate an item. This patch allows for that by adding a single checkbox to the form. Patch (against beta3) and screenshot attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | station-698832-6.patch | 1.82 KB | tim.plunkett |
| #4 | station-698832-4.patch | 2.07 KB | tim.plunkett |
| station-schedule-item-duplicate.png | 26.17 KB | marcvangend | |
| station_schedule_duplication.patch | 1.55 KB | marcvangend |
Comments
Comment #1
drewish commentedI like the idea but would it be better to have it as an additional duplicate button? they could click that rather than having the check box?
Comment #2
marcvangendI considered that too and I'm still not sure what users would expect and/or prefer. In the end I chose the checkbox because it allows for a description, so I had more space to explain what it does. On the other hand, a good button label would not need a description anyway.
Coming to think of it, I'm not sure if the word "duplicate" is right here, because you're not creating an exact duplicate of course. Maybe something like "new" or "copy" would be more appropriate.
I'd like to have some more votes on this (I'll ask my colleagues tomorrow what they think), but how about a "Save as new" button? ASCII mockup:
Comment #3
refreshingapathy commentedI'd vote for the "Save as New" button - slightly less confusing than the checkbox in my opinion.
Comment #4
tim.plunkettHow's this look?
As someone who has to make a new schedule every 3 months, I love this functionality.
Comment #5
drewish commentedThat seems fine but couldn't station_schedule_item_edit_duplicate_submit() just check the submit op? I guess this is probably cleaner since you'd don't have to worry about a t()'d string.
Oh and
will cause a PHP notice for not having $form_state['duplicate'] defined when you submit using the save handler.
Comment #6
tim.plunkettI was trying to avoid checking a t()'d string, because I'm still not sure how that works. Is it as simple as
($form_state['values']['op'] == t('Save as new'))?My other idea was to use
$form_state['clicked_button']['#id'], which also gets rid of the PHP notice. That's the attached patch.Comment #7
drewish commentedThat looks better but I think you could simplify it further:
Comment #8
tim.plunkettIn all of these patches, station_schedule_item_edit_form_validate() breaks with a null iid, it doesn't catch overlaps. I'll have to take a look at this tomorrow.
Comment #9
drewish commentedHumm, currently it's doing:
If iid is null it should what be cast to 0?