Issue #2305807 by amitgoyal, olli | jhodgdon: Fixed Clicking "Add" filter and then canceling dialog results in "You have unsaved changes.".

8.0.x
Alex Pott 2014-07-22 21:17:28 +01:00
parent afd7cf9bd4
commit 77b61671ca
3 changed files with 23 additions and 2 deletions

View File

@ -16,12 +16,31 @@ use Drupal\Core\Ajax\CommandInterface;
*/
class ShowButtonsCommand implements CommandInterface {
/**
* Whether the view has been changed.
*
* @var bool
*/
protected $changed;
/**
* Constructs a \Drupal\views\Ajax\ShowButtonsCommand object.
*
* @param bool $changed
* Whether the view has been changed.
*/
public function __construct($changed) {
$this->changed = $changed;
}
/**
* Implements \Drupal\Core\Ajax\CommandInterface::render().
*/
public function render() {
return array(
'command' => 'viewsShowButtons',
'changed' => $this->changed,
);
}

View File

@ -13,7 +13,9 @@
Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
if (response.changed) {
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
}
};
Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {

View File

@ -161,7 +161,7 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
else {
$response = new AjaxResponse();
$response->addCommand(new CloseModalDialogCommand());
$response->addCommand(new Ajax\ShowButtonsCommand());
$response->addCommand(new Ajax\ShowButtonsCommand(!empty($view->changed)));
$response->addCommand(new Ajax\TriggerPreviewCommand());
if (!empty($form_state['#page_title'])) {
$response->addCommand(new Ajax\ReplaceTitleCommand($form_state['#page_title']));