tabulatr2 0.9.34 → 0.9.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c8c69cd0b5f5693a39aeaeb1e3739a612d207c2
4
- data.tar.gz: aeca5e6b9c330ee6df1c265f6c67b45adce58e39
3
+ metadata.gz: f78160470ba558135fdea0fefb2e29e11e87ae16
4
+ data.tar.gz: 4ecee9bdc437f1c127b6f3655c1216d7ef6c78b7
5
5
  SHA512:
6
- metadata.gz: 9108b2b8ef04bc380c99cd936a0b4b40da0addf5cda1c6ca9acc4395a782f145230ef7beb734c787578a09b38424505e892930ada3a2e4e28c76b66c73eec909
7
- data.tar.gz: b6e1a26f200e661573256c42801df53f6b4667d1558367d59e258cebedfcd7a1564b621a22cdc719b73b943fe03930e74b7aea9313e307bf80931958be07f4ec
6
+ metadata.gz: 4012a84a4caa68a651a3221510948debbf3fafdc14da6a3eeb1047f4b4ccb6a2a0d6616b54f06465bd79410e608a36b229b6fe963ef7324b2032c66911f31268
7
+ data.tar.gz: 52f710e1d5e2c74353e89c787f8342d1387183477d8eb3eeaf381b264d92df48c87638d992c94980cdb8c1b708b57452802ca109d8e566890ffb28def1495116
@@ -43,6 +43,7 @@ $(function(){
43
43
  var key = a.data('do-batch-action');
44
44
  var tableId = a.data('table-id');
45
45
  var params = {page: 1};
46
+ var use_ajax = !a.data('download');
46
47
  params[name] = key;
47
48
  params.tabulatr_checked = {checked_ids: jQuery.map($('#'+ tableId +' .tabulatr-checkbox:checked'), function(el){return $(el).val();}).join(',')};
48
49
  var confirmation = true;
@@ -58,7 +59,10 @@ $(function(){
58
59
  table_obj = tabulatr_tables[i];
59
60
  }
60
61
  }
61
- table_obj.updateTable(params, true);
62
+ if (use_ajax)
63
+ table_obj.updateTable(params, true);
64
+ else
65
+ table_obj.sendRequestWithoutAjax(params);
62
66
  }
63
67
  });
64
68
 
@@ -36,6 +36,16 @@ Tabulatr.prototype = {
36
36
  this.loadDataFromServer(hash);
37
37
  },
38
38
 
39
+ sendRequestWithoutAjax: function(hash) {
40
+ var data = this.getDataForAjax(hash);
41
+ var url;
42
+ if ($('table#'+ this.id).data('path') == '#')
43
+ url = $(location).attr("pathname") + ".pdf?" + $.param(data)
44
+ else
45
+ url = $('table#'+ this.id).data('path') + ".pdf?" + $.param(data);
46
+ window.open(url);
47
+ },
48
+
39
49
  pageShouldBeStored: function(page, forceReload){
40
50
  return page !== undefined && !forceReload;
41
51
  },
@@ -67,7 +77,11 @@ Tabulatr.prototype = {
67
77
  data = this.createParameterString(hash, this.id);
68
78
  if(this.isAPersistedTable) {
69
79
  try {
70
- localStorage[this.id] = JSON.stringify(data);
80
+ var storableData = jQuery.extend(true, {}, data);
81
+ var batch_key = this.id.split('_')[0] + '_batch';
82
+ if (batch_key in storableData)
83
+ delete storableData[batch_key];
84
+ localStorage[this.id] = JSON.stringify(storableData);
71
85
  } catch(e) {}
72
86
  }
73
87
  }
@@ -105,6 +119,9 @@ Tabulatr.prototype = {
105
119
  },
106
120
 
107
121
  handleResponse: function(response) {
122
+ if (typeof response === "string")
123
+ response = JSON.parse(response);
124
+
108
125
  this.insertTabulatrData(response);
109
126
  var tabulatrPagination = new TabulatrPagination(
110
127
  response.meta.pages, response.meta.table_id);
@@ -125,11 +142,23 @@ Tabulatr.prototype = {
125
142
  },
126
143
 
127
144
  insertTabulatrData: function(response){
145
+ if (typeof response === "string")
146
+ response = JSON.parse(response);
147
+
128
148
  var tableId = response.meta.table_id;
129
- var tbody = $('#'+ tableId +' tbody');
149
+ var table = $('#'+ tableId);
150
+ var tbody = table.find('tbody');
151
+ var ndpanel = $('#no-data-' + tableId);
130
152
 
131
153
  this.prepareTableForInsert(tableId, response.meta.append, response.data.length, response.meta.count);
132
154
 
155
+ if (ndpanel.length > 0 && response.data.length == 0) {
156
+ table.hide();
157
+ ndpanel.show();
158
+ } else {
159
+ table.show();
160
+ ndpanel.hide();
161
+ }
133
162
 
134
163
  // insert the actual data
135
164
  for(var i = 0; i < response.data.length; i++){
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.34"
25
+ VERSION = "0.9.35"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.34
4
+ version: 0.9.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-11-06 00:00:00.000000000 Z
13
+ date: 2017-11-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails