Commit 5e9d7ce7 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Improve checkValidity method from scannerjs

Change the gadget checkValidity method to return false when:
- no thumbnail has been generated
- a thumbnail upload is in failed state
parent 7bcb0511
...@@ -666,10 +666,25 @@ ...@@ -666,10 +666,25 @@
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
// XXX TODO: check all blob, and ensure they are all: deleted, stored var gadget = this,
// Any other state prevent to submit the form has_thumbnail = false,
// XXX if the state is required, ensure there is at least one blob stored key;
return false; for (key in gadget.state) {
if (gadget.state.hasOwnProperty(key)) {
if (key.indexOf("blob_state_") !== -1 &&
!gadget.state[key].match("deleted|stored")) {
return false;
}
if (key.indexOf("blob_url_") !== -1) {
if (!gadget.state[key]) {
return false;
} else if (has_thumbnail) {
has_thumbnail = true;
}
}
}
}
return has_thumbnail;
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareAcquiredMethod("getTranslationList", "getTranslationList"); .declareAcquiredMethod("getTranslationList", "getTranslationList");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment