Skip to content

Commit

Permalink
[REF] changed the way to display the document data to prevent the UI …
Browse files Browse the repository at this point in the history
…to be blocked when there is an error message
  • Loading branch information
benwillig committed May 11, 2023
1 parent 3b83918 commit 8b739d5
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions cmis_web/static/src/js/form_widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,14 @@ odoo.define('cmis_web.form_widgets', function (require) {
return new Promise(function(resolve) {
self.cmisSessionReady.then(function() {
if (self.value) {
self._get_document(self.value).then(function (document) {
self.document = self.wrap_cmis_object(document);
resolve(document);
self._get_document(self.value).catch(function(error) {
self.value = "__error__";
resolve({});
}).then(function (document) {
if (!!document) {
self.document = self.wrap_cmis_object(document);
resolve(document);
}
});
} else {
resolve({});
Expand All @@ -1037,10 +1042,12 @@ odoo.define('cmis_web.form_widgets', function (require) {

_render: function () {
this._super.apply(this, arguments);
if (this.value && this.value !== "empty") {
this._renderCmisDocument(this.document);
} else {
if (this.value === "empty") {
this._renderNoDocument();
} else if (this.value === "__error__") {
this._renderGetError();
} else if (this.document) {
this._renderCmisDocument(this.document);
}
},

Expand All @@ -1065,12 +1072,19 @@ odoo.define('cmis_web.form_widgets', function (require) {
this.register_no_document();
},

_renderGetError: function() {
this.$el.empty();
this.$el.append($('<p/>').text(_t("Unable to retrieve the document. The resource might have been deleted in the CMIS.")))
},

_get_document: function (objectId) {
var self = this;
return new Promise(function (resolve) {
return new Promise(function (resolve, reject) {
self.cmis_session.getObject(objectId, "latest", DEFAULT_CMIS_OPTIONS)
.ok(function (document) {
resolve(document);
}).notOk(function (error) {
reject(error);
});
});
},
Expand Down

0 comments on commit 8b739d5

Please sign in to comment.