Closed (fixed)
Project:
Office Hours
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2013 at 10:21 UTC
Updated:
30 Apr 2013 at 21:40 UTC
At present, day values in the backend represents:
0 sunday AM (first value)
1 sunday PM (second value)
2 monday AM (first value)
3 monday PM (second value)
...
Proposal is to extend the backend to provide an extra column: daydelta and convert values to:
| day | daydelta | represents |
|---|---|---|
| 0 | 0 | 1st slot for sunday |
| 0 | 1 | 2nd slot for sunday |
| 0 | 2 | 3rd slot for sunday |
| 1 | 0 | 1st slot for monday |
| 2 | 0 | 1st slot for tuesday |
| 2 | 1 | 2nd slot for tuesday |
as shown, day is converted to a standard 0..6 and daydelta extends the model to allow more than two slots per day.
Related to #1710258: More than 2 Time Blocks Per Day: upgrade to 21, 28... hours per week
See #1913292: [META] Untangle office_hours for reference.
Comments
Comment #1
johnvPerhaps it is not necessary to change the scheme. We can use the field 'delta' and set the subfield 'day' to the day number, like this:
We need to be careful with existing data, though.
Comment #2
johnvITMT, I've implemented #1710258: More than 2 Time Blocks Per Day: upgrade to 21, 28... hours per week
After saving the data, the column 'day' does not contain the day-index any more (0,1,2,3,..,13).
It only contains the daynumber *2 : 0,2,4,6,8,10,12 .
It takes an upgrade_N hook to change this in all existing fields, an change code accordingly.
Comment #3
johnvThis is fixed using the existing 'day' column.
An update function for the database storage is added here (since hook_field_load() and hook_field_presave() are not invoked when showing the default value): #1964274: Default value not set after wednesday
There is a follow-up issue regarding the javascript widget: #1945230: Javascript for 'N time blocks per day' is not complete
Thanks jonhattan, for the ideas &patches.