erp5_document_scanner: Speed up the usability of scannerjs
- Stop relying of CSS hide/show attributes. Instead, only put needed elements in the DOM. - Upload images asynchronously to improve the usability Add a tales expression as default field value. The default value is a JSON containing 2 keys: * the relative_url of an active process * the list of active process image content to aggregate By default, when the field is rendered for the first time, this tales expression is evaluated and a new active process is created at that point. So, default json is like: {active_process: 'portal_activities/1234', image_list: []} * store the active_process relative_url in the gadget state in the render method * store the image_list in the gadget state in the render_method * change getContent method to send a json build from the active_process and image_list state - Change the gadget checkValidity method to return false when: * no thumbnail has been generated * a thumbnail upload is in failed state - POST image cropped to backend * change the `extra renderjs` parameters list to pass a Python script to call when a new image is cropped. * change the gadget to use jio.util.ajax with the script full url (provided by the server) - Translate and Update i18n info - Ajax must return a active process image content UUID - Add spinner in button to show that we are saving it in background - Add reference to Active Process. With this, we can search easily active processes used by document scanner and remove them - Add an alarm which will delete outdated (>5 days old) active_process created by the dialog. - Improve code to switch cameras in mobiles with more than 2 cameras - Display intermediate image after get orientation and instantiate Cropper
import json | |||
active_process = context.getPortalObject().portal_activities.newActiveProcess( | |||
|
|||
reference=context.Base_getDocumentScannerDefaultReference()) | |||
return json.dumps({ | |||
"active_process": active_process.getRelativeUrl(), | |||
"image_list": [] | |||
}) |