Loading README.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8,12 +8,14 @@ The widget provides: - 'allowed hours' restrictions; - input validation; - use of either a 24 or 12 hour clock; - (as per v8.x-1.7) an ability to add 'Exception days' with calendar date instead of weekday. The formatter provides o.a.: - a 'Current status' indicator ('open now'/'closed now'); - options to show all/none/open/current days; - options to group days (E.g., "Mon-Fri 12:00-22:00"); - customizable element separators to display the 'office hours' any way you want. (See below for details.) - (as per v8.x-1.7) an ability to determine the 'Exception days' to display in the future. You can configure the formatter as follows: - Add the field to an entity/node; Loading office_hours.theme.exceptions.inc +11 −1 Original line number Diff line number Diff line Loading @@ -49,11 +49,21 @@ function office_hours_exceptions_preprocess_field(array &$variables) { return $elements; } // If field settings for this view_mode are not set, yet. if (!isset($settings['exceptions']['title'])) { \Drupal::messenger()->addMessage( t("Please review the display settings for field %field_name in view mode %view_mode, and save them again.", [ '%field_name' => $field_name, '%view_mode' => $view_mode])); return $elements; } // Loop over formatters: $elements contains table/status/schema formatter. $label = $settings['exceptions']['title'] ?? ''; foreach ($elements as $key => &$element) if (is_numeric($key)) { // If there is an exception, add an extra row to label the exceptions. // Note: may be changed in template_preprocess_office_hours_table(). $label = $settings['exceptions']['title']; $exception_header = []; switch ($element['content']['#theme']) { Loading src/Plugin/Field/FieldFormatter/OfficeHoursFormatterBase.php +7 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,9 @@ abstract class OfficeHoursFormatterBase extends FormatterBase { /* // Find timezone fields, to be used in 'Current status'-option. $fields = field_info_instances( (isset($form['#entity_type']) ? $form['#entity_type'] : NULL), (isset($form['#bundle']) ? $form['#bundle'] : NULL)); $fields = field_info_instances( (isset($form['#entity_type']) ? $form['#entity_type'] : NULL), (isset($form['#bundle']) ? $form['#bundle'] : NULL)); $timezone_fields = []; foreach ($fields as $field_name => $timezone_instance) { if ($field_name == $field['field_name']) { Loading @@ -70,7 +72,10 @@ abstract class OfficeHoursFormatterBase extends FormatterBase { $timezone_field = field_read_field($field_name); if (in_array($timezone_field['type'], ['tzfield'])) { $timezone_fields[$timezone_instance['field_name']] = $timezone_instance['label'] . ' (' . $timezone_instance['field_name'] . ')'; $timezone_fields[$timezone_instance['field_name']] = $timezone_instance['label'] . ' (' . $timezone_instance['field_name'] . ')'; } } if ($timezone_fields) { Loading src/Plugin/Field/FieldType/OfficeHoursExceptionsItem.php +0 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,6 @@ namespace Drupal\office_hours\Plugin\Field\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItem; /** * Plugin implementation of the 'office_hours' field type. Loading src/Plugin/WebformElement/WebformOfficeHours.php +1 −1 File changed.Contains only whitespace changes. Show changes Loading
README.txt +2 −0 Original line number Diff line number Diff line Loading @@ -8,12 +8,14 @@ The widget provides: - 'allowed hours' restrictions; - input validation; - use of either a 24 or 12 hour clock; - (as per v8.x-1.7) an ability to add 'Exception days' with calendar date instead of weekday. The formatter provides o.a.: - a 'Current status' indicator ('open now'/'closed now'); - options to show all/none/open/current days; - options to group days (E.g., "Mon-Fri 12:00-22:00"); - customizable element separators to display the 'office hours' any way you want. (See below for details.) - (as per v8.x-1.7) an ability to determine the 'Exception days' to display in the future. You can configure the formatter as follows: - Add the field to an entity/node; Loading
office_hours.theme.exceptions.inc +11 −1 Original line number Diff line number Diff line Loading @@ -49,11 +49,21 @@ function office_hours_exceptions_preprocess_field(array &$variables) { return $elements; } // If field settings for this view_mode are not set, yet. if (!isset($settings['exceptions']['title'])) { \Drupal::messenger()->addMessage( t("Please review the display settings for field %field_name in view mode %view_mode, and save them again.", [ '%field_name' => $field_name, '%view_mode' => $view_mode])); return $elements; } // Loop over formatters: $elements contains table/status/schema formatter. $label = $settings['exceptions']['title'] ?? ''; foreach ($elements as $key => &$element) if (is_numeric($key)) { // If there is an exception, add an extra row to label the exceptions. // Note: may be changed in template_preprocess_office_hours_table(). $label = $settings['exceptions']['title']; $exception_header = []; switch ($element['content']['#theme']) { Loading
src/Plugin/Field/FieldFormatter/OfficeHoursFormatterBase.php +7 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,9 @@ abstract class OfficeHoursFormatterBase extends FormatterBase { /* // Find timezone fields, to be used in 'Current status'-option. $fields = field_info_instances( (isset($form['#entity_type']) ? $form['#entity_type'] : NULL), (isset($form['#bundle']) ? $form['#bundle'] : NULL)); $fields = field_info_instances( (isset($form['#entity_type']) ? $form['#entity_type'] : NULL), (isset($form['#bundle']) ? $form['#bundle'] : NULL)); $timezone_fields = []; foreach ($fields as $field_name => $timezone_instance) { if ($field_name == $field['field_name']) { Loading @@ -70,7 +72,10 @@ abstract class OfficeHoursFormatterBase extends FormatterBase { $timezone_field = field_read_field($field_name); if (in_array($timezone_field['type'], ['tzfield'])) { $timezone_fields[$timezone_instance['field_name']] = $timezone_instance['label'] . ' (' . $timezone_instance['field_name'] . ')'; $timezone_fields[$timezone_instance['field_name']] = $timezone_instance['label'] . ' (' . $timezone_instance['field_name'] . ')'; } } if ($timezone_fields) { Loading
src/Plugin/Field/FieldType/OfficeHoursExceptionsItem.php +0 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,6 @@ namespace Drupal\office_hours\Plugin\Field\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItem; /** * Plugin implementation of the 'office_hours' field type. Loading
src/Plugin/WebformElement/WebformOfficeHours.php +1 −1 File changed.Contains only whitespace changes. Show changes