Commit 9635c1f6 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 257f89ef
......@@ -666,10 +666,25 @@
}, {mutex: 'changestate'})
.declareMethod('checkValidity', function () {
// XXX TODO: check all blob, and ensure they are all: deleted, stored
// Any other state prevent to submit the form
// XXX if the state is required, ensure there is at least one blob stored
return false;
var gadget = this,
has_thumbnail = false,
key;
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'})
.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