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
64b7ff09
Commit
64b7ff09
authored
Apr 02, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: add an auto crop button
parent
7d4a1ca8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
50 deletions
+83
-50
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_css.css
...m/web_page_module/scanner_gadget_document_scanner_css.css
+2
-1
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_css.xml
...m/web_page_module/scanner_gadget_document_scanner_css.xml
+2
-2
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.html
...web_page_module/scanner_gadget_document_scanner_html.html
+1
-0
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.xml
.../web_page_module/scanner_gadget_document_scanner_html.xml
+2
-2
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+73
-42
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
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/documentscannercss.less.txt
...l_skins/erp5_document_scanner/documentscannercss.less.txt
+1
-1
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_css.css
View file @
64b7ff09
...
...
@@ -50,7 +50,8 @@ div[data-gadget-url$="gadget_document_scanner.html"] .capture-btn,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.delete-btn
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.retry-btn
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.change-camera-btn
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.confirm-btn
{
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.confirm-btn
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.auto-crop-btn
{
color
:
#212529
;
padding
:
3pt
;
border
:
1px
solid
rgba
(
0
,
0
,
0
,
0.14
);
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_css.xml
View file @
64b7ff09
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.6
0019.31334.2372
</string>
</value>
<value>
<string>
982.6
1113.55569.43315
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1585
753245.18
</float>
<float>
1585
816780.79
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.html
View file @
64b7ff09
...
...
@@ -6,6 +6,7 @@
data-i18n=Delete
data-i18n=Save
data-i18n=Capture
data-i18n=1-click Capture
data-i18n=Saving
data-i18n=Error
data-i18n=Page
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_html.xml
View file @
64b7ff09
...
...
@@ -242,7 +242,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.6
0143.18861.24029
</string>
</value>
<value>
<string>
982.6
2512.65384.20480
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
1585
757797.
7
</float>
<float>
1585
905603.0
7
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
64b7ff09
...
...
@@ -403,7 +403,7 @@
video
.
play
();
return
RSVP
.
all
([
getVideoDeviceList
(),
gadget
.
getTranslationList
([
"
Capture
"
,
"
Change Camera
"
,
"
Page
"
]),
gadget
.
getTranslationList
([
"
Capture
"
,
"
Change Camera
"
,
"
Page
"
,
"
1-click Capture
"
]),
buildPreviousThumbnailDom
(
gadget
)
]);
})
...
...
@@ -425,6 +425,12 @@
text
:
result_list
[
1
][
0
]
}));
button_list
.
push
(
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
'
class
'
:
'
auto-crop-btn ui-icon-fast-forward ui-btn-icon-left
'
,
text
:
result_list
[
1
][
3
]
}));
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera-header
'
},
[
domsugar
(
'
h4
'
,
[
...
...
@@ -576,7 +582,7 @@
}
// Capture the media stream
function
captureAndRenderPicture
(
gadget
)
{
function
captureAndRenderPicture
(
gadget
,
is_auto_crop
)
{
var
settings
=
gadget
.
state
.
preferred_image_settings_data
,
btn
=
gadget
.
element
.
querySelector
(
"
.take-picture-btn
"
),
image_capture
=
new
window
.
ImageCapture
(
...
...
@@ -621,7 +627,25 @@
var
img
=
result_list
[
1
],
div
,
defer
=
RSVP
.
defer
();
defer
=
RSVP
.
defer
(),
edit_picture_element
;
if
(
!
is_auto_crop
)
{
edit_picture_element
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
edit-picture
'
},
[
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
'
class
'
:
'
reset-btn ui-btn-icon-left ui-icon-times
'
,
text
:
result_list
[
0
][
0
]
}),
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
'
class
'
:
'
confirm-btn ui-btn-icon-left ui-icon-check
'
,
text
:
result_list
[
0
][
1
]
})
]);
}
else
{
// Keep the previous disabled button list
// in order to reduce the flickering
edit_picture_element
=
gadget
.
element
.
querySelector
(
'
.edit-picture
'
);
}
// Prepare the cropper canvas
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
...
...
@@ -635,16 +659,7 @@
// DON'T remove img from a div img-container.
// DON'T replace img by canvas.
domsugar
(
"
div
"
,
{
"
class
"
:
"
img-container
"
},
[
img
]),
domsugar
(
'
div
'
,
{
'
class
'
:
'
edit-picture
'
},
[
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
'
class
'
:
'
reset-btn ui-btn-icon-left ui-icon-times
'
,
text
:
result_list
[
0
][
0
]
}),
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
'
class
'
:
'
confirm-btn ui-btn-icon-left ui-icon-check
'
,
text
:
result_list
[
0
][
1
]
})
]),
edit_picture_element
,
result_list
[
2
]
]);
...
...
@@ -700,7 +715,9 @@
domsugar
(
'
label
'
,
{
'
class
'
:
'
page-number
'
,
text
:
gadget
.
state
.
page
+
1
})
])
]),
domsugar
(
'
img
'
,
{
src
:
gadget
.
state
[
'
blob_url_
'
+
gadget
.
state
.
page
]}),
domsugar
(
'
div
'
,
{
'
class
'
:
'
img-container
'
},
[
domsugar
(
'
img
'
,
{
src
:
gadget
.
state
[
'
blob_url_
'
+
gadget
.
state
.
page
]})
]),
// XXX TODO: why is the button rendering different from the other pages?
domsugar
(
'
div
'
,
{
'
class
'
:
'
edit-picture
'
},
button_list
),
result_list
[
1
]
...
...
@@ -713,6 +730,31 @@
});
}
function
cropPicture
(
gadget
)
{
var
canvas
=
gadget
.
cropper
.
getCroppedCanvas
(),
state_dict
;
state_dict
=
{
preferred_cropped_canvas_data
:
gadget
.
cropper
.
getData
(),
display_step
:
'
display_video
'
,
page
:
gadget
.
state
.
page
+
1
,
page_count
:
gadget
.
state
.
page_count
+
1
};
// Keep image date, as user may need to display it again
state_dict
[
'
blob_canvas_
'
+
gadget
.
state
.
page_count
]
=
canvas
;
// state_dict['blob_url_' + gadget.state.page_count] = data_url;
state_dict
[
'
blob_state_
'
+
gadget
.
state
.
page_count
]
=
'
saving
'
;
state_dict
[
'
blob_uuid_
'
+
gadget
.
state
.
page_count
]
=
null
;
return
gadget
.
changeState
(
state_dict
)
.
push
(
function
()
{
// XXX Ensure that you have the active process relative url
addDetachedPromise
(
gadget
,
'
ajax_
'
+
(
gadget
.
state
.
page_count
-
1
),
handleAsyncStore
(
gadget
,
gadget
.
state
.
page_count
-
1
));
gadget
.
detached_promise_dict
.
cropper
.
cancel
(
'
Not needed anymore, as cropped
'
);
});
}
//////////////////////////////////////////////////
// Gadget API
//////////////////////////////////////////////////
...
...
@@ -791,6 +833,9 @@
if
(
display_step
===
'
crop_picture
'
)
{
return
captureAndRenderPicture
(
gadget
);
}
if
(
display_step
===
'
auto_crop_picture
'
)
{
return
captureAndRenderPicture
(
gadget
,
true
);
}
if
(
display_step
===
'
show_picture
'
)
{
return
renderSubmittedPicture
(
gadget
);
}
...
...
@@ -835,12 +880,6 @@
});
}
if
(
evt
.
target
.
className
.
indexOf
(
"
take-picture-btn
"
)
!==
-
1
)
{
return
gadget
.
changeState
({
display_step
:
'
crop_picture
'
});
}
if
(
evt
.
target
.
className
.
indexOf
(
"
reset-btn
"
)
!==
-
1
)
{
return
gadget
.
changeState
({
display_step
:
'
display_video
'
...
...
@@ -873,30 +912,22 @@
return
gadget
.
changeState
(
state_dict
);
}
if
(
evt
.
target
.
className
.
indexOf
(
"
take-picture-btn
"
)
!==
-
1
)
{
return
gadget
.
changeState
({
display_step
:
'
crop_picture
'
});
}
if
(
evt
.
target
.
className
.
indexOf
(
"
confirm-btn
"
)
!==
-
1
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
canvas
=
gadget
.
cropper
.
getCroppedCanvas
();
state_dict
=
{
preferred_cropped_canvas_data
:
gadget
.
cropper
.
getData
(),
display_step
:
'
display_video
'
,
page
:
gadget
.
state
.
page
+
1
,
page_count
:
gadget
.
state
.
page_count
+
1
};
// Keep image date, as user may need to display it again
state_dict
[
'
blob_canvas_
'
+
gadget
.
state
.
page_count
]
=
canvas
;
// state_dict['blob_url_' + gadget.state.page_count] = data_url;
state_dict
[
'
blob_state_
'
+
gadget
.
state
.
page_count
]
=
'
saving
'
;
state_dict
[
'
blob_uuid_
'
+
gadget
.
state
.
page_count
]
=
null
;
return
gadget
.
changeState
(
state_dict
);
})
.
push
(
function
()
{
// XXX Ensure that you have the active process relative url
addDetachedPromise
(
gadget
,
'
ajax_
'
+
(
gadget
.
state
.
page_count
-
1
),
handleAsyncStore
(
gadget
,
gadget
.
state
.
page_count
-
1
));
return
cropPicture
(
gadget
);
}
gadget
.
detached_promise_dict
.
cropper
.
cancel
(
'
Not needed anymore, as cropped
'
);
if
(
evt
.
target
.
className
.
indexOf
(
"
auto-crop-btn
"
)
!==
-
1
)
{
return
gadget
.
changeState
({
display_step
:
'
auto_crop_picture
'
})
.
push
(
function
()
{
return
cropPicture
(
gadget
);
});
}
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
64b7ff09
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.
59651.45192.29798
</string>
</value>
<value>
<string>
982.
61614.28913.46660
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1585
728228.5
</float>
<float>
1585
846471.58
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/documentscannercss.less.txt
View file @
64b7ff09
...
...
@@ -44,7 +44,7 @@ div[data-gadget-url$="gadget_document_scanner.html"] {
}
.reset-btn, .confirm-btn, .edit-btn, .take-picture-btn, .capture-btn,
.delete-btn, .retry-btn, .change-camera-btn, .confirm-btn {
.delete-btn, .retry-btn, .change-camera-btn, .confirm-btn
, .auto-crop-btn
{
color: #212529;
padding: 3pt;
border: 1px solid rgba(0, 0, 0, 0.14);
...
...
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