summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-09-06 15:26:02 +0200
committerFabien Meghazi <fme@openerp.com>2012-09-06 15:26:02 +0200
commit276e081490430a62872febef6529fff6bf8edeea (patch)
tree75751a33744d1988d26dc2ff58f2326349dd7f5c /addons/web/static/src
parentd8f925870faf176c36a859b0c5ef8dae3e9c3861 (diff)
[FIX] Fixed muliple calls to FormView#can_be_discarded()
[REM] Removed trigger_children bzr revid: fme@openerp.com-20120906132602-whcst4g0c16a6s5v
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js16
-rw-r--r--addons/web/static/src/js/view_form.js10
2 files changed, 9 insertions, 17 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 0c32fdffff9..3114aaf315f 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -958,20 +958,6 @@ instance.web.Client = instance.web.Widget.extend({
has_uncommitted_changes: function() {
return false;
},
- trigger_children: function(events) {
- // TODO: In the future, if we have more valid use cases in other objects, let's
- // put this back in the EventDispatcherMixin as an option of trigger()
- var children = this.getChildren();
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- if (child.__eventDispatcherMixin) {
- child.__edispatcherEvents.trigger.apply(child.__edispatcherEvents, arguments);
- instance.webclient // Yuck!
- .trigger_children.apply(child, arguments);
- }
- }
- return this;
- },
});
instance.web.WebClient = instance.web.Client.extend({
@@ -1151,7 +1137,7 @@ instance.web.WebClient = instance.web.Client.extend({
},
has_uncommitted_changes: function() {
var $e = $.Event('clear_uncommitted_changes');
- this.trigger_children('clear_uncommitted_changes', $e);
+ instance.web.bus.trigger('clear_uncommitted_changes', $e);
if ($e.isDefaultPrevented()) {
return true;
} else {
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index bf2bfc4c9fe..744aa8d000d 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -92,7 +92,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
self.on("change:actual_mode", self, self.init_pager);
self.init_pager();
});
- this.on('clear_uncommitted_changes', this, function(e) {
+ instance.web.bus.on('clear_uncommitted_changes', this, function(e) {
if (!this.can_be_discarded()) {
e.preventDefault();
}
@@ -753,7 +753,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return def.promise();
},
can_be_discarded: function() {
- return !this.$el.is('.oe_form_dirty') || confirm(_t("Warning, the record has been modified, your changes will be discarded.\n\nAre you sure you want to leave this page ?"));
+ if (this.$el.is('.oe_form_dirty')) {
+ if (!confirm(_t("Warning, the record has been modified, your changes will be discarded.\n\nAre you sure you want to leave this page ?"))) {
+ return false;
+ }
+ this.$el.removeClass('oe_form_dirty');
+ }
+ return true;
},
/**
* Triggers saving the form's record. Chooses between creating a new