changeset 8ba9c7020a8b in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset;node=8ba9c7020a8b
description:
Ensure to execute display before showing the info message
The display must be run before the callback linked to the promise of
save_current. And save_current must return a promise with the same
state as
the save promise.
Also save should not reject with the exception to avoid jQuery warning.
issue8338
review265421002
(grafted from c9c4f1426d346e3fa41cac4bf0a7101b2d6c9706)
diffstat:
src/model.js | 2 +-
src/screen.js | 29 +++++++++++++++++------------
2 files changed, 18 insertions(+), 13 deletions(-)
diffs (60 lines):
diff -r 8290b7b36a69 -r 8ba9c7020a8b src/model.js
--- a/src/model.js Wed May 01 21:58:01 2019 +0200
+++ b/src/model.js Mon May 13 22:38:11 2019 +0200
@@ -510,7 +510,7 @@
this.id = this.model.execute(
'create', [[values]], context, false)[0];
} catch (e) {
- return jQuery.Deferred().reject(e);
+ return jQuery.Deferred().reject();
}
} else {
if (!jQuery.isEmptyObject(values)) {
diff -r 8290b7b36a69 -r 8ba9c7020a8b src/screen.js
--- a/src/screen.js Wed May 01 21:58:01 2019 +0200
+++ b/src/screen.js Mon May 13 22:38:11 2019 +0200
@@ -1342,19 +1342,24 @@
prm = this.group.save().then(function() {
return this.current_record;
}.bind(this));
+ } else if (current_record.validate(fields, null, null, true)) {
+ prm = current_record.save().then(function() {
+ return current_record;
+ });
} else {
- current_record.validate(fields).then(function(validate) {
- if (validate) {
- current_record.save().then(function() {
- prm.resolve(current_record);
- }, prm.reject);
- } else {
- this.current_view.display().done(
- this.set_cursor.bind(this));
- prm.reject();
- }
- }.bind(this));
+ return this.current_view.display().then(function() {
+ this.set_cursor();
+ return jQuery.Deferred().reject();
+ });
}
+ var display = function() {
+ // Return the original promise to keep succeed/rejected state
+ return this.display().then(function() {
+ return prm;
+ }, function() {
+ return prm;
+ });
+ }.bind(this);
return prm.then(function(current_record) {
if (path && current_record && current_record.id) {
path.splice(-1, 1,
@@ -1363,7 +1368,7 @@
return this.group.get_by_path(path).then(function(record) {
this.set_current_record(record);
}.bind(this));
- }.bind(this)).always(this.display.bind(this));
+ }.bind(this)).then(display, display);
},
set_cursor: function(new_, reset_view) {
if (!this.current_view) {