diff --git a/core/modules/views/views_ui/css/views-admin.theme.css b/core/modules/views/views_ui/css/views-admin.theme.css index fd74623..a9c3c0f 100644 --- a/core/modules/views/views_ui/css/views-admin.theme.css +++ b/core/modules/views/views_ui/css/views-admin.theme.css @@ -577,30 +577,34 @@ ul#views-display-menu-tabs li.add ul.action-list li{ * The auto-preview checkbox line. */ -#views-ui-preview-form > div > div, -#views-ui-preview-form > div > input { +#views-ui-preview-form #edit-controls { + background-color: #e1e2dc; +} + +#views-ui-preview-form #edit-controls div, +#views-ui-preview-form #edit-controls input { float: left; } -#views-ui-preview-form .form-type-checkbox { +#views-ui-preview-form #edit-controls .form-type-checkbox { margin-top: 2px; margin-left: 2px; } -#views-ui-preview-form .form-type-textfield, #views-ui-preview-form .form-actions { +#views-ui-preview-form #edit-controls .form-type-textfield, #views-ui-preview-form #edit-controls .form-actions { margin-top: 5px; } -#views-ui-preview-form .arguments-preview { +#views-ui-preview-form #edit-controls .arguments-preview { font-size: 1em; } -#views-ui-preview-form .arguments-preview, -#views-ui-preview-form .form-type-textfield { +#views-ui-preview-form #edit-controls .arguments-preview, +#views-ui-preview-form #edit-controls .form-type-textfield { margin-left: 14px; } -#views-ui-preview-form .form-type-textfield label { +#views-ui-preview-form #edit-controls .form-type-textfield label { display: inline-block; float: left; font-weight: normal; @@ -609,11 +613,16 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } @media screen and (min-width:45em) { /* 720px */ - #views-ui-preview-form .form-type-textfield .description { + #views-ui-preview-form #edit-controls .form-type-textfield .description { white-space: nowrap; } } +#views-ui-preview-form #edit-controls .form-type-textfield .description { + float: right; +} + + /* @end */ /* @group Attachment buckets @@ -961,15 +970,10 @@ ul#views-display-menu-tabs li.add ul.action-list li{ #views-preview-wrapper { border: 1px solid #CCC; - border-top: 2px solid #CCC; padding-bottom: 12px; padding-top: 12px; } -#views-ui-preview-form { - margin: 12px; -} - #views-live-preview { margin: 0 12px; } diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php index a710ab4..224f491 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php @@ -22,6 +22,13 @@ public function form(array $form, array &$form_state, EntityInterface $view) { $form['#suffix'] = ''; $form['#id'] = 'views-ui-preview-form'; + $form['controls'] = array( + '#type' => 'container', + ); + $form['controls']['title'] = array( + '#markup' => '

' . t('Preview') . '

', + ); + // Reset the cache of IDs. Drupal rather aggressively prevents ID // duplication but this causes it to remember IDs that are no longer even // being used. @@ -32,21 +39,24 @@ public function form(array $form, array &$form_state, EntityInterface $view) { $form['controls']['#attributes'] = array('class' => array('clearfix')); + // Add the arguments textfield + $form['controls']['view_args'] = array( + '#type' => 'textfield', + '#title' => t('Apply contextual filters'), + '#description' => t('For multiple filters, separate values with a "/". Example: %example', array('%example' => '40/12/10')), + '#id' => 'preview-args', + ); + // Add a checkbox controlling whether or not this display auto-previews. $form['controls']['live_preview'] = array( + '#weight' => 110, '#type' => 'checkbox', '#id' => 'edit-displays-live-preview', '#title' => t('Auto preview'), '#default_value' => config('views.settings')->get('ui.always_live_preview'), ); - // Add the arguments textfield - $form['controls']['view_args'] = array( - '#type' => 'textfield', - '#title' => t('Preview with contextual filters:'), - '#description' => t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), - '#id' => 'preview-args', - ); + $form['#action'] = url('admin/structure/views/view/' . $view->get('name') .'/preview/' . $view->displayID); $args = array(); if (!empty($form_state['values']['view_args'])) { @@ -55,13 +65,12 @@ public function form(array $form, array &$form_state, EntityInterface $view) { if ($view->renderPreview) { $form['preview'] = array( - '#weight' => 110, + '#weight' => 1000, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), '#markup' => $view->renderPreview($view->displayID, $args), ); } - $form['#action'] = url('admin/structure/views/view/' . $view->get('name') .'/preview/' . $view->displayID); return $form; } @@ -77,7 +86,7 @@ protected function actions(array $form, array &$form_state) { ), 'button' => array( '#type' => 'submit', - '#value' => t('Update preview'), + '#value' => t('Preview'), '#attributes' => array('class' => array('arguments-preview')), '#submit' => array(array($this, 'submitPreview')), '#id' => 'preview-submit', @@ -93,6 +102,18 @@ protected function actions(array $form, array &$form_state) { } /** + * Overrides \Drupal\Core\Entity\EntityFormController::build(). + */ + public function build(array $form, array &$form_state, EntityInterface $entity) { + $form = parent::build($form, $form_state, $entity); + + $form['controls']['actions'] = $form['actions']; + unset($form['actions']); + return $form; + } + + + /** * Form submission handler for the Preview button. */ public function submitPreview($form, &$form_state) {