Commit b5ac4a52 authored by Dries's avatar Dries
Browse files

Issue #1848836 by dawehner, damiankloip: Change Views Wizard's primary button...

Issue #1848836 by dawehner, damiankloip: Change Views Wizard's primary button to 'Save and edit' and remove 'Save & exit' button.
parent 3f4d8bc4
......@@ -45,7 +45,7 @@ public function testCommentWizard() {
// Just triggering the saving should automatically choose a proper row
// plugin.
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->assertUrl('admin/structure/views/view/' . $view['name'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
// If we update the type first we should get a selection of comment valid
......@@ -66,9 +66,10 @@ public function testCommentWizard() {
}
$expected_options = array('comment', 'fields');
$this->assertEqual($options, $expected_options);
$this->drupalPost(NULL, $view, t('Continue & edit'));
$view['name'] = strtolower($this->randomName(16));
$this->drupalPost(NULL, $view, t('Save and edit'));
$this->assertUrl('admin/structure/views/view/' . $view['name'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view['name']);
$view->initHandlers();
......
......@@ -41,7 +41,7 @@ public function randomView(array $view = array()) {
$view += $default;
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
return $default;
}
......@@ -89,7 +89,6 @@ public function testAddDisplay() {
$path_prefix = 'admin/structure/views/view/' . $view['name'] .'/edit';
$this->drupalGet($path_prefix);
$this->drupalPost(NULL, array(), t('Save'));
// Add a new display.
$this->drupalPost(NULL, array(), 'Add Page');
......@@ -109,8 +108,6 @@ public function testReorderDisplay() {
$view = $this->randomView($view);
$path_prefix = 'admin/structure/views/view/' . $view['name'] .'/edit';
$edit = array();
$this->drupalPost($path_prefix, $edit, t('Save'));
$this->clickLink(t('reorder displays'));
$this->assertTrue($this->xpath('//tr[@id="display-row-default"]'), 'Make sure the default display appears on the reorder listing');
$this->assertTrue($this->xpath('//tr[@id="display-row-page_1"]'), 'Make sure the page display appears on the reorder listing');
......
......@@ -32,7 +32,7 @@ function testOverrideDisplays() {
$view['page[path]'] = $this->randomName(16);
$view['block[create]'] = 1;
$view_path = $view['page[path]'];
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Configure its title. Since the page and block both started off with the
// same (empty) title in the views wizard, we expect the wizard to have set
......@@ -100,7 +100,7 @@ function testWizardMixedDefaultOverriddenDisplays() {
$view['page[feed_properties][path]'] = $this->randomName(16);
$view['block[create]'] = 1;
$view['block[title]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Put the block into the first sidebar region, and make sure it will not
// display on the view's page display (since we will be searching for the
......@@ -186,7 +186,7 @@ function testRevertAllDisplays() {
$view['page[path]'] = $this->randomName(16);
$view['block[create]'] = 1;
$view['block[title]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Revert the title of the block back to the default ones, but submit some
// new values to be sure that the new value is not stored.
......
......@@ -50,9 +50,7 @@ function testEditUI() {
$view['page[create]'] = TRUE;
$view['page[title]'] = $this->randomName(16);
$view['page[path]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->assertLink(t('Master') . '*');
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Configure to not always show the master display.
// If you have a view without a page or block the master display should be
......@@ -63,13 +61,12 @@ function testEditUI() {
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$view['page[create]'] = FALSE;
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->assertLink(t('Master') . '*');
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Create a view with an additional display, so master should be hidden.
$view['page[create]'] = TRUE;
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$view['name'] = strtolower($this->randomName());
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->assertNoLink(t('Master'));
......@@ -81,7 +78,9 @@ function testEditUI() {
'ui_show_display_embed' => TRUE,
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$view['name'] = strtolower($this->randomName());
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->assertFieldById('edit-displays-top-add-display-embed');
$edit = array(
......@@ -89,7 +88,7 @@ function testEditUI() {
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
views_invalidate_cache();
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->assertNoFieldById('edit-displays-top-add-display-embed');
// Configure to hide/show the sql at the preview.
......@@ -97,7 +96,9 @@ function testEditUI() {
'ui_show_sql_query_enabled' => FALSE,
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$view['name'] = strtolower($this->randomName());
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->drupalPost(NULL, array(), t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]/pre');
......@@ -107,7 +108,9 @@ function testEditUI() {
'ui_show_sql_query_enabled' => TRUE,
);
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
$view['name'] = strtolower($this->randomName());
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->drupalPost(NULL, array(), t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
......
......@@ -34,9 +34,9 @@ function testViewsWizardAndListing() {
$view1['name'] = strtolower($this->randomName(16));
$view1['description'] = $this->randomName(16);
$view1['page[create]'] = FALSE;
$this->drupalPost('admin/structure/views/add', $view1, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view1, t('Save and edit'));
$this->assertResponse(200);
$this->assertText(t('Your view was saved. You may edit it from the list below.'));
$this->drupalGet('admin/structure/views');
$this->assertText($view1['human_name']);
$this->assertText($view1['description']);
// @todo For now, clone is being left to config.module to solve.
......@@ -62,7 +62,8 @@ function testViewsWizardAndListing() {
$view2['page[path]'] = $this->randomName(16);
$view2['page[feed]'] = 1;
$view2['page[feed_properties][path]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view2, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view2, t('Save and edit'));
$this->drupalGet($view2['page[path]']);
$this->assertResponse(200);
// Since the view has a page, we expect to be automatically redirected to
......@@ -105,7 +106,8 @@ function testViewsWizardAndListing() {
$view3['page[path]'] = $this->randomName(16);
$view3['block[create]'] = 1;
$view3['block[title]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view3, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view3, t('Save and edit'));
$this->drupalGet($view3['page[path]']);
$this->assertResponse(200);
// Make sure the view only displays the node we expect.
......
......@@ -53,7 +53,8 @@ function testItemsPerPage() {
$view['block[create]'] = 1;
$view['block[title]'] = $this->randomName(16);
$view['block[items_per_page]'] = 3;
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
$this->drupalGet($view['page[path]']);
$this->assertResponse(200);
// Make sure the page display shows the nodes we expect, and that they
......
......@@ -35,8 +35,7 @@ function testMenus() {
$view['page[link]'] = 1;
$view['page[link_properties][menu_name]'] = 'main';
$view['page[link_properties][title]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
$this->assertResponse(200);
$this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
// Make sure there is a link to the view from the front page (where we
// expect the main menu to display).
......
......@@ -39,7 +39,8 @@ function testSorting() {
$view1['page[create]'] = 1;
$view1['page[title]'] = $this->randomName(16);
$view1['page[path]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view1, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view1, t('Save and edit'));
$this->drupalGet($view1['page[path]']);
$this->assertResponse(200);
// Make sure the view shows the nodes in the expected order.
......@@ -63,7 +64,8 @@ function testSorting() {
$view2['page[create]'] = 1;
$view2['page[title]'] = $this->randomName(16);
$view2['page[path]'] = $this->randomName(16);
$this->drupalPost('admin/structure/views/add', $view2, t('Save & exit'));
$this->drupalPost('admin/structure/views/add', $view2, t('Save and edit'));
$this->drupalGet($view2['page[path]']);
$this->assertResponse(200);
// Make sure the view shows the nodes in the expected order.
......
......@@ -128,11 +128,11 @@ function testTaggedWith() {
$view1['page[create]'] = 1;
$view1['page[title]'] = $this->randomName(16);
$view1['page[path]'] = $this->randomName(16);
$this->drupalPost(NULL, $view1, t('Save & exit'));
$this->assertResponse(200);
$this->drupalPost(NULL, $view1, t('Save and edit'));
// Visit the page and check that the nodes we expect are present and the
// ones we don't expect are absent.
$this->drupalGet($view1['page[path]']);
$this->assertResponse(200);
$this->assertText($node_tag1_title);
$this->assertText($node_tag1_tag2_title);
$this->assertNoText($node_no_tags_title);
......@@ -150,7 +150,7 @@ function testTaggedWith() {
$view2['page[create]'] = 1;
$view2['page[title]'] = $this->randomName(16);
$view2['page[path]'] = $this->randomName(16);
$this->drupalPost(NULL, $view2, t('Save & exit'));
$this->drupalPost(NULL, $view2, t('Save and edit'));
$this->assertResponse(200);
$this->drupalGet($view2['page[path]']);
$this->assertNoText($node_tag1_title);
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
use Drupal\views\Plugin\views\wizard\WizardException;
/**
* Form controller for the Views edit form.
......@@ -117,16 +118,7 @@ public function form(array $form, array &$form_state, EntityInterface $view) {
*/
protected function actions(array $form, array &$form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = t('Save & exit');
$actions['continueAndEdit'] = array(
'#value' => t('Continue & edit'),
'#validate' => array(
array($this, 'validate'),
),
'#submit' => array(
array($this, 'continueAndEdit'),
),
);
$actions['submit']['#value'] = t('Save and edit');
$actions['cancel'] = array(
'#value' => t('Cancel'),
......@@ -160,6 +152,7 @@ public function submit(array $form, array &$form_state) {
try {
$view = $form_state['wizard_instance']->create_view($form, $form_state);
}
// @todo Figure out whether it really makes sense to throw and catch exceptions on the wizard.
catch (WizardException $e) {
drupal_set_message($e->getMessage(), 'error');
$form_state['redirect'] = 'admin/structure/views';
......@@ -167,50 +160,7 @@ public function submit(array $form, array &$form_state) {
}
$view->save();
$form_state['redirect'] = 'admin/structure/views';
if (!empty($view->get('executable')->displayHandlers['page_1'])) {
$display = $view->get('executable')->displayHandlers['page_1'];
if ($display->hasPath()) {
$one_path = $display->getOption('path');
if (strpos($one_path, '%') === FALSE) {
$form_state['redirect'] = $one_path; // PATH TO THE VIEW IF IT HAS ONE
return;
}
}
}
drupal_set_message(t('Your view was saved. You may edit it from the list below.'));
}
/**
* Form submission handler for the 'continue' action.
*
* @param array $form
* An associative array containing the structure of the form.
* @param array $form_state
* A reference to a keyed array containing the current state of the form.
*/
public function continueAndEdit(array $form, array &$form_state) {
try {
$view = $form_state['wizard_instance']->create_view($form, $form_state);
}
catch (WizardException $e) {
drupal_set_message($e->getMessage(), 'error');
$form_state['redirect'] = 'admin/structure/views';
return;
}
// Just cache it temporarily to edit it.
views_ui_cache_set($view);
// If there is a destination query, ensure we still redirect the user to the
// edit view page, and then redirect the user to the destination.
// @todo: Revisit this when http://drupal.org/node/1668866 is in.
$destination = array();
$query = drupal_container()->get('request')->query;
if ($query->has('destination')) {
$destination = drupal_get_destination();
$query->remove('destination');
}
$form_state['redirect'] = array('admin/structure/views/view/' . $view->get('name'), array('query' => $destination));
$form_state['redirect'] = array('admin/structure/views/view/' . $view->get('name'));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment