diff --git a/core/modules/views_ui/css/views_ui.admin.css b/core/modules/views_ui/css/views_ui.admin.css index c8e49a4..adf84f2 100644 --- a/core/modules/views_ui/css/views_ui.admin.css +++ b/core/modules/views_ui/css/views_ui.admin.css @@ -109,9 +109,6 @@ * to add a new section */ -.form-edit .form-actions { -} - .views-displays { clear: both; } diff --git a/core/modules/views_ui/css/views_ui.admin.theme.css b/core/modules/views_ui/css/views_ui.admin.theme.css index e88d2fa..5041c70 100644 --- a/core/modules/views_ui/css/views_ui.admin.theme.css +++ b/core/modules/views_ui/css/views_ui.admin.theme.css @@ -430,10 +430,11 @@ td.group-title { .views-displays { border: 1px solid #ccc; - padding-bottom: 36px; } -.views-display-top { +.views-display-top, +#edit-controls, +.form-edit .form-actions { background-color: #e1e2dc; border-bottom: 1px solid #ccc; padding: 8px 8px 8px; /* LTR */ @@ -443,6 +444,17 @@ td.group-title { padding: 8px 8px 8px; } +.form-edit .form-actions { + border-left: 1px solid #ccc; + border-right: 1px solid #ccc; + margin-top: 0; +} + +#edit-controls { + margin: -12px -12px 0 -12px; + padding: 12px 12px 12px; +} + .views-display-top .secondary { margin-right: 18em; } @@ -556,7 +568,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @group Attachment details */ #edit-display-settings { - margin: 12px 12px 0 12px + margin: 12px; } @@ -601,45 +613,60 @@ 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 h2.title { + display: inline; } -#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 { +.form-item-view-args { display: inline-block; } -.form-item-live-preview, -#preview-submit-wrapper { +.form-item.form-item-view-args { + max-width: 43em; +} + +.form-item.form-item-view-args label { + display: inline-block; + float: left; +} + +.form-item.form-item-view-args .description { + float: right; +} + +.form-item.form-item-live-preview { + float: right; + margin: 0; vertical-align: top; } +#preview-args { + float: right; +} + @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; } } @@ -754,10 +781,6 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @end */ -.views-edit-view { - margin-bottom: 15px; -} - /* @group Preview * * The preview controls and the preview pane @@ -1005,16 +1028,10 @@ ul#views-display-menu-tabs li.add ul.action-list li{ #views-preview-wrapper { border: 1px solid #ccc; - padding-bottom: 12px; - padding-top: 12px; } #views-ui-preview-form { - margin: 12px; -} - -#views-live-preview { - margin: 0 12px; + padding: 12px; } #views-live-preview .views-query-info { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php index 5523518..9268192 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php @@ -34,12 +34,12 @@ 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.'); - $this->drupalPost(NULL, $edit = array('view_args' => '100'), t('Update preview')); + $this->drupalPost(NULL, $edit = array('view_args' => '100'), t('Preview')); // Test that area text and exposed filters are present and rendered. $this->assertFieldByName('id', NULL, 'ID exposed filter field found.'); @@ -55,19 +55,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); @@ -146,7 +146,7 @@ public function testPreviewWithPagersUI() { */ protected function getPreviewAJAX($view_name, $panel_id, $row_count) { $this->drupalGet('admin/structure/views/view/' . $view_name . '/preview/' . $panel_id); - $result = $this->drupalPostAJAX(NULL, array(), array('op' => t('Update preview'))); + $result = $this->drupalPostAJAX(NULL, array(), array('op' => t('Preview'))); // Has AJAX callback replied with an insert command? If so, we can // assume that the page content was updated with AJAX returned data. diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/SettingsTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/SettingsTest.php index 4b18104..a456d30 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/SettingsTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/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_ui/lib/Drupal/views_ui/ViewPreviewFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php index 4ac5b8c..060fa0b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php @@ -58,6 +58,13 @@ public function form(array $form, array &$form_state) { $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. @@ -68,22 +75,23 @@ public function form(array $form, array &$form_state) { $form['controls']['#attributes'] = array('class' => array('clearfix')); + // Add the arguments textfield + $form['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', - ); - $args = array(); if (!empty($form_state['values']['view_args'])) { $args = explode('/', $form_state['values']['view_args']); @@ -91,7 +99,7 @@ public function form(array $form, array &$form_state) { if (!empty($form_state['show_preview'])) { $form['preview'] = array( - '#weight' => 110, + '#weight' => 1000, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), '#markup' => $view->renderPreview($this->displayID, $args), @@ -113,7 +121,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', @@ -129,6 +137,17 @@ protected function actions(array $form, array &$form_state) { } /** + * {@inheritdoc} + */ + 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) {