Hi Guys,
I refactored the display formatter and its settings. This should take care of all the uninitialized settings problems as well. Aside from removing the hard-coded CSS styling (bad form to include inline styling in the code), it should act exactly the same as what's currently in 7.x-1.x-dev
I've also added 2 features in my local copy. The first displays the current status (open/closed, displays text before or after and adds a CSS class to the currently active day(s)) and accounts for closing times past midnight. The second is using a tzfield to set the local timezone of the times (which is used in calculating the current status). Let me know if you want the patches for those as well.
Laz
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | office_hours-1595158-16.patch | 10.3 KB | Lazarus-Long |
| #15 | office_hours-1595158-8.patch | 16.46 KB | johnv |
| #12 | 0001-Fixed-issues-with-compressed-times.patch | 3.45 KB | Lazarus-Long |
| #11 | ScreenHunter_1.jpg | 63.84 KB | johnv |
| #11 | ScreenHunter_2.jpg | 21.75 KB | johnv |
Comments
Comment #1
Lazarus-Long commentedAnd a little bit of theming for good luck
Comment #2
dflitner commentedI would like that first feature you describe, especially adding a CSS class to the currently active day. Will try to test these patches and see how they work.
Comment #3
Lazarus-Long commentedHere's the patch from the current commit (d93cac3) for the status feature. It relies on the refactored display formatter, so that's included as well.
Comment #4
Ozeuss commentedI thought i commented on this issue and gave a patch...
0001 has been committed, cool!
0002- doesn't consider time format (ampm) display setting - we have this both on the widget and on the formatter level (for some reason...). Could you please add and reroll? thanks.
About the other 2 patches - Could you please add separate issues for these? that way it would be much easier for others to follow and review. Thanks!
Comment #5
Lazarus-Long commentedHi Ozeuss,
Here's a rollup of the display formatter changes from the current 7.x-1.x head. Should also show AM/PM for 12 hour times now.
Comment #6
Lazarus-Long commentedTypo'd the hoursformat setting in the last patch. Ignore it
Comment #7
johnvNice patch! shorter, cleaner code.
I couldn't apply the patch with git. Perhaps some problem with -p0 -p1 parameter?
Some things are broken:
- The day-label-width is moved to css, which is a good thing. But in code an educated guess was made about the width, using $max_label_length. Your patch adds a fixed widht, which generates worse result for short lables. See attached printscreen.
- When one or more day have 'more hours', every day has a is empty 'more hours' displayed. See attached printscreen, left and right column, lower row. With compressed display, output is OK.
- Although the output seems OK, in above function, a new separator is defined. This is confusing. Can't you pass $settings['separator_hours_hours'] ?
- In the third line of the printscreen, the store has 7 open days. However, in column "Hours -grouped, compressed"only 5 are shown. Sat+Sun are not shown. (First-day-of-week was set to Monday).
- This part comes from your other feature. I think t is missing from this one.
Comment #8
Lazarus-Long commentedThe fixed label length was meant to be fixed with CSS classes. The default min-width should be 6em and the grouped min-width should be 11em.
The missing more-hours I'll take a look at later tonight.
The separator in theme_office_hours_time_range() is a default to fill in any missing values. $settings['separator_hours_hours'] is passed from theme_office_hours_formatter_default().
Missing days I'll look into.
Not sure what you mean by missing t? Something is not translated?
Comment #9
johnvI meant : "I think it (+.oh-display-grouped .oh-display-label) is missing from this patch."
Comment #10
Lazarus-Long commentedDerp moment.
Yes, it is missing. I'll roll a new patch a little later.
Comment #11
johnvThis is already happening in current -dev.
There is an error when entering the value 00 vs. ' ' in the widget/node. See attach screendumps.
Perhaps you can find the cause.
Comment #12
Lazarus-Long commentedI think I've tracked this down. I wasn't able to re-create the effect from just the 00 values, but I believe it had to do with 00:00 - 00:00 meaning "open all day" rather than "closed". Shouldn't matter if the times were the first or second set of times.
Second part was just the label.
$info['endday'] ? true : false;rather than$info['endday'] !== null ? true : false;.Let me know how this goes.
Comment #13
Lazarus-Long commentedComment #14
johnvSee my patch attached.
- I've kept the programmed css-width.I've opened #1614206: How to set the label width correctly?, which you've already read.
- Check _office_hours_field_formatter_defaults(), for the use of array_merge() vs. drupal_array_merge_deep() vs. +
- I've ran the code through Coder, and removed most messages. Drupal doesn't like camelCase.
Comment #15
johnvHere's the patch.
Comment #16
Lazarus-Long commentedNice. I've made one more change. Both theme_ functions are in the theme.inc file now, and the formatter_view() function is in the .module. This way we can remove the module_load_include() for the theme file (and it will only be loaded by the theme system when needed).
Also, I noticed you removed the array_merge() from the default settings function. It won't matter for this feature, but when we start using sub-arrays in the settings (such as my status feature), it will need to use drupal_array_merge_deep instead. I haven't made any changes to it in this patch though.
Here's the patch, created after applying your patch in #15.
Comment #17
johnvOK, we can put back drupal_array_merge_deep() if/when it has a function;
Shouldn't we move most of office_hours_field_formatter_view() to the theme-function, hence out of the module-file? This makes the .module file lighter.
Comment #18
Lazarus-Long commentedIt may make the .module file lighter, but because the hook_field_formatter_view() is in the .theme.inc file, it has to be included when the .module file is loaded. This makes the .module effectively as large as both files combined, and includes one more file load at times that it may not actually be required (ie: loading editing pages)
Comment #19
johnvI understand, that's why i meant move most of office_hours_field_formatter_view(), leaving plm. 15 lines in.
Comment #20
Lazarus-Long commentedThe theme_ function should only be responsible for taking the data and displaying it, not for processing any of the information. Anything in that function has to be reimplemented by themers when they want to override the default theme/style.
The size of the .module file is already fairly small. I wouldn't worry too much about its size.
Comment #21
johnvOK.
Comment #22
johnvOK, this is committed, see 25e93f0.
Comment #23
Lazarus-Long commentedSweet. First attributed commit. Thanks mate.
Comment #24
johnvSomething is wrong.
On existing installations the widget is fine.
But on a fresh installation (or disable, enable the module) only 1 line of hours is shown.
Try this:
- (re-enable) the module.
- add a OH field
- add/change a node --> only 1 line of hours is shown, without the table-formatting
- now copy version 1.0 of the module in the modules/office_hours/directory.
- refresh all caches on the page (add/change a node), now the widget looks fine.
Comment #25
johnv