Commit e80eb510 authored by Robert Kasza's avatar Robert Kasza Committed by Róbert Kasza
Browse files

Issue #3303157 by PCate, kaszarobert: Add option to hide "Formatting options" dropdown

parent f50d3265
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -74,3 +74,6 @@ field.widget.settings.table_widget:
    placeholder:
      type: text
      label: 'Size'
    hide_formatting_options:
      type: boolean
      label: 'Hide formatting options'
+23 −8
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ class TableWidget extends WidgetBase implements ContainerFactoryPluginInterface
      'readonly_columns' => 0,
      'limit_operations' => FALSE,
      'enabled_operations' => [],
      'hide_formatting_options' => FALSE,
      'placeholder' => '',
    ] + parent::defaultSettings();
  }
@@ -161,6 +162,14 @@ class TableWidget extends WidgetBase implements ContainerFactoryPluginInterface
      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
    ];

    $elements['hide_formatting_options'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Hide formatting options'),
      '#default_value' => $this->getSetting('hide_formatting_options'),
      '#description' => $this->t('If the markup is not rendered for this table later, the Formatting options dropdown help can be hidden by checking this option.'),

    ];

    return $elements;
  }

@@ -223,6 +232,10 @@ class TableWidget extends WidgetBase implements ContainerFactoryPluginInterface
      $summary[] = $this->t('All operations are enabled.');
    }

    $summary[] = (empty($this->getSetting('hide_formatting_options'))) ?
      $this->t('Hide formatting options') :
      $this->t('Show formatting options');

    return $summary;
  }

@@ -282,6 +295,7 @@ class TableWidget extends WidgetBase implements ContainerFactoryPluginInterface
      '#weight' => 15,
    ];

    if (empty($this->getSetting('hide_formatting_options'))) {
      $description = $this->config->get('formatting_options');

      if (!empty($description)) {
@@ -292,6 +306,7 @@ class TableWidget extends WidgetBase implements ContainerFactoryPluginInterface
          '#weight' => 20,
        ];
      }
    }

    $licenseKey = $this->config->get('license_key') ?? '';
    $element['value']['#attached']['drupalSettings']['handsontable']['license_key'] = $licenseKey;