Commit 3a58de0f authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: mark a thumbnail in red if the upload failed

parent 25e74888
......@@ -69,3 +69,7 @@ div[data-gadget-url$="gadget_document_scanner.html"] > .camera > .thumbnail-list
div[data-gadget-url$="gadget_document_scanner.html"] .show-img {
width: 35%;
}
div[data-gadget-url$="gadget_document_scanner.html"] .upload-error {
border: 3px solid red;
}
\ No newline at end of file
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1580768900.5</float>
<float>1580843720.26</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -101,7 +101,7 @@
}, function () {
// XXX TODO: Handle error case
var state_dict = {};
state_dict['blob_state_' + blob_page] = 'Error';
state_dict['blob_state_' + blob_page] = 'error';
return gadget.changeState(state_dict);
});
}
......@@ -177,6 +177,7 @@
function buildPreviousThumbnailDom(gadget) {
var i,
img_class,
len = gadget.state.page_count,
thumbnail_dom_list = [];
......@@ -193,12 +194,17 @@
for (i = 0; i < len; i += 1) {
// XXX TODO display a loader when saving
if (gadget.state['blob_state_' + i] !== 'deleted') {
if (gadget.state['blob_state_' + i] === "error") {
img_class = "show-img upload-error";
} else {
img_class = "show-img";
}
thumbnail_dom_list.push(domsugar('button', {
type: "button",
// Do not allow to show again the current image
// or do not allow to show saving image (to simplify button management)
disabled: (i === gadget.state.page) || (gadget.state['blob_state_' + i] === 'saving')
}, [domsugar("img", {"class": "show-img",
}, [domsugar("img", {"class": img_class,
'data-page': i,
src: gadget.state['blob_url_' + i]})]));
}
......@@ -362,7 +368,7 @@
],
div;
if (gadget.state['blob_state_' + gadget.state.page] === 'failed') {
if (gadget.state['blob_state_' + gadget.state.page] === 'error') {
button_list.push(
// XXX TODO improve icon
domsugar('button', {type: 'button',
......@@ -475,7 +481,7 @@
// XXX TODO use a more precise selector
return buildPreviousThumbnailDom(gadget)
.push(function (result) {
thumbnail_container = gadget.element.querySelector('ol');
thumbnail_container = gadget.element.querySelector('.thumbnail-list');
thumbnail_container.parentElement.replaceChild(
result,
thumbnail_container
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.39871.25821.10052</string> </value>
<value> <string>981.40903.42421.64529</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1580832330.08</float>
<float>1580845018.98</float>
<string>UTC</string>
</tuple>
</state>
......
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