Commit 770483cd authored by Romain Courteaud's avatar Romain Courteaud Committed by Gabriel Monnerat

erp5_document_scanner: fully erase the gadget DOM when changing its state

Stop relying of CSS hide/show attributes.
Instead, only put needed elements in the DOM.
parent 0a4b94fb
...@@ -7,7 +7,7 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] { ...@@ -7,7 +7,7 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] {
text-align: center; text-align: center;
} }
.video, .photo, .camera-output { .video, .photo, .camera-output, .canvas {
max-width: 100%; max-width: 100%;
width: auto; width: auto;
max-height: 500px; max-height: 500px;
...@@ -17,11 +17,11 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] { ...@@ -17,11 +17,11 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] {
.camera-input, .camera-output { .camera-input, .camera-output {
min-height: 360px; min-height: 360px;
display: none; // display: none;
} }
.canvas { .canvas {
display: none; // display: none;
filter: brightness(1); filter: brightness(1);
} }
...@@ -58,12 +58,20 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] { ...@@ -58,12 +58,20 @@ div[data-gadget-scope="field_your_document_scanner_gadget"] {
padding: 3pt; padding: 3pt;
border: 1px solid rgba(0, 0, 0, 0.14); border: 1px solid rgba(0, 0, 0, 0.14);
border-radius: 0.325em; border-radius: 0.325em;
display: "inline-block";
margin-right: 6pt;
}
.ui-btn-icon-left:before {
margin-right: 6pt;
} }
/*
.take-picture-btn, .capture-btn, .confirm-btn, .take-picture-btn, .capture-btn, .confirm-btn,
.reset-btn, .confirm-btn, .change-camera-btn, .edit-btn { .reset-btn, .confirm-btn, .change-camera-btn, .edit-btn {
display: none; display: none;
} }
*/
.contentarea { .contentarea {
font-size: 16px; font-size: 16px;
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
<link rel="stylesheet" href="gadget_document_scanner.css"> <link rel="stylesheet" href="gadget_document_scanner.css">
<link rel="stylesheet" href="cropper.min.css"> <link rel="stylesheet" href="cropper.min.css">
<script type="text/javascript" src="cropper.min.js"></script> <script type="text/javascript" src="cropper.min.js"></script>
<script type="text/javascript" src="domsugar.js"></script>
<script type="text/javascript" src="gadget_document_scanner.js"></script> <script type="text/javascript" src="gadget_document_scanner.js"></script>
<title>Gadget Document Scanner</title> <title>Gadget Document Scanner</title>
</head> </head>
<body> <body>
<div class="camera"> <div></div>
<!--div class="camera">
<div class="camera-header"> <div class="camera-header">
<h4>Page <label class="page-number">1</label></h4> <h4>Page <label class="page-number">1</label></h4>
</div> </div>
...@@ -38,6 +40,6 @@ ...@@ -38,6 +40,6 @@
<button type="button" class="edit-btn ui-btn-icon-left ui-icon-pencil"> Edit</button> <button type="button" class="edit-btn ui-btn-icon-left ui-icon-pencil"> Edit</button>
<button type="button" class="change-camera-btn ui-icon-refresh ui-btn-icon-left"> Change Camera</button> <button type="button" class="change-camera-btn ui-icon-refresh ui-btn-icon-left"> Change Camera</button>
</div> </div>
</div> </div-->
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -7,6 +7,5 @@ selection_mapping = portal.portal_selections.getSelectionParamsFor( ...@@ -7,6 +7,5 @@ selection_mapping = portal.portal_selections.getSelectionParamsFor(
REQUEST=context.REQUEST) or {} REQUEST=context.REQUEST) or {}
canvas_data = selection_mapping.get(context.REQUEST["HTTP_USER_AGENT"]) or {} canvas_data = selection_mapping.get(context.REQUEST["HTTP_USER_AGENT"]) or {}
canvas_data["dialog_method"] = context.Base_storeDocumentFromCameraInActiveProcess.getId()
return json.dumps(canvas_data) return json.dumps(canvas_data)
portal = context.getPortalObject() portal = context.getPortalObject()
translateString = portal.Base_translateString translateString = portal.Base_translateString
active_process = context.Base_storeDocumentFromCameraInActiveProcess(
active_process_url=active_process_url,
batch_mode=True,
**kw)
# Avoid to pass huge images to the activity # Avoid to pass huge images to the activity
kw.pop("your_document_scanner_gadget", None) kw.pop("your_document_scanner_gadget", None)
context.activate().Base_uploadDocumentFromCamera( context.activate().Base_uploadDocumentFromCamera(
active_process_url=active_process.getRelativeUrl(), active_process_url=active_process_url,
**kw) **kw)
return context.Base_redirect('view', return context.Base_redirect('view',
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(\'preferred_cropped_canvas_data\', context.Base_getPreferredCropperSettingsFromSelection()),]</string> </value> <value> <string>python: [(\'dialog_method\', \'Base_storeDocumentFromCameraInActiveProcess\'), (\'preferred_cropped_canvas_data\', context.Base_getPreferredCropperSettingsFromSelection()),]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
web_page_module/rjs_gadget_document_scanner_css
web_page_module/rjs_gadget_document_scanner_html
web_page_module/rjs_gadget_document_scanner_js
\ No newline at end of file
...@@ -101,20 +101,15 @@ ...@@ -101,20 +101,15 @@
<td>//button[@class="take-picture-btn ui-btn-icon-left ui-icon-circle"]</td> <td>//button[@class="take-picture-btn ui-btn-icon-left ui-icon-circle"]</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>waitForCondition</td>
<td>selenium.browserbot.getCurrentWindow().document.querySelector("video").readyState == 4</td>
<td>30000</td>
</tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//button[@class="take-picture-btn ui-btn-icon-left ui-icon-circle"]</td> <td>//button[@class="take-picture-btn ui-btn-icon-left ui-icon-circle"]</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>waitForCondition</td> <td>waitForElementPresent</td>
<td>selenium.browserbot.getCurrentWindow().document.querySelector(".confirm-btn").style.display != "none"</td> <td>//button[@class="reset-btn ui-btn-icon-left ui-icon-times"]</td>
<td>30000</td> <td></td>
</tr> </tr>
<tr> <tr>
<td>click</td> <td>click</td>
...@@ -122,9 +117,9 @@ ...@@ -122,9 +117,9 @@
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>waitForCondition</td> <td>waitForElementPresent</td>
<td>selenium.browserbot.getCurrentWindow().document.querySelector(".confirm-btn").style.display == "none"</td> <td>//button[@class="take-picture-btn ui-btn-icon-left ui-icon-circle"]</td>
<td>30000</td> <td></td>
</tr> </tr>
<tr> <tr>
<td>click</td> <td>click</td>
...@@ -132,9 +127,9 @@ ...@@ -132,9 +127,9 @@
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>waitForCondition</td> <td>waitForElementPresent</td>
<td>selenium.browserbot.getCurrentWindow().document.querySelector(".confirm-btn").style.display != "none"</td> <td>//button[@class="confirm-btn ui-btn-icon-left ui-icon-check"]</td>
<td>3000</td> <td></td>
</tr> </tr>
<tr> <tr>
<td>click</td> <td>click</td>
...@@ -149,11 +144,6 @@ ...@@ -149,11 +144,6 @@
</div> </div>
<!--tr>
<td>waitForCondition</td>
<td>selenium.browserbot.getCurrentWindow().document.querySelector(".page-number").innerText == "2"</td>
<td>30000</td>
</tr-->
<tr> <tr>
<td>storeValue</td> <td>storeValue</td>
<td>//input[@id="field_your_active_process_url"]</td> <td>//input[@id="field_your_active_process_url"]</td>
......
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