Commit 66bda87d authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #1998266: Add 'Exception day' feature - add config schema, sorting

parent ab6333c1
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -89,6 +89,19 @@ field.formatter.settings.office_hours:
        closed_text:
         type: label
         label: 'Currently closed message'
    exceptions:
      type: mapping
      label: 'Exception dates'
      mapping:
        restrict_exceptions_to_num_days:
          type: integer
          label: 'Restrict exceptions display to x days in future'
        date_format:
          type: string
          label: 'Date format for exception day'
        title:
         type: label
         label: 'Title for exceptions'
    timezone_field:
      type: string
      label: 'Timezone field'
+1 −1
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ trait OfficeHoursFormatterTrait {
      if (!$item->isExceptionDay()) {
        return TRUE;
      }
      if (self::$horizon == NULL) {
      if (self::$horizon == 0) {
        // Exceptions settings are not set / submodule is disabled.
        return FALSE;
      }
+1 −1
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ abstract class OfficeHoursFormatterBase extends FormatterBase {
    $element['exceptions'] = [
      '#title' => $this->t('Exception day handling'),
      '#type' => 'details',
      '#open' => TRUE,
      '#open' => FALSE,
    ];
    // Get the exception date formats.
    // @todo Use $container->get('entity_type.manager').
+2 −2
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ class OfficeHoursItemList extends FieldItemList implements OfficeHoursItemListIn
   * {@inheritdoc}
   */
  public function getRows(array $settings, array $field_settings, array $third_party_settings, $time = NULL) {
    // @todo move more from getRows here, using itemList, not values.
    $this->keepExceptionDaysInHorizon($settings['exceptions']['restrict_exceptions_to_num_days'] ?? NULL);
    // @todo Move more from getRows here, using itemList, not values.
    $this->keepExceptionDaysInHorizon($settings['exceptions']['restrict_exceptions_to_num_days'] ?? 0);
    return $this->getFieldRows($this->getValue(), $settings, $field_settings, $third_party_settings, $time);
  }

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class OfficeHoursExceptionsWeekWidget extends OfficeHoursWeekWidget {
        $indexed_items[$day][] = $item;
      }
    }
    OfficeHoursDateHelper::weekDaysOrdered($indexed_items);
    $indexed_items = OfficeHoursDateHelper::weekDaysOrdered($indexed_items);

    $field_name = $this->fieldDefinition->getName();
    // Add more days if we clicked "Add exception".