Commit ff57eb80 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Translate all texts

To translate all texts, we added more promises and queues to make sure everything works as expected
parent 9ccc620f
...@@ -232,33 +232,36 @@ ...@@ -232,33 +232,36 @@
var i, var i,
len = gadget.state.page_count, len = gadget.state.page_count,
thumbnail_dom_list = []; thumbnail_dom_list = [];
for (i = 0; i < len; i += 1) {
// XXX TODO: show nice looking thumbnail
// from gadget.state.blob_url_i
// XXX TODO translation + right term
// XXX TODO display a loader when sending
if (gadget.state['blob_state_' + i] !== 'deleted') {
thumbnail_dom_list.push(domsugar('button', {type: 'button',
text: 'Page' + (i + 1) + ' (' + gadget.state['blob_state_' + i] + ')',
// Do not allow to show again the current image
// or do not allow to show sending image (to simplify button management)
disabled: (i === gadget.state.page) || (gadget.state['blob_state_' + i] === 'sending'),
'class': 'show-img',
'data-page': i
}));
}
}
// Always add a button to generate a new image
// XXX TODO translation + right term
thumbnail_dom_list.push(domsugar('button', {type: 'button',
text: 'New Page',
// Do not allow to show again the current image
disabled: (len === gadget.state.page - 1),
'class': 'new-btn'
}));
return domsugar('ol', thumbnail_dom_list); return gadget.getTranslationList(["Page", "New Page"])
.push(function (result_list) {
for (i = 0; i < len; i += 1) {
// XXX TODO: show nice looking thumbnail
// from gadget.state.blob_url_i
// XXX TODO translation + right term
// XXX TODO display a loader when sending
if (gadget.state['blob_state_' + i] !== 'deleted') {
thumbnail_dom_list.push(domsugar('button', {type: 'button',
text: result_list[0] + (i + 1) + ' (' + gadget.state['blob_state_' + i] + ')',
// Do not allow to show again the current image
// or do not allow to show sending image (to simplify button management)
disabled: (i === gadget.state.page) || (gadget.state['blob_state_' + i] === 'sending'),
'class': 'show-img',
'data-page': i
}));
}
}
// Always add a button to generate a new image
// XXX TODO translation + right term
thumbnail_dom_list.push(domsugar('button', {type: 'button',
text: result_list[1],
// Do not allow to show again the current image
disabled: (len === gadget.state.page - 1),
'class': 'new-btn'
}));
return domsugar('ol', thumbnail_dom_list);
});
} }
// Display the video stream from a media source // Display the video stream from a media source
...@@ -292,7 +295,8 @@ ...@@ -292,7 +295,8 @@
video.play(); video.play();
return RSVP.all([ return RSVP.all([
getVideoDeviceList(), getVideoDeviceList(),
gadget.getTranslationList(["Capture", "Change Camera"]) gadget.getTranslationList(["Capture", "Change Camera"]),
buildPreviousThumbnailDom(gadget)
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
...@@ -322,7 +326,7 @@ ...@@ -322,7 +326,7 @@
]), ]),
domsugar('div', {'class': 'camera-input'}, [video]), domsugar('div', {'class': 'camera-input'}, [video]),
domsugar('div', {'class': 'edit-picture'}, button_list), domsugar('div', {'class': 'edit-picture'}, button_list),
buildPreviousThumbnailDom(gadget) result_list[2]
]); ]);
gadget.element.replaceChild(div, gadget.element.firstElementChild); gadget.element.replaceChild(div, gadget.element.firstElementChild);
...@@ -347,7 +351,8 @@ ...@@ -347,7 +351,8 @@
gadget.detached_promise_dict.media_stream.cancel('Not needed anymore, as captured'); gadget.detached_promise_dict.media_stream.cancel('Not needed anymore, as captured');
return RSVP.all([ return RSVP.all([
gadget.getTranslationList(["Delete", "Save"]), gadget.getTranslationList(["Delete", "Save"]),
createImageBitmap(blob) createImageBitmap(blob),
buildPreviousThumbnailDom(gadget)
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
...@@ -380,7 +385,7 @@ ...@@ -380,7 +385,7 @@
text: result_list[0][1] text: result_list[0][1]
}) })
]), ]),
buildPreviousThumbnailDom(gadget) result_list[2]
]); ]);
// XXX How to change the dom only when cropper is ready? // XXX How to change the dom only when cropper is ready?
...@@ -399,13 +404,19 @@ ...@@ -399,13 +404,19 @@
} }
function renderSubmittedPicture(gadget) { function renderSubmittedPicture(gadget) {
return gadget.getTranslationList(["Delete", "Save"]) return new RSVP.Queue()
.push(function (translation_list) { .push(function () {
return RSVP.all([
gadget.getTranslationList(["Delete", "Save"]),
buildPreviousThumbnailDom(gadget)
]);
})
.push(function (result_list) {
var button_list = [ var button_list = [
// XXX TODO: improve icon // XXX TODO: improve icon
domsugar('button', {type: 'button', domsugar('button', {type: 'button',
'class': 'delete-btn ui-btn-icon-left ui-icon-times', 'class': 'delete-btn ui-btn-icon-left ui-icon-times',
text: translation_list[0] text: result_list[0][0]
}) })
], ],
div; div;
...@@ -415,7 +426,7 @@ ...@@ -415,7 +426,7 @@
// XXX TODO improve icon // XXX TODO improve icon
domsugar('button', {type: 'button', domsugar('button', {type: 'button',
'class': 'retry-btn ui-btn-icon-left ui-icon-times', 'class': 'retry-btn ui-btn-icon-left ui-icon-times',
text: translation_list[1] text: result_list[0][1]
}) })
); );
} }
...@@ -430,7 +441,7 @@ ...@@ -430,7 +441,7 @@
domsugar('img', {src: gadget.state['blob_url_' + gadget.state.page]}), domsugar('img', {src: gadget.state['blob_url_' + gadget.state.page]}),
// XXX TODO: why is the button rendering different from the other pages? // XXX TODO: why is the button rendering different from the other pages?
domsugar('div', {'class': 'edit-picture'}, button_list), domsugar('div', {'class': 'edit-picture'}, button_list),
buildPreviousThumbnailDom(gadget) result_list[1]
]); ]);
// XXX How to change the dom only when cropper is ready? // XXX How to change the dom only when cropper is ready?
...@@ -521,12 +532,14 @@ ...@@ -521,12 +532,14 @@
// Only refresh the thumbnail list // Only refresh the thumbnail list
// if display_step is not modified // if display_step is not modified
// XXX TODO use a more precise selector // XXX TODO use a more precise selector
thumbnail_container = gadget.element.querySelector('ol'); return buildPreviousThumbnailDom(gadget)
thumbnail_container.parentElement.replaceChild( .push(function (result) {
buildPreviousThumbnailDom(gadget), thumbnail_container = gadget.element.querySelector('ol');
thumbnail_container thumbnail_container.parentElement.replaceChild(
); result,
thumbnail_container
);
});
}) })
.onEvent("click", function (evt) { .onEvent("click", function (evt) {
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.30507.33878.33041</string> </value> <value> <string>981.34772.33248.46728</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1580308941.19</float> <float>1580476795.66</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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