Add force_reload on save and return reload promesse

This commit is contained in:
C?dric Krier 2015-07-17 18:01:48 +02:00
parent d0a08c5b42
commit 768a22b905
2 changed files with 10 additions and 5 deletions

View file

@ -424,7 +424,10 @@
has_changed: function() {
return !jQuery.isEmptyObject(this._changed);
},
save: function() {
save: function(force_reload) {
if (force_reload === undefined) {
force_reload = false;
}
var context = this.get_context();
var prm = jQuery.when();
var values = this.get();
@ -443,7 +446,9 @@
}
prm.done(function() {
this.cancel();
this.reload();
if (force_reload) {
return this.reload();
}
}.bind(this));
if (this.group) {
this.group.written(this.id);
@ -451,7 +456,7 @@
if (this.group.parent) {
delete this.group.parent._changed[this.group.child_name];
prm = prm.done(function() {
return this.group.parent.save();
return this.group.parent.save(force_reload);
}.bind(this));
}
return prm;

View file

@ -997,7 +997,7 @@
if (delete_) {
records.forEach(function(record) {
if (record.group.parent) {
prms.push(record.group.parent.save());
prms.push(record.group.parent.save(false));
}
if (~record.group.record_deleted.indexOf(record)) {
record.group.record_deleted.splice(
@ -1307,7 +1307,7 @@
record = selected_records[i];
jQuery.extend(context, record.get_timestamp());
}
record.save().done(function() {
record.save(false).done(function() {
record.model.execute(attributes.name,
[ids], context).then(process_action.bind(this))
.then(reload_ids);