thecore_dataentry_commons 1.4.7 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/higher_level/_barcode_simple_scan.html.erb +30 -43
- data/app/views/rails_admin/main/_dataentry_commons_data_action.html.erb +54 -0
- data/app/views/rails_admin/main/_dataentry_commons_data_container.html.erb +1 -6
- data/app/views/rails_admin/main/_dataentry_commons_input_group_logic.html.erb +8 -0
- data/app/views/rails_admin/main/_kp.html.erb +0 -6
- data/app/views/thecore_utils/_html_helpers.html.erb +65 -0
- data/config/locales/en.thecore_datawedge_websocket_helpers.yml +1 -1
- data/config/locales/it.thecore_datawedge_websocket_helpers.yml +1 -1
- data/lib/thecore_dataentry_commons.rb +2 -2
- data/lib/thecore_dataentry_commons/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98cf537394cb413a353796313e4244682d652b6ac2e99a7b58312b4338ec3ae0
|
4
|
+
data.tar.gz: 6161a1a38897ed7c2164b75aca068436f33a1a201f41e3afc717a93efba0caa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caae373573cb3779a99a56dbca2854c49a75925f18c9b3db7c521f7c3a2a597e8252418087a76a1178754245d4131d71c37b33bf1e85a9b7c81c5c1e7ca075b6
|
7
|
+
data.tar.gz: f6bd40ed3859fb50a797c3625f1bf62c1ba54bdbab4628b3e121d315f5f31815c0dc4bba3735b15b6d78bd0d28e059c7fe25d351d102b996c5a74c3aa0d62be8
|
@@ -3,10 +3,22 @@
|
|
3
3
|
|
4
4
|
<%= render "dataentry_commons_data_container", hide_action: (hide_action rescue true)%>
|
5
5
|
|
6
|
+
<%= render "dataentry_commons_data_action" %>
|
6
7
|
<script>
|
7
8
|
var code;
|
8
9
|
var returnedData;
|
9
10
|
var additionalData = {};
|
11
|
+
var disableKeyManagement = false;
|
12
|
+
|
13
|
+
function resetInfo() {
|
14
|
+
returnedData = code = undefined;
|
15
|
+
$("#barcode").empty();
|
16
|
+
$("#data-info").empty().hide();
|
17
|
+
$("#data-content").empty().hide();
|
18
|
+
<%-unless (hide_action rescue true)%>
|
19
|
+
$("#data-action").hide();
|
20
|
+
<%-end%>
|
21
|
+
}
|
10
22
|
|
11
23
|
// These functions can be overridden in the containing file
|
12
24
|
function setAll() {
|
@@ -17,14 +29,10 @@
|
|
17
29
|
<%-end%>
|
18
30
|
}
|
19
31
|
|
20
|
-
function
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
$("#data-content").empty().hide();
|
25
|
-
<%-unless (hide_action rescue true)%>
|
26
|
-
$("#data-action").hide();
|
27
|
-
<%-end%>
|
32
|
+
function resetAll() {
|
33
|
+
// Resetting all to the starting condition
|
34
|
+
resetCurrentBtn();
|
35
|
+
resetInfo();
|
28
36
|
}
|
29
37
|
|
30
38
|
function contentHtmlString(data){
|
@@ -33,6 +41,8 @@
|
|
33
41
|
|
34
42
|
function barcodeScannedSuccess(data, status) {
|
35
43
|
returnedData = data;
|
44
|
+
if(disableKeyManagement)
|
45
|
+
$(window).off('keydown');
|
36
46
|
// Cleaning up
|
37
47
|
$("#data-content").empty().hide();
|
38
48
|
// Setting info already formatted from the controller
|
@@ -49,30 +59,21 @@
|
|
49
59
|
function barcodeScannedThen(appended){}
|
50
60
|
|
51
61
|
function barcodeScannedFailure(errorObj) {
|
52
|
-
|
53
|
-
resetCurrentBtn();
|
54
|
-
resetInfo();
|
62
|
+
returnedData = errorObj.responseJSON;
|
55
63
|
// Showing modal error
|
56
|
-
|
64
|
+
var primary = null
|
65
|
+
var secondary = null
|
66
|
+
if (errorObj.responseJSON.primary_btn)
|
67
|
+
primary = window[errorObj.responseJSON.primary_btn];
|
68
|
+
if (errorObj.responseJSON.secondary_btn)
|
69
|
+
secondary = window[errorObj.responseJSON.secondary_btn];
|
70
|
+
openModal("<%=t :error %>", errorObj.responseJSON.error, primary, secondary);
|
71
|
+
if(!primary && !secondary)
|
72
|
+
resetAll();
|
57
73
|
}
|
58
74
|
|
59
75
|
<%-unless (hide_action rescue true)%>
|
60
|
-
|
61
|
-
openModal("<%=t :success %>", data.message);
|
62
|
-
setAll();
|
63
|
-
resetCurrentBtn();
|
64
|
-
return data;
|
65
|
-
}
|
66
|
-
|
67
|
-
function dataActionThen(data){}
|
68
|
-
|
69
|
-
function dataActionFailure(errorObj) {
|
70
|
-
barcodeScannedFailure(errorObj);
|
71
|
-
}
|
72
|
-
|
73
|
-
function dataActionAlways(){
|
74
|
-
$("#data-action").button('reset');
|
75
|
-
}
|
76
|
+
dataAction.init();
|
76
77
|
<%-end%>
|
77
78
|
// END of overridable functions
|
78
79
|
|
@@ -86,27 +87,13 @@
|
|
86
87
|
parameters: additionalData
|
87
88
|
}).then(barcodeScannedSuccess).done(barcodeScannedThen).fail(barcodeScannedFailure);
|
88
89
|
}
|
90
|
+
|
89
91
|
<%-if (start_disabled rescue false)%>
|
90
92
|
$('#send').off('click', sendFunction);
|
91
93
|
<%-else%>
|
92
94
|
$('#send').on('click', sendFunction);
|
93
95
|
<%-end%>
|
94
96
|
|
95
|
-
<%-unless (hide_action rescue true)%>
|
96
|
-
// Operation on button click
|
97
|
-
$("#data-action").click(function () {
|
98
|
-
code = $('#barcode');
|
99
|
-
code.prop('disabled', true);
|
100
|
-
$(this).button('loading');
|
101
|
-
$.get('<%=rails_admin.send("#{action_name}_path")%>', {
|
102
|
-
barcode: code.val(),
|
103
|
-
parameters: additionalData,
|
104
|
-
what_to_do: "data-action",
|
105
|
-
data: returnedData
|
106
|
-
}).then(dataActionSuccess).done(dataActionThen).fail(dataActionFailure).always(dataActionAlways);
|
107
|
-
});
|
108
|
-
<%-end%>
|
109
|
-
|
110
97
|
// Starting with a clean interface
|
111
98
|
resetInfo();
|
112
99
|
</script>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<script>
|
2
|
+
var dataAction = {
|
3
|
+
|
4
|
+
success: function(data, status) {
|
5
|
+
openModal('<%=t :success %>', data.message || data.info);
|
6
|
+
setAll();
|
7
|
+
resetCurrentBtn();
|
8
|
+
return data;
|
9
|
+
},
|
10
|
+
|
11
|
+
then: function(data) {},
|
12
|
+
|
13
|
+
failure: function(errorObj) {
|
14
|
+
barcodeScannedFailure(errorObj);
|
15
|
+
},
|
16
|
+
|
17
|
+
always: function () {
|
18
|
+
$("#data-action").button('reset');
|
19
|
+
dataAction.dispose();
|
20
|
+
},
|
21
|
+
// Operation on button click
|
22
|
+
before: function() {},
|
23
|
+
|
24
|
+
run: function() {
|
25
|
+
code = $('#barcode');
|
26
|
+
code.prop('disabled', true);
|
27
|
+
$(this).button('loading');
|
28
|
+
this.before();
|
29
|
+
$.post('<%=rails_admin.send("#{action_name}_path")%>', {
|
30
|
+
barcode: code.val(),
|
31
|
+
parameters: additionalData,
|
32
|
+
what_to_do: "data-action",
|
33
|
+
data: returnedData
|
34
|
+
}).then(this.success).done(this.then).fail(this.failure).always(this.always);
|
35
|
+
},
|
36
|
+
|
37
|
+
init: function() {
|
38
|
+
$(window).off('keydown', manageScannedKeystrokes);
|
39
|
+
let dataActionHtml = $([
|
40
|
+
'<div class="row" id="data-action-container">',
|
41
|
+
' <button id="data-action" onclick="dataAction.run(); return false;" class="btn btn-danger col-lg-12" data-loading-text="<i class=\'fa fa-spinner fa-spin \'></i> <%=t :loading %>"><%=t "barcode.action.name"%></button>',
|
42
|
+
'</div>'
|
43
|
+
].join("\n"));
|
44
|
+
$("#info-container").append(dataActionHtml);
|
45
|
+
// $("#data-action").click(dataAction.run);
|
46
|
+
},
|
47
|
+
|
48
|
+
dispose: function() {
|
49
|
+
$("#data-action-container").remove();
|
50
|
+
$(window).off('keydown');
|
51
|
+
$(window).on('keydown', manageScannedKeystrokes);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
</script>
|
@@ -1,13 +1,8 @@
|
|
1
|
-
<div class="container" style="margin-top: 1em;">
|
1
|
+
<div class="container" style="margin-top: 1em;" id="info-container">
|
2
2
|
<div class="row">
|
3
3
|
<div id="data-info" class="alert alert-warning col-lg-12"></div>
|
4
4
|
</div>
|
5
5
|
<div class="row">
|
6
6
|
<div id="data-content" class="alert alert-warning col-lg-12"></div>
|
7
7
|
</div>
|
8
|
-
<%-unless (hide_action rescue true)%>
|
9
|
-
<div class="row">
|
10
|
-
<button id="data-action" class="btn btn-danger col-lg-12" data-loading-text="<i class='fa fa-spinner fa-spin '></i> <%=t :loading %>"><%=t "barcode.action.name"%></button>
|
11
|
-
</div>
|
12
|
-
<%-end%>
|
13
8
|
</div>
|
@@ -1 +1,9 @@
|
|
1
|
+
<script>
|
2
|
+
function resetCurrentBtn() {
|
3
|
+
$("#send").button('reset');
|
4
|
+
$("#barcode").prop('disabled', false);
|
5
|
+
$("#barcode").val('');
|
6
|
+
// sendMessageToServer(msg_input_plugin_enable); clickedBtn = code = null;
|
7
|
+
}
|
8
|
+
</script>
|
1
9
|
<%=render (@type.presence || "kp"), start_disabled: (start_disabled rescue false) %>
|
@@ -13,12 +13,6 @@
|
|
13
13
|
// var clickedBtn; var code; Gestisco il keypress sull'input
|
14
14
|
// $("#barcode").on(kpMode, keypressAndReturn);
|
15
15
|
|
16
|
-
function resetCurrentBtn() {
|
17
|
-
$("#send").button('reset');
|
18
|
-
$("#barcode").prop('disabled', false);
|
19
|
-
$("#barcode").val('');
|
20
|
-
// sendMessageToServer(msg_input_plugin_enable); clickedBtn = code = null;
|
21
|
-
}
|
22
16
|
// var clickedBtn; var code; Gestisco il keypress sull'input
|
23
17
|
function manageScannedKeystrokes(event) {
|
24
18
|
const keycode = (event.keyCode ? event.keyCode : event.which);
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<script>
|
2
|
+
function buildDTPicker(id, label, initialValue, ro, date_only){
|
3
|
+
var html = '<div class="input-group date" default-date="'+initialValue+'">';
|
4
|
+
html += '<label class="input-group-addon">'+label+'</label>';
|
5
|
+
html += '<input class="form-control" type="text" readonly/>';
|
6
|
+
html += '<label class="input-group-addon"><i class="fa fa-fw fa-calendar"></i></label>';
|
7
|
+
html += '</div>';
|
8
|
+
var jqueryObj = $(html);
|
9
|
+
var dtParams = {
|
10
|
+
locale: "<%=I18n.locale%>",
|
11
|
+
defaultDate: initialValue,
|
12
|
+
ignoreReadonly: !ro,
|
13
|
+
allowInputToggle: true,
|
14
|
+
sideBySide: true,
|
15
|
+
icons: {
|
16
|
+
time: 'fa fa-clock',
|
17
|
+
date: 'fa fa-calendar',
|
18
|
+
up: 'fa fa-chevron-up',
|
19
|
+
down: 'fa fa-chevron-down',
|
20
|
+
previous: 'fa fa-chevron-left',
|
21
|
+
next: 'fa fa-chevron-right',
|
22
|
+
today: 'fa fa-calendar-check',
|
23
|
+
clear: 'fa fa-trash',
|
24
|
+
close: 'fa fa-times'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
if(date_only)
|
28
|
+
dtParams.format = "L";
|
29
|
+
jqueryObj.datetimepicker(dtParams).on('dp.change', function (e){
|
30
|
+
returnedData[id.replace(/-/g, '_')] = e.date.format();
|
31
|
+
$(this).datetimepicker('hide');
|
32
|
+
});
|
33
|
+
return jqueryObj;
|
34
|
+
}
|
35
|
+
|
36
|
+
function buildDatePicker(id, initialValue) {
|
37
|
+
var html = '<div class="input-group date" id="' + id + '">';
|
38
|
+
html += '<input type="text" class="form-control" />';
|
39
|
+
html += '<label class="input-group-addon"><i class="fa fa-fw fa-calendar"></i></label>';
|
40
|
+
html += '</div>';
|
41
|
+
var jqueryObj = $(html);
|
42
|
+
var dtParams = {
|
43
|
+
locale: "<%=I18n.locale%>",
|
44
|
+
defaultDate: initialValue,
|
45
|
+
allowInputToggle: true,
|
46
|
+
format: 'L',
|
47
|
+
icons: {
|
48
|
+
time: 'fa fa-clock',
|
49
|
+
date: 'fa fa-calendar',
|
50
|
+
up: 'fa fa-chevron-up',
|
51
|
+
down: 'fa fa-chevron-down',
|
52
|
+
previous: 'fa fa-chevron-left',
|
53
|
+
next: 'fa fa-chevron-right',
|
54
|
+
today: 'fa fa-calendar-check',
|
55
|
+
clear: 'fa fa-trash',
|
56
|
+
close: 'fa fa-times'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
jqueryObj.datetimepicker(dtParams).on('dp.change', function (e){
|
60
|
+
$(this).datetimepicker('hide');
|
61
|
+
//returnedData[id.replace(/-/g, '_')] = e.date.format();
|
62
|
+
});
|
63
|
+
return jqueryObj;
|
64
|
+
}
|
65
|
+
</script>
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_dataentry_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thecore_ui_rails_admin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: browser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.1'
|
41
41
|
description: This plugin adds some partials to deal with DataWedge WebSocket.
|
42
42
|
email:
|
43
43
|
- gabriele.tassoni@gmail.com
|
@@ -49,11 +49,13 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- app/views/higher_level/_barcode_simple_scan.html.erb
|
51
51
|
- app/views/rails_admin/main/_barcode_scan_mode_detection.html.erb
|
52
|
+
- app/views/rails_admin/main/_dataentry_commons_data_action.html.erb
|
52
53
|
- app/views/rails_admin/main/_dataentry_commons_data_container.html.erb
|
53
54
|
- app/views/rails_admin/main/_dataentry_commons_input_group.html.erb
|
54
55
|
- app/views/rails_admin/main/_dataentry_commons_input_group_logic.html.erb
|
55
56
|
- app/views/rails_admin/main/_kp.html.erb
|
56
57
|
- app/views/rails_admin/main/_ws.html.erb
|
58
|
+
- app/views/thecore_utils/_html_helpers.html.erb
|
57
59
|
- config/locales/en.thecore_datawedge_websocket_helpers.yml
|
58
60
|
- config/locales/it.thecore_datawedge_websocket_helpers.yml
|
59
61
|
- db/migrate/20170913192906_add_keymode_to_settings.rb
|
@@ -80,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
82
|
- !ruby/object:Gem::Version
|
81
83
|
version: '0'
|
82
84
|
requirements: []
|
83
|
-
rubygems_version: 3.0.
|
85
|
+
rubygems_version: 3.0.3
|
84
86
|
signing_key:
|
85
87
|
specification_version: 4
|
86
88
|
summary: Some javascripts and partials to handle DW WS.
|