Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
erp5
Commits
071d2901
Commit
071d2901
authored
Apr 06, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: store the cropper data in session storage
Allow user to reuse the same cropper area in a session.
parent
ef13c749
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
+53
-16
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+51
-14
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
...em/web_page_module/scanner_gadget_document_scanner_js.xml
+2
-2
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
071d2901
...
@@ -7,6 +7,26 @@
...
@@ -7,6 +7,26 @@
FileReader
,
DataView
,
URL
,
fx
)
{
FileReader
,
DataView
,
URL
,
fx
)
{
"
use strict
"
;
"
use strict
"
;
var
CROPPER_DATA_JIO_KEY
=
'
cropperjs_data_
'
;
function
getDevicePreferredCropperData
(
gadget
)
{
return
gadget
.
session_storage_jio
.
get
(
CROPPER_DATA_JIO_KEY
+
gadget
.
state
.
device_id
)
.
push
(
undefined
,
function
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
return
null
;
}
throw
error
;
});
}
function
putDevicePreferredCropperData
(
gadget
,
data
)
{
return
gadget
.
session_storage_jio
.
put
(
CROPPER_DATA_JIO_KEY
+
gadget
.
state
.
device_id
,
data
);
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// Browser API to promise
// Browser API to promise
//////////////////////////////////////////////////
//////////////////////////////////////////////////
...
@@ -201,7 +221,7 @@
...
@@ -201,7 +221,7 @@
checkOrientation
:
false
,
checkOrientation
:
false
,
zoomable
:
false
,
zoomable
:
false
,
movable
:
false
,
movable
:
false
,
data
:
data
,
data
:
data
||
{}
,
ready
:
function
()
{
ready
:
function
()
{
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
...
@@ -434,7 +454,8 @@
...
@@ -434,7 +454,8 @@
return
RSVP
.
all
([
return
RSVP
.
all
([
getVideoDeviceList
(),
getVideoDeviceList
(),
gadget
.
getTranslationList
([
"
Capture
"
,
"
Change Camera
"
,
"
Page
"
,
"
1-click Capture
"
]),
gadget
.
getTranslationList
([
"
Capture
"
,
"
Change Camera
"
,
"
Page
"
,
"
1-click Capture
"
]),
buildPreviousThumbnailDom
(
gadget
)
buildPreviousThumbnailDom
(
gadget
),
getDevicePreferredCropperData
(
gadget
)
]);
]);
})
})
.
push
(
function
(
result_list
)
{
.
push
(
function
(
result_list
)
{
...
@@ -455,12 +476,14 @@
...
@@ -455,12 +476,14 @@
text
:
result_list
[
1
][
0
]
text
:
result_list
[
1
][
0
]
}));
}));
button_list
.
push
(
if
(
result_list
[
3
]
!==
null
)
{
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
button_list
.
push
(
'
class
'
:
'
auto-crop-btn ui-icon-fast-forward ui-btn-icon-left
'
,
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
text
:
result_list
[
1
][
3
]
'
class
'
:
'
auto-crop-btn ui-icon-fast-forward ui-btn-icon-left
'
,
})
text
:
result_list
[
1
][
3
]
);
})
);
}
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
buildPageTitle
(
gadget
,
result_list
[
1
][
2
]),
buildPageTitle
(
gadget
,
result_list
[
1
][
2
]),
...
@@ -646,7 +669,8 @@
...
@@ -646,7 +669,8 @@
return
RSVP
.
all
([
return
RSVP
.
all
([
gadget
.
getTranslationList
([
"
Delete
"
,
"
Save
"
,
"
Page
"
]),
gadget
.
getTranslationList
([
"
Delete
"
,
"
Save
"
,
"
Page
"
]),
createLoadedImgElement
(
blob_url
),
createLoadedImgElement
(
blob_url
),
buildPreviousThumbnailDom
(
gadget
)
buildPreviousThumbnailDom
(
gadget
),
getDevicePreferredCropperData
(
gadget
)
]);
]);
})
})
.
push
(
function
(
result_list
)
{
.
push
(
function
(
result_list
)
{
...
@@ -691,7 +715,7 @@
...
@@ -691,7 +715,7 @@
btn
.
classList
.
remove
(
"
ui-icon-spinner
"
);
btn
.
classList
.
remove
(
"
ui-icon-spinner
"
);
addDetachedPromise
(
gadget
,
'
cropper
'
,
addDetachedPromise
(
gadget
,
'
cropper
'
,
handleCropper
(
img
,
handleCropper
(
img
,
gadget
.
state
.
preferred_cropped_canvas_data
,
result_list
[
3
]
,
defer
.
resolve
));
defer
.
resolve
));
return
defer
.
promise
;
return
defer
.
promise
;
})
})
...
@@ -750,7 +774,6 @@
...
@@ -750,7 +774,6 @@
var
canvas
=
gadget
.
cropper
.
getCroppedCanvas
(),
var
canvas
=
gadget
.
cropper
.
getCroppedCanvas
(),
state_dict
;
state_dict
;
state_dict
=
{
state_dict
=
{
preferred_cropped_canvas_data
:
gadget
.
cropper
.
getData
(),
display_step
:
'
display_video
'
,
display_step
:
'
display_video
'
,
display_index
:
null
,
display_index
:
null
,
page_count
:
gadget
.
state
.
page_count
+
1
page_count
:
gadget
.
state
.
page_count
+
1
...
@@ -761,7 +784,11 @@
...
@@ -761,7 +784,11 @@
state_dict
[
'
blob_state_
'
+
gadget
.
state
.
page_count
]
=
'
saving
'
;
state_dict
[
'
blob_state_
'
+
gadget
.
state
.
page_count
]
=
'
saving
'
;
state_dict
[
'
blob_uuid_
'
+
gadget
.
state
.
page_count
]
=
null
;
state_dict
[
'
blob_uuid_
'
+
gadget
.
state
.
page_count
]
=
null
;
return
gadget
.
changeState
(
state_dict
)
// Store the cropper data area
return
putDevicePreferredCropperData
(
gadget
,
gadget
.
cropper
.
getData
())
.
push
(
function
()
{
return
gadget
.
changeState
(
state_dict
);
})
.
push
(
function
()
{
.
push
(
function
()
{
// XXX Ensure that you have the active process relative url
// XXX Ensure that you have the active process relative url
addDetachedPromise
(
gadget
,
'
ajax_
'
+
(
gadget
.
state
.
page_count
-
1
),
addDetachedPromise
(
gadget
,
'
ajax_
'
+
(
gadget
.
state
.
page_count
-
1
),
...
@@ -777,6 +804,18 @@
...
@@ -777,6 +804,18 @@
rJS
(
window
)
rJS
(
window
)
.
ready
(
function
()
{
.
ready
(
function
()
{
this
.
detached_promise_dict
=
{};
this
.
detached_promise_dict
=
{};
// use to store temporary cropper data area
this
.
session_storage_jio
=
jIO
.
createJIO
({
type
:
"
document
"
,
document_id
:
"
/
"
,
sub_storage
:
{
type
:
"
zip
"
,
sub_storage
:
{
type
:
"
local
"
,
sessiononly
:
true
}
}
});
})
})
.
declareJob
(
'
raise
'
,
function
(
error
)
{
.
declareJob
(
'
raise
'
,
function
(
error
)
{
throw
error
;
throw
error
;
...
@@ -819,7 +858,6 @@
...
@@ -819,7 +858,6 @@
active_process
:
default_value
.
active_process
,
active_process
:
default_value
.
active_process
,
image_list
:
default_value
.
image_list
,
image_list
:
default_value
.
image_list
,
camera_list
:
camera_list
,
camera_list
:
camera_list
,
preferred_cropped_canvas_data
:
{},
preferred_image_settings_data
:
JSON
.
parse
(
options
.
preferred_image_settings_data
),
preferred_image_settings_data
:
JSON
.
parse
(
options
.
preferred_image_settings_data
),
device_id
:
device_id
,
device_id
:
device_id
,
key
:
options
.
key
,
key
:
options
.
key
,
...
@@ -959,7 +997,6 @@
...
@@ -959,7 +997,6 @@
}
}
return
gadget
.
changeState
({
return
gadget
.
changeState
({
display_step
:
'
display_video
'
,
display_step
:
'
display_video
'
,
preferred_cropped_canvas_data
:
{},
camera_list
:
camera_list
,
camera_list
:
camera_list
,
device_id
:
device_id
device_id
:
device_id
});
});
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
071d2901
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
983.1
655.22186.31027
</string>
</value>
<value>
<string>
983.1
729.31351.955
</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>
158618
1306.42
</float>
<float>
158618
5444.24
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment