Commit d1313878 authored by Jérome Perrin's avatar Jérome Perrin

xhtml_style: set the "changed" flag when gadget notifies changes

This way the "you have unsaved changes" pops up also when navigating
away after changing gadget content.
parent 32cead86
...@@ -61,6 +61,12 @@ ...@@ -61,6 +61,12 @@
</tr> </tr>
<!-- the flag used in erp5.js to warn unsaved changes is initially not set -->
<tr>
<td>assertEval</td>
<td>selenium.browserbot.currentWindow.changed</td>
<td>false</td>
</tr>
<tr> <tr>
<td>type</td> <td>type</td>
...@@ -68,6 +74,12 @@ ...@@ -68,6 +74,12 @@
<td>123</td> <td>123</td>
</tr> </tr>
<!-- the flag used in erp5.js to warn unsaved changes is set after gadget is changed -->
<tr>
<td>waitForEval</td>
<td>selenium.browserbot.currentWindow.changed</td>
<td>true</td>
</tr>
<tr> <tr>
......
...@@ -4,13 +4,16 @@ ...@@ -4,13 +4,16 @@
"use strict"; "use strict";
rJS(window) rJS(window)
.declareAcquiredMethod('notifyChange', 'notifyChange')
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
this.element.firstChild.value = options.value || ""; this.element.firstChild.value = options.value || "";
this.element.firstChild.title = options.key; this.element.firstChild.title = options.key;
this.element.firstChild.setAttribute('data-name', this.element.firstChild.setAttribute('data-name',
options.key || ""); options.key || "");
}) })
.onEvent('change', function () {
return this.notifyChange();
})
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var input = this.element.firstChild, var input = this.element.firstChild,
form_gadget = this, form_gadget = this,
......
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifyChange', .allowPublicAcquisition('notifyChange',
function () { function () {
// This flag is used for erp5.js's onBeforeUnload warning for unsaved changes.
window.changed = true;
return; return;
}) })
......
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