diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/PreviewTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/PreviewTest.php index f9aea91..83de5e7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/PreviewTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/PreviewTest.php @@ -34,7 +34,7 @@ protected function testPreviewContextual() { module_enable(array('contextual')); $this->drupalGet('admin/structure/views/view/test_preview/edit'); $this->assertResponse(200); - $this->drupalPost(NULL, $edit = array(), t('Update preview')); + $this->drupalPost(NULL, $edit = array(), t('Preview')); $elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(':ul-class' => 'contextual-links', ':li-class' => 'filter-add')); $this->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.'); @@ -47,19 +47,19 @@ function testPreviewUI() { $this->drupalGet('admin/structure/views/view/test_preview/edit'); $this->assertResponse(200); - $this->drupalPost(NULL, $edit = array(), t('Update preview')); + $this->drupalPost(NULL, $edit = array(), t('Preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 5); // Filter just the first result. - $this->drupalPost(NULL, $edit = array('view_args' => '1'), t('Update preview')); + $this->drupalPost(NULL, $edit = array('view_args' => '1'), t('Preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 1); // Filter for no results. - $this->drupalPost(NULL, $edit = array('view_args' => '100'), t('Update preview')); + $this->drupalPost(NULL, $edit = array('view_args' => '100'), t('Preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 0); diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php index 28978d6..ef4b2e9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php @@ -100,7 +100,7 @@ function testEditUI() { $view['id'] = strtolower($this->randomName()); $this->drupalPost('admin/structure/views/add', $view, t('Save and edit')); - $this->drupalPost(NULL, array(), t('Update preview')); + $this->drupalPost(NULL, array(), t('Preview')); $xpath = $this->xpath('//div[@class="views-query-info"]/pre'); $this->assertEqual(count($xpath), 0, 'The views sql is hidden.'); @@ -112,7 +112,7 @@ function testEditUI() { $view['id'] = strtolower($this->randomName()); $this->drupalPost('admin/structure/views/add', $view, t('Save and edit')); - $this->drupalPost(NULL, array(), t('Update preview')); + $this->drupalPost(NULL, array(), t('Preview')); $xpath = $this->xpath('//div[@class="views-query-info"]//pre'); $this->assertEqual(count($xpath), 1, 'The views sql is shown.'); $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.'); 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 8248f34..d7d0c0c 100644 --- a/core/modules/views/views_ui/css/views-admin.theme.css +++ b/core/modules/views/views_ui/css/views-admin.theme.css @@ -573,45 +573,48 @@ ul#views-display-menu-tabs li.add ul.action-list li{ * The auto-preview checkbox line. */ -#views-ui-preview-form .form-type-checkbox { - margin-top: 2px; - margin-left: 2px; -} - -#views-ui-preview-form .form-type-textfield, #views-ui-preview-form .form-actions { - margin-top: 5px; +#views-ui-preview-form #edit-controls div { + float: left; } -#views-ui-preview-form .arguments-preview { +#views-ui-preview-form #edit-controls .arguments-preview { font-size: 1em; + margin: 0 0.75em; } -#views-ui-preview-form .arguments-preview, -#views-ui-preview-form .form-type-textfield { - margin-left: 14px; -} - -#views-ui-preview-form .form-type-textfield label { +#views-ui-preview-form #edit-controls .form-type-textfield label, +#views-ui-preview-form #edit-controls .form-type-textfield input { display: inline-block; float: left; +} + +#views-ui-preview-form #edit-controls .form-type-textfield label { font-weight: normal; height: 6ex; margin-right: 0.75em; } +#views-ui-preview-form #edit-controls .form-type-textfield input { + max-width: 380px; +} + .form-item-live-preview, .form-item-view-args, #preview-submit-wrapper { display: inline-block; } +.form-item-view-args { + max-width: 42em; +} + .form-item-live-preview, #preview-submit-wrapper { vertical-align: top; } @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; } } @@ -967,17 +970,9 @@ ul#views-display-menu-tabs li.add ul.action-list li{ #views-preview-wrapper { border: 1px solid #ccc; - padding-bottom: 12px; - padding-top: 12px; + padding: 12px; } -#views-ui-preview-form { - margin: 12px; -} - -#views-live-preview { - margin: 0 12px; -} #views-live-preview .views-query-info { overflow: auto; 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 f6798fe..b84f09e 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. @@ -43,11 +50,20 @@ public function form(array $form, array &$form_state, EntityInterface $view) { // 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')), + '#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'), + ); + $args = array(); if (!empty($form_state['values']['view_args'])) { $args = explode('/', $form_state['values']['view_args']); @@ -55,7 +71,7 @@ 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), @@ -77,7 +93,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 +109,17 @@ 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) {