You are here

class FullcalendarOptions in FullCalendar 8

Same name and namespace in other branches
  1. 8.3 fullcalendar_options/src/Plugin/fullcalendar/type/FullcalendarOptions.php \Drupal\fullcalendar_options\Plugin\fullcalendar\type\FullcalendarOptions

@todo.

Plugin annotation


@FullcalendarOption(
  id = "fullcalendar_options",
  module = "fullcalendar_options",
  js = TRUE
)

Hierarchy

Expanded class hierarchy of FullcalendarOptions

File

fullcalendar_options/src/Plugin/fullcalendar/type/FullcalendarOptions.php, line 17

Namespace

Drupal\fullcalendar_options\Plugin\fullcalendar\type
View source
class FullcalendarOptions extends FullcalendarBase {

  /**
   * {@inheritdoc}
   */
  public function defineOptions() {
    $options = [];
    foreach ($this
      ->optionsListParsed() as $key => $info) {
      $options[$key]['default'] = $info['#default_value'];

      // If this is a Boolean value, set the 'bool' flag for export.
      if (isset($info['#data_type']) && $info['#data_type'] == 'bool') {
        $options[$key]['bool'] = TRUE;
      }
    }
    return [
      'fullcalendar_options' => [
        'contains' => $options,
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $options = $this
      ->optionsListParsed();

    // There were no options added, remove the parent fieldset.
    if (!empty($options)) {
      $form['fullcalendar_options'] = [
        '#type' => 'details',
        '#title' => $this
          ->t('Extra options'),
        '#open' => TRUE,
      ];

      // Add the default value to each option.
      foreach ($options as $key => $info) {
        $form['fullcalendar_options'][$key] = $info;
        if (isset($this->style->options['fullcalendar_options'][$key])) {
          $form['fullcalendar_options'][$key]['#default_value'] = $this->style->options['fullcalendar_options'][$key];
        }
      }
    }
  }

  /**
   * @todo.
   */
  public function optionsList() {
    $form = [];
    $form['firstHour'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('First hour'),
      '#description' => $this
        ->t('Determines the first hour that will be visible in the scroll pane.'),
      '#size' => 2,
      '#maxlength' => 2,
      '#default_value' => 6,
      '#data_type' => 'int',
    ];
    $form['minTime'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Minimum time'),
      '#description' => $this
        ->t('Determines the first hour/time that will be displayed, even when the scrollbars have been scrolled all the way up.'),
      '#size' => 2,
      '#maxlength' => 2,
      '#default_value' => 0,
      '#data_type' => 'int',
    ];
    $form['maxTime'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Maximum time'),
      '#description' => $this
        ->t('Determines the last hour/time (exclusively) that will be displayed, even when the scrollbars have been scrolled all the way down.'),
      '#size' => 2,
      '#maxlength' => 2,
      '#default_value' => 24,
      '#data_type' => 'int',
    ];
    $form['slotMinutes'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Slot minutes'),
      '#description' => $this
        ->t('The frequency for displaying time slots, in minutes.'),
      '#size' => 2,
      '#maxlength' => 2,
      '#default_value' => 30,
      '#data_type' => 'int',
    ];
    $form['defaultEventMinutes'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Default event minutes'),
      '#description' => $this
        ->t('Determines the length (in minutes) an event appears to be when it has an unspecified end date.'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => 120,
      '#data_type' => 'int',
    ];
    $form['allDaySlot'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('All day slot'),
      '#description' => $this
        ->t('Determines if the "all-day" slot is displayed at the top of the calendar.'),
      '#default_value' => TRUE,
      '#data_type' => 'bool',
    ];
    $form['weekends'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Weekends'),
      '#description' => $this
        ->t('Whether to include Saturday/Sunday columns in any of the calendar views.'),
      '#default_value' => TRUE,
      '#data_type' => 'bool',
    ];
    $form['lazyFetching'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Lazy fetching'),
      '#description' => $this
        ->t('Determines when event fetching should occur.'),
      '#default_value' => TRUE,
      '#data_type' => 'bool',
    ];
    $form['disableDragging'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Disable dragging'),
      '#description' => $this
        ->t('Disables all event dragging, even when events are editable.'),
      '#default_value' => FALSE,
      '#data_type' => 'bool',
    ];
    $form['disableResizing'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Disable resizing'),
      '#description' => $this
        ->t('Disables all event resizing, even when events are editable.'),
      '#default_value' => FALSE,
      '#data_type' => 'bool',
    ];
    $form['dragRevertDuration'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Drag revert duration'),
      '#description' => $this
        ->t('Time (in ms) it takes for an event to revert to its original position after an unsuccessful drag.'),
      '#size' => 6,
      '#maxlength' => 6,
      '#default_value' => 500,
      '#data_type' => 'int',
    ];
    $form['dayClick'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Day click'),
      '#description' => $this
        ->t('Switch the display when a day is clicked'),
      '#default_value' => FALSE,
      '#data_type' => 'bool',
    ];
    return $form;
  }

  /**
   * @todo.
   */
  protected function optionsListParsed() {
    $form = $this
      ->optionsList();
    $settings = \Drupal::config('fullcalendar_options.settings')
      ->get();

    // By default, restrict the form to options allowed by the admin settings.
    $form = array_intersect_key($form, array_filter($settings));
    if (isset($form['dayClick'])) {

      // Add in dependency form elements.
      $form['dayClickView'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('Display'),
        '#description' => $this
          ->t('The display to switch to when a day is clicked.'),
        '#default_value' => 'agendaWeek',
        '#options' => [
          'month' => $this
            ->t('Month'),
          'agendaWeek' => $this
            ->t('Week (Agenda)'),
          'basicWeek' => $this
            ->t('Week (Basic)'),
          'agendaDay' => $this
            ->t('Day (Agenda)'),
          'basicDay' => $this
            ->t('Day (Basic)'),
        ],
        '#states' => [
          'visible' => [
            ':input[name="style_options[fullcalendar_options][dayClick]"]' => [
              'checked' => TRUE,
            ],
          ],
        ],
      ];
    }
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FullcalendarBase::$style protected property @todo.
FullcalendarBase::preView public function Overrides FullcalendarInterface::preView 1
FullcalendarBase::process public function Overrides FullcalendarInterface::process 1
FullcalendarBase::setStyle public function Overrides FullcalendarInterface::setStyle
FullcalendarBase::submitOptionsForm public function Overrides FullcalendarInterface::submitOptionsForm 1
FullcalendarOptions::buildOptionsForm public function Overrides FullcalendarInterface::buildOptionsForm
FullcalendarOptions::defineOptions public function Overrides FullcalendarInterface::defineOptions
FullcalendarOptions::optionsList public function @todo.
FullcalendarOptions::optionsListParsed protected function @todo.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.