thecore_dataentry_commons 1.4.6 → 2.0.1

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: 87f9ac84382de0a404470be5028fba6995603c98e365eb62903c947ead4cdeb5
4
- data.tar.gz: 27e7051b9ad877b7da2258c92e7cf2699ac6bcc54d06542d85ce72cdb527e9c0
3
+ metadata.gz: e7e1ec2618c611bfd7ecf1c5bd25a021b1371e8fc1e518cedeb179877380668a
4
+ data.tar.gz: 95c6025fd0cb286fa150aeec8cd9eb83e81e6660924250209a900aa300c06012
5
5
  SHA512:
6
- metadata.gz: 0b3db55eb4a617b6126b0563f00054edd0cff4a66064e80ab0cd6941827bad2e5676fea798167191f2842ca6b9c592c5cd219386a1eb21a51443eecf66004d79
7
- data.tar.gz: 9df03f723df7e5456acf4481721622dbb028e8a9d1a0c58f658368ef7f3305e146598abaaee1042e679abf70df0d068eb3c7968adb145d6d0b9e8b39ac65d5a5
6
+ metadata.gz: c1829970cebb97ac0f2ec358db7a5f244a1101513a4a2b150fa5b0483b874fff681a2bbaa578d3aa086ec922ea5a8ad6a0bc04d581914bc16fae6b13f25ecddb
7
+ data.tar.gz: 8de5519f780b1dc693c71d94b16107c2f71ad68fe0339bd5d4b9a6e4e754e0f873ecfcd839003f185932f997d70914f371f2ec0c98e6b7dcd2bbaa037cc317dc
@@ -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
+ $.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);
@@ -29,6 +23,7 @@
29
23
  (keycode > 95 && keycode < 112) || // numpad keys
30
24
  (keycode > 185 && keycode < 193) || // ;=,-./` (in order)
31
25
  (keycode > 218 && keycode < 223)); // [\]' (in order)
26
+ // console.log(`Is it Valid? ${valid}`);
32
27
  let prevent = false;
33
28
  if (event.ctrlKey && keycode == '32') {
34
29
  // Invia il form secondario
@@ -43,7 +38,7 @@
43
38
  prevent = true;
44
39
  } else if (valid) { // if (event.target.id != "barcode")
45
40
  // Scrivilo nell'input field (accumulando)
46
- console.log("Write to the field");
41
+ // console.log("Write to the field");
47
42
  $("#barcode").val(function (index, val) {
48
43
  // Write
49
44
  return val + event.key;
@@ -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>
@@ -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,6 +1,6 @@
1
- require "thecore_settings"
2
- require "thecore_dataentry_commons/engine"
1
+ require "thecore_ui_rails_admin"
3
2
  require "browser"
3
+ require "thecore_dataentry_commons/engine"
4
4
 
5
5
  module ThecoreDataentryCommons
6
6
  # Your code goes here...
@@ -8,11 +8,13 @@ module ThecoreDataentryCommons
8
8
  # app.middleware.use ::ActionDispatch::Static, "#{root}/app"
9
9
  # end
10
10
  initializer 'thecore_dataentry_commons.add_to_migrations' do |app|
11
- unless app.root.to_s == root.to_s
11
+ unless app.root.to_s.match root.to_s
12
12
  # APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
13
13
  config.paths['db/migrate'].expanded.each do |expanded_path|
14
14
  app.config.paths['db/migrate'] << expanded_path
15
15
  end
16
+ # = app.config.paths['db/migrate'].uniq
17
+ # puts app.config.paths['db/migrate'].map(:path).inspect
16
18
  end
17
19
  end
18
20
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreDataentryCommons
2
- VERSION = '1.4.6'.freeze
2
+ VERSION = '2.0.1'.freeze
3
3
  end
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: 1.4.6
4
+ version: 2.0.1
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-19 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thecore_settings
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: '1.1'
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: '1.1'
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: '2.5'
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: '2.5'
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,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  - !ruby/object:Gem::Version
81
83
  version: '0'
82
84
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.7.7
85
+ rubygems_version: 3.1.2
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: Some javascripts and partials to handle DW WS.