Commit 86f56e0c authored by Aaron Wells's avatar Aaron Wells Committed by Robert Lyon

Make the form change checker reset correctly with block config modal

Bug 1559796: Because the block config modal's "X" closer button is
outside of the <form> tags of the new block, the standard form change
checker code wasn't binding the "reset" event to it.

Also, because the form change checker was written with the assumption
that each form submitted to it would have a unique ID, you wind up with
tons of forms in the formcheckers list, all with the same "instconf" id,
one for each time you open the modal.

Change-Id: I26c06c322d5c876e406a203647676cd73cda511d
parent 5eb7de72
......@@ -30,7 +30,16 @@ function FormChangeManager() {
}
this.add = function(formid) {
self.formcheckers.push(new FormChangeChecker(formid));
var alreadyfound = self.find(formid);
if (alreadyfound === null) {
newform = new FormChangeChecker(formid);
self.formcheckers.push(newform);
}
else {
alreadyfound.unbind();
alreadyfound.reset();
alreadyfound.bind();
}
}
this.checkDirtyChanges = function() {
......
......@@ -1151,6 +1151,13 @@
function hideDock() {
// Reset the form change checker
var form = formchangemanager.find('instconf');
if (form !== null) {
form.unbind();
form.reset();
}
dock.hide();
}
......
......@@ -999,6 +999,28 @@ class BehatGeneral extends BehatBase {
}
/**
* Close the config modal dialog.
*
* @When /^I close the config dialog$/
* @throws ElementNotFoundException
*/
public function i_close_config_dialog() {
// Find the config dialog close button.
$exception = new ElementNotFoundException($this->getSession(), 'dialog');
$xpath = "//div[@id='configureblock']" .
"//div[contains(concat(' ', normalize-space(@class), ' '), ' modal-dialog ')]" .
"//button[contains(concat(' ', normalize-space(@class), ' '), ' close ')]";
$closebutton = $this->find('xpath', $xpath, $exception);
if ($closebutton->isVisible()) {
$closebutton->click();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
return;
}
}
/**
* Tick the radio button
* https://github.com/Kunstmaan/KunstmaanBehatBundle/blob/master/Features/Context/SubContext/RadioButtonSubContext.php
......
......@@ -56,6 +56,17 @@ Scenario: Clicking ID's (Bug 1428456)
When I delete the block "Ulysses"
Then I should not see "Buck Mulligan"
# Checking we can add a block, make config changes, then delete the block
# without it causing 'unsaved changes' popup when navigating away
And I follow "Text"
And I press "Add"
And I wait "1" seconds
And I set the following fields to these values:
| Block title | Crime and punishment |
| Block content | <p>On an exceptionally hot evening early in July a young man came out of the garret in which he lodged in S. Place and walked slowly, as though in hesitation, towards K. bridge...</p> |
And I close the config dialog
And I scroll to the id "main-nav"
# Checking if we can change page layout
When I follow "Edit layout"
And I follow "Create custom layout"
......
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