[FIX] Fixed muliple calls to FormView#can_be_discarded()
[REM] Removed trigger_children bzr revid: fme@openerp.com-20120906132602-whcst4g0c16a6s5v
This commit is contained in:
parent
d8f925870f
commit
276e081490
|
@ -958,20 +958,6 @@ instance.web.Client = instance.web.Widget.extend({
|
||||||
has_uncommitted_changes: function() {
|
has_uncommitted_changes: function() {
|
||||||
return false;
|
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({
|
instance.web.WebClient = instance.web.Client.extend({
|
||||||
|
@ -1151,7 +1137,7 @@ instance.web.WebClient = instance.web.Client.extend({
|
||||||
},
|
},
|
||||||
has_uncommitted_changes: function() {
|
has_uncommitted_changes: function() {
|
||||||
var $e = $.Event('clear_uncommitted_changes');
|
var $e = $.Event('clear_uncommitted_changes');
|
||||||
this.trigger_children('clear_uncommitted_changes', $e);
|
instance.web.bus.trigger('clear_uncommitted_changes', $e);
|
||||||
if ($e.isDefaultPrevented()) {
|
if ($e.isDefaultPrevented()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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.on("change:actual_mode", self, self.init_pager);
|
||||||
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()) {
|
if (!this.can_be_discarded()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
return def.promise();
|
return def.promise();
|
||||||
},
|
},
|
||||||
can_be_discarded: function() {
|
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
|
* Triggers saving the form's record. Chooses between creating a new
|
||||||
|
|
Loading…
Reference in New Issue