diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 8a18d69..676fdb6 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -126,8 +126,7 @@ public function form(array $form, FormStateInterface $form_state) { if ($view->isLocked()) { $username = [ '#theme' => 'username', - '#account' => $this->entityManager->getStorage('user') - ->load($view->lock->owner), + '#account' => $this->entityManager->getStorage('user')->load($view->lock->owner), ]; $lock_message_substitutions = [ '@user' => \Drupal::service('renderer')->render($username), @@ -212,6 +211,26 @@ public function form(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + protected function actions(array $form, FormStateInterface $form_state) { + $actions = parent::actions($form, $form_state); + unset($actions['delete']); + + $actions['cancel'] = [ + '#type' => 'submit', + '#value' => $this->t('Cancel'), + '#submit' => ['::cancel'], + '#limit_validation_errors' => [], + ]; + if ($this->entity->isLocked()) { + $actions['submit']['#access'] = FALSE; + $actions['cancel']['#access'] = FALSE; + } + return $actions; + } + + /** + * {@inheritdoc} + */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); @@ -335,18 +354,15 @@ public function getDisplayTab($view) { // page. if (empty($display)) { // @TODO: Improved UX for the case where a plugin is missing. - $build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array( - '@display' => $display->display['id'], - '@plugin' => $display->display['display_plugin'] - )); } + $build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", ['@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']]); + } // Build the content of the edit page. else { $build['details'] = $this->getDisplayDetails($view, $display->display); } // In AJAX context, ViewUI::rebuildCurrentTab() returns this outside of form // context, so hook_form_views_ui_edit_form_alter() is insufficient. - \Drupal::moduleHandler() - ->alter('views_ui_display_tab', $build, $view, $display_id); + \Drupal::moduleHandler()->alter('views_ui_display_tab', $build, $view, $display_id); return $build; } @@ -369,18 +385,12 @@ public function getDisplayDetails($view, $display) { // The master display cannot be duplicated. $is_default = $display['id'] == 'default'; // @todo: Figure out why getOption doesn't work here. - $is_enabled = $view->getExecutable()->displayHandlers->get($display['id']) - ->isEnabled(); + $is_enabled = $view->getExecutable()->displayHandlers->get($display['id'])->isEnabled(); if ($display['id'] != 'default') { $build['top']['#theme_wrappers'] = ['container']; $build['top']['#attributes']['id'] = 'edit-display-settings-top'; - $build['top']['#attributes']['class'] = [ - 'views-ui-display-tab-actions', - 'edit-display-settings-top', - 'views-ui-display-tab-bucket', - 'clearfix' - ]; + $build['top']['#attributes']['class'] = ['views-ui-display-tab-actions', 'edit-display-settings-top', 'views-ui-display-tab-bucket', 'clearfix']; // The Delete, Duplicate and Undo Delete buttons. $build['top']['actions'] = [ @@ -397,10 +407,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Enable @display_title', ['@display_title' => $display_title]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDisplayEnable', - '::submitDelayDestination' - ], + '#submit' => ['::submitDisplayEnable', '::submitDelayDestination'], '#prefix' => '
  • ', "#suffix" => '
  • ', ]; @@ -433,10 +440,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Duplicate @display_title', ['@display_title' => $display_title]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDisplayDuplicate', - '::submitDelayDestination' - ], + '#submit' => ['::submitDisplayDuplicate', '::submitDelayDestination'], '#prefix' => '
  • ', "#suffix" => '
  • ', ]; @@ -446,10 +450,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Delete @display_title', ['@display_title' => $display_title]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDisplayDelete', - '::submitDelayDestination' - ], + '#submit' => ['::submitDisplayDelete', '::submitDelayDestination'], '#prefix' => '
  • ', "#suffix" => '
  • ', ]; @@ -463,10 +464,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Duplicate as @type', ['@type' => $label]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDuplicateDisplayAsType', - '::submitDelayDestination' - ], + '#submit' => ['::submitDuplicateDisplayAsType', '::submitDelayDestination'], '#prefix' => '
  • ', '#suffix' => '
  • ', ]; @@ -477,10 +475,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Undo delete of @display_title', ['@display_title' => $display_title]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDisplayUndoDelete', - '::submitDelayDestination' - ], + '#submit' => ['::submitDisplayUndoDelete', '::submitDelayDestination'], '#prefix' => '
  • ', "#suffix" => '
  • ', ]; @@ -490,10 +485,7 @@ public function getDisplayDetails($view, $display) { '#type' => 'submit', '#value' => $this->t('Disable @display_title', ['@display_title' => $display_title]), '#limit_validation_errors' => [], - '#submit' => [ - '::submitDisplayDisable', - '::submitDelayDestination' - ], + '#submit' => ['::submitDisplayDisable', '::submitDelayDestination'], '#prefix' => '
  • ', "#suffix" => '
  • ', ]; @@ -900,14 +892,12 @@ public function buildOptionForm(ViewUI $view, $id, $option, $display) { $option_build['#description'] = $option['title']; - $option_build['#link'] = $view->getExecutable()->displayHandlers->get($display['id']) - ->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']); + $option_build['#link'] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']); $option_build['#links'] = []; if (!empty($option['links']) && is_array($option['links'])) { foreach ($option['links'] as $link_id => $link_value) { - $option_build['#settings_links'][] = $view->getExecutable()->displayHandlers->get($display['id']) - ->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value); + $option_build['#settings_links'][] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value); } } @@ -917,12 +907,8 @@ public function buildOptionForm(ViewUI $view, $id, $option, $display) { } else { $display_id = $display['id']; - if (!$view->getExecutable()->displayHandlers->get($display['id']) - ->isDefaultDisplay() - ) { - if ($view->getExecutable()->displayHandlers->get($display['id']) - ->defaultableSections($id) - ) { + if (!$view->getExecutable()->displayHandlers->get($display['id'])->isDefaultDisplay()) { + if ($view->getExecutable()->displayHandlers->get($display['id'])->defaultableSections($id)) { $option_build['#overridden'] = TRUE; } } @@ -951,12 +937,7 @@ public function getFormBucket(ViewUI $view, $type, $display) { $build['#name'] = $type; $build['#title'] = $types[$type]['title']; - $rearrange_url = Url::fromRoute('views_ui.form_rearrange', [ - 'js' => 'nojs', - 'view' => $view->id(), - 'display_id' => $display['id'], - 'type' => $type - ]); + $rearrange_url = Url::fromRoute('views_ui.form_rearrange', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id'], 'type' => $type]); $class = 'icon compact rearrange'; // Different types now have different rearrange forms, so we use this switch @@ -965,11 +946,7 @@ public function getFormBucket(ViewUI $view, $type, $display) { case 'filter': // The rearrange form for filters contains the and/or UI, so override // the used path. - $rearrange_url = Url::fromRoute('views_ui.form_rearrange_filter', [ - 'js' => 'nojs', - 'view' => $view->id(), - 'display_id' => $display['id'] - ]); + $rearrange_url = Url::fromRoute('views_ui.form_rearrange_filter', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id']]); // TODO: Add another class to have another symbol for filter rearrange. $class = 'icon compact rearrange'; break; @@ -1009,19 +986,8 @@ public function getFormBucket(ViewUI $view, $type, $display) { $actions['add'] = [ 'title' => $add_text, - 'url' => Url::fromRoute('views_ui.form_add_handler', [ - 'js' => 'nojs', - 'view' => $view->id(), - 'display_id' => $display['id'], - 'type' => $type - ]), - 'attributes' => [ - 'class' => [ - 'icon compact add', - 'views-ajax-link' - ], - 'id' => 'views-add-' . $type - ], + 'url' => Url::fromRoute('views_ui.form_add_handler', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id'], 'type' => $type]), + 'attributes' => ['class' => ['icon compact add', 'views-ajax-link'], 'id' => 'views-add-' . $type], ]; if ($count_handlers > 0) { // Create the rearrange text variable for the rearrange action. @@ -1030,13 +996,7 @@ public function getFormBucket(ViewUI $view, $type, $display) { $actions['rearrange'] = [ 'title' => $rearrange_text, 'url' => $rearrange_url, - 'attributes' => [ - 'class' => [ - $class, - 'views-ajax-link' - ], - 'id' => 'views-rearrange-' . $type - ], + 'attributes' => ['class' => [$class, 'views-ajax-link'], 'id' => 'views-rearrange-' . $type], ]; } diff --git a/core/themes/stable/css/views_ui/views_ui.admin.theme.css b/core/themes/stable/css/views_ui/views_ui.admin.theme.css index afc4ab1..d747776 100644 --- a/core/themes/stable/css/views_ui/views_ui.admin.theme.css +++ b/core/themes/stable/css/views_ui/views_ui.admin.theme.css @@ -363,11 +363,6 @@ td.group-title { outline: none; text-decoration: underline; } -.views-displays .tabs li a:hover, -.views-displays .tabs li.is-active a, -.views-displays .tabs li.is-active a.is-active { - /* border-bottom: 3px solid #004f80; */ -} .views-displays .tabs .open > a { position: relative; } @@ -661,7 +656,7 @@ td.group-title { .view-preview-form__title { display: inline; } -#edit-displays-live-preview{ +#edit-displays-live-preview { margin: 25px 0 20px 14px; } [dir="rtl"] .view-preview-form .form-item-live-preview {