thecore_dataentry_commons 1.4.7 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c32e615b4d9709032878d535a678e424161a124075427c4630feed29a4b6c46
4
- data.tar.gz: '092968d69255797c074bd22fbd5f4cbea0a78ca480344c3131c3d84703f74d31'
3
+ metadata.gz: 69be673cf75a0edb0b5ffc9b8b2388bfd4227e70bdecbe7c94d5c1a229013d8c
4
+ data.tar.gz: 24d9b9cae23b01de0073c78cce3e2eda924d38db9cefd324b768065b8425453c
5
5
  SHA512:
6
- metadata.gz: 2bd0cbbdb728ae47e4614fe48d29fc1bbb83e551e473d49692bee167aebf74a2a9fa05e55e534f3beeef2a2f106321ae015a497c3b8ed9244192726b3d948b08
7
- data.tar.gz: cafdeb83b68bb348892114af3c1403575c80af52963e494bf0ace1362541f4617c2909d2be70036b987c40ce1056dc759d7e4dda5c80328cfec1c384088a4535
6
+ metadata.gz: '0385b1c20013adb0aab32119bacf53d0069728045d597c13f1f341485fa2540da46a63e01f3f4870e4a66bc98392d752dbe1a2d1ba8bff0e8fe2f46ceeeddeef'
7
+ data.tar.gz: 223980eb810a422634455c13b9bbe80c6b3feed6a7d7f1aace8a16461db87d557d071a22c66aed17a44188995b3c4660858d425e8c764407bf09ce183def536c
@@ -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 resetInfo() {
21
- returnedData = code = undefined;
22
- $("#barcode").empty();
23
- $("#data-info").empty().hide();
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
- // Resetting all to the starting condition
53
- resetCurrentBtn();
54
- resetInfo();
62
+ returnedData = errorObj.responseJSON;
55
63
  // Showing modal error
56
- openModal("<%=t :error %>", errorObj.responseJSON.error);
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
- function dataActionSuccess(data, status) {
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
+ $.get('<%=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>
@@ -16,4 +16,4 @@ en:
16
16
  barcode:
17
17
  action:
18
18
  name:
19
- Send (CTRL + space)
19
+ Send
@@ -16,4 +16,4 @@ it:
16
16
  barcode:
17
17
  action:
18
18
  name:
19
- Invia (CTRL + spazio)
19
+ Elabora
@@ -1,3 +1,3 @@
1
1
  module ThecoreDataentryCommons
2
- VERSION = '1.4.7'.freeze
2
+ VERSION = '1.4.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_dataentry_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2019-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_settings
@@ -49,6 +49,7 @@ 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