kaui 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/kaui/account_timelines_controller.rb +117 -0
  3. data/app/controllers/kaui/accounts_controller.rb +50 -7
  4. data/app/controllers/kaui/audit_logs_controller.rb +37 -0
  5. data/app/controllers/kaui/bundles_controller.rb +5 -1
  6. data/app/controllers/kaui/engine_controller.rb +3 -28
  7. data/app/controllers/kaui/engine_controller_util.rb +8 -2
  8. data/app/controllers/kaui/invoices_controller.rb +54 -29
  9. data/app/controllers/kaui/payments_controller.rb +69 -9
  10. data/app/controllers/kaui/sessions_controller.rb +7 -0
  11. data/app/helpers/kaui/exception_helper.rb +25 -0
  12. data/app/helpers/kaui/subscription_helper.rb +5 -1
  13. data/app/models/kaui/account.rb +9 -0
  14. data/app/models/kaui/invoice.rb +2 -0
  15. data/app/models/kaui/payment.rb +7 -0
  16. data/app/views/kaui/account_timelines/_multi_functions_bar.html.erb +155 -0
  17. data/app/views/kaui/account_timelines/show.html.erb +2 -0
  18. data/app/views/kaui/accounts/_account_info.html.erb +7 -0
  19. data/app/views/kaui/accounts/_multi_functions_bar.html.erb +329 -0
  20. data/app/views/kaui/accounts/index.html.erb +32 -18
  21. data/app/views/kaui/audit_logs/_multi_functions_bar.html.erb +189 -0
  22. data/app/views/kaui/audit_logs/index.html.erb +8 -0
  23. data/app/views/kaui/bundles/index.html.erb +34 -0
  24. data/app/views/kaui/errors/500.html.erb +29 -0
  25. data/app/views/kaui/invoices/_multi_functions_bar.html.erb +322 -0
  26. data/app/views/kaui/invoices/index.html.erb +49 -24
  27. data/app/views/kaui/payments/_multi_functions_bar.html.erb +323 -0
  28. data/app/views/kaui/payments/index.html.erb +73 -30
  29. data/config/locales/en.yml +3 -0
  30. data/config/routes.rb +7 -0
  31. data/lib/kaui/error_handler.rb +37 -0
  32. data/lib/kaui/version.rb +1 -1
  33. data/lib/kaui.rb +117 -30
  34. metadata +13 -19
@@ -4,6 +4,15 @@ module Kaui
4
4
  class Account < KillBillClient::Model::Account
5
5
  attr_accessor :phone, :bill_cycle_day_local
6
6
 
7
+ SENSIVITE_DATA_FIELDS = %w[name email].freeze
8
+ REMAPPING_FIELDS = {
9
+ 'is_payment_delegated_to_parent' => 'pay_via_parent',
10
+ 'bill_cycle_day_local' => 'bcd',
11
+ 'account_balance' => 'balance',
12
+ 'account_cba' => 'cba',
13
+ 'is_migrated' => 'migrated'
14
+ }.freeze
15
+
7
16
  def check_account_details_phone
8
17
  return true if phone =~ /\A(?:\+?\d{1,3}\s*-?)?\(?(?:\d{3})?\)?[- ]?\d{3}[- ]?\d{4}\z/i
9
18
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Kaui
4
4
  class Invoice < KillBillClient::Model::Invoice
5
+ TABLE_IGNORE_COLUMNS = %w[amount balance credit_adj refund_adj items is_parent_invoice parent_invoice_id parent_account_id audit_logs bundle_keys].freeze
6
+
5
7
  def self.build_from_raw_invoice(raw_invoice)
6
8
  result = Kaui::Invoice.new
7
9
  KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes').each do |attr|
@@ -7,6 +7,13 @@ module Kaui
7
7
  attr_accessor :payment_date, :target_invoice_id
8
8
 
9
9
  TRANSACTION_STATUSES = %w[SUCCESS PENDING PAYMENT_FAILURE PLUGIN_FAILURE UNKNOWN].freeze
10
+ REMAPPING_FIELDS = {
11
+ 'auth_amount' => 'auth',
12
+ 'captured_amount' => 'capture',
13
+ 'purchased_amount' => 'purchase',
14
+ 'credited_amount' => 'credit',
15
+ 'refunded_amount' => 'refund'
16
+ }.freeze
10
17
 
11
18
  def self.build_from_raw_payment(raw_payment)
12
19
  result = Kaui::Payment.new
@@ -0,0 +1,155 @@
1
+ <div class="functions-container">
2
+ <button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
3
+ <i class="glyphicon glyphicon-download-alt"></i>
4
+ <strong>Download CSV</strong>
5
+ </button>
6
+ </div>
7
+
8
+ <div class="modal fade" id="downloadCsvModal" tabindex="-1" role="dialog" aria-labelledby="downloadCsvModalLabel" aria-hidden="true">
9
+ <div class="modal-dialog" role="document">
10
+ <div class="modal-content">
11
+ <div class="modal-header">
12
+ <h3 class="modal-title" id="downloadCsvModalLabel">Download</h3>
13
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
14
+ <span aria-hidden="true">&times;</span>
15
+ </button>
16
+ </div>
17
+ <div class="modal-body">
18
+ <form id="downloadCsvForm">
19
+ <div class="row">
20
+ <div class="col-md-6">
21
+ <div class="form-group">
22
+ <label for="startDate">Effective Date:</label>
23
+ <input type="text" class="form-control" id="startDate" name="startDate">
24
+ </div>
25
+ </div>
26
+ <div class="col-md-6">
27
+ <div class="form-group">
28
+ <label for="endDate">To:</label>
29
+ <input type="text" class="form-control" id="endDate" name="endDate">
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <div class="row">
34
+ <div class="col-md-6">
35
+ <div class="form-check">
36
+ <div>
37
+ <input type="radio" id="customDate" name="download_option" value="customDate">
38
+ <label for="customDate">Custom date</label>
39
+ </div>
40
+ <div>
41
+ <input type="radio" id="allData" name="download_option" value="all">
42
+ <label for="allData">All events</label>
43
+ </div>
44
+ <div>
45
+ <input type="radio" id="thisWeek" name="download_option" value="thisWeek">
46
+ <label for="thisWeek">This week</label>
47
+ </div>
48
+ <div>
49
+ <input type="radio" id="thisMonth" name="download_option" value="thisMonth">
50
+ <label for="thisMonth">This month</label>
51
+ </div>
52
+ <div>
53
+ <input type="radio" id="thisYear" name="download_option" value="thisYear">
54
+ <label for="thisYear">This year</label>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </form>
60
+ </div>
61
+ <div class="modal-footer">
62
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
63
+ <button type="button" class="btn btn-primary" id="downloadButton">Download</button>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+
69
+ <style>
70
+ .download-button-right {
71
+ float: right;
72
+ margin-left: 10px;
73
+ background-color: white;
74
+ color: black;
75
+ text-transform: none;
76
+ border: 1px solid #ccc;
77
+ padding: 8px 15px;
78
+ }
79
+
80
+ .functions-container {
81
+ display: flex;
82
+ justify-content: flex-end;
83
+ }
84
+ </style>
85
+
86
+ <%= javascript_tag do %>
87
+ $(document).ready(function() {
88
+ $('.dropdown-menu').on('click', 'input[type="checkbox"], label', function(event) {
89
+ event.stopPropagation();
90
+ });
91
+
92
+ $('#modalDownloadButton').click(function() {
93
+ $('#downloadCsvModal').modal('show');
94
+ });
95
+
96
+ $('#startDate, #endDate').datepicker({
97
+ dateFormat: 'yy-mm-dd'
98
+ });
99
+
100
+ $('#downloadCsvModal').on('show.bs.modal', function (e) {
101
+ $('#allData').prop('checked', true);
102
+ $('#startDate, #endDate').prop('disabled', true);
103
+ $('#startDate').val(null);
104
+ $('#endDate').val(null);
105
+ });
106
+
107
+ $('#allData').change(function() {
108
+ $('#startDate').val(null);
109
+ $('#endDate').val(null);
110
+ $('#startDate, #endDate').prop('disabled', true);
111
+ });
112
+
113
+ $('#thisWeek').change(function() {
114
+ if ($(this).is(':checked')) {
115
+ setDateRange("week");
116
+ }
117
+ });
118
+
119
+ $('#thisMonth').change(function() {
120
+ if ($(this).is(':checked')) {
121
+ setDateRange("month");
122
+ }
123
+ });
124
+
125
+ $('#thisYear').change(function() {
126
+ if ($(this).is(':checked')) {
127
+ setDateRange("year");
128
+ }
129
+ });
130
+
131
+ $('#customDate').change(function() {
132
+ if ($(this).is(':checked')) {
133
+ setDateRange("day");
134
+ $('#startDate, #endDate').prop('disabled', false);
135
+ }
136
+ });
137
+
138
+ var downloadButton = document.getElementById('downloadButton');
139
+ if (downloadButton) {
140
+ downloadButton.addEventListener('click', function() {
141
+ event.preventDefault();
142
+ var startDate = $('#startDate').val();
143
+ var endDate = $('#endDate').val();
144
+ var downloadAll = $('#allData').is(':checked');
145
+ var eventToFilter = $('#event_types').val().toUpperCase()
146
+
147
+ if (downloadAll) {
148
+ window.open("<%= download_account_timeline_path %>?account_id=<%=@account.account_id%>&eventType="+eventToFilter, '_blank');
149
+ } else {
150
+ window.open("<%= download_account_timeline_path %>?account_id=<%=@account.account_id%>&startDate="+startDate+"&endDate="+endDate+"&eventType="+eventToFilter, '_blank');
151
+ }
152
+ });
153
+ }
154
+ });
155
+ <% end %>
@@ -21,6 +21,8 @@
21
21
  </div>
22
22
  </form>
23
23
 
24
+ <%= render :partial => 'multi_functions_bar' %>
25
+
24
26
  <hr/>
25
27
 
26
28
  <table id="timeline-table" class="table table-condensed mobile-data">
@@ -18,6 +18,13 @@
18
18
  :class => 'btn btn-xs text-danger',
19
19
  data: {toggle: 'modal', name: @account.name || '(not set)', account_id: @account.account_id}) %>
20
20
  <% end %>
21
+
22
+ <% if can? :export, Kaui::AdminTenant %>
23
+ <%= link_to '<i class="fa fa-arrow-down" aria-hidden="true"></i>Export'.html_safe,
24
+ kaui_engine.export_account_path(@account.account_id),
25
+ :class => 'btn btn-xs', :id => 'download_link', :title => 'Export Account Data' %>
26
+ <% end %>
27
+
21
28
  <% unless @account.parent_account_id.nil? %>
22
29
  <span class="label label-info account-child-label">Child</span>
23
30
  <% end %>
@@ -0,0 +1,329 @@
1
+ <div class="dropdown-container">
2
+ <button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
3
+ <i class="glyphicon glyphicon-download-alt"></i>
4
+ <strong>Download CSV</strong>
5
+ </button>
6
+ <div class="dropdown">
7
+ <button class="btn btn-default dropdown-toggle toggle-button-right" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
8
+ <i class="glyphicon glyphicon-cog"></i>
9
+ <strong>Edit Columns</strong>
10
+ </button>
11
+ <ul class="dropdown-menu" id="column-visibility" aria-labelledby="v">
12
+ <% Kaui.account_search_columns.call[0].each_with_index do |title, index| %>
13
+ <li class="list-group-item-manual" data-id="<%= index %>">
14
+ <label class="label-group-item-manual">
15
+ <input type="checkbox" class="column-toggle" draggable="true" data-column="<%= index %>" <%= 'checked' if @dropdown_default[index][:visible] %> > <%= title %>
16
+ <span class="glyphicon glyphicon-option-vertical icon-drag" aria-hidden="true"></span>
17
+ </label>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ </div>
22
+ </div>
23
+
24
+ <div class="modal fade" id="downloadCsvModal" tabindex="-1" role="dialog" aria-labelledby="downloadCsvModalLabel" aria-hidden="true">
25
+ <div class="modal-dialog" role="document">
26
+ <div class="modal-content">
27
+ <div class="modal-header">
28
+ <h3 class="modal-title" id="downloadCsvModalLabel">Download</h3>
29
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
30
+ <span aria-hidden="true">&times;</span>
31
+ </button>
32
+ </div>
33
+ <div class="modal-body">
34
+ <form id="downloadCsvForm">
35
+ <div class="row">
36
+ <div class="col-md-6">
37
+ <div class="form-group">
38
+ <label for="startDate">Account Creation Date From:</label>
39
+ <input type="text" class="form-control" id="startDate" name="startDate">
40
+ </div>
41
+ </div>
42
+ <div class="col-md-6">
43
+ <div class="form-group">
44
+ <label for="endDate">To:</label>
45
+ <input type="text" class="form-control" id="endDate" name="endDate">
46
+ </div>
47
+ </div>
48
+ </div>
49
+ <div class="row">
50
+ <div class="col-md-6">
51
+ <div class="form-check">
52
+ <div>
53
+ <input type="radio" id="customDate" name="download_option" value="customDate">
54
+ <label for="customDate">Custom date</label>
55
+ </div>
56
+ <div>
57
+ <input type="radio" id="allData" name="download_option" value="all">
58
+ <label for="allData">All accounts</label>
59
+ </div>
60
+ <div>
61
+ <input type="radio" id="thisWeek" name="download_option" value="thisWeek">
62
+ <label for="thisWeek">This week</label>
63
+ </div>
64
+ <div>
65
+ <input type="radio" id="thisMonth" name="download_option" value="thisMonth">
66
+ <label for="thisMonth">This month</label>
67
+ </div>
68
+ <div>
69
+ <input type="radio" id="thisYear" name="download_option" value="thisYear">
70
+ <label for="thisYear">This year</label>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ <div class="row">
76
+ <div class="col-md-12">
77
+ <h5>Additional Options</h5>
78
+ </div>
79
+ </div>
80
+ <div class="row">
81
+ <div class="col-md-6">
82
+ <div class="form-check">
83
+ <input type="checkbox" class="form-check-input" id="allFields" name="allFields">
84
+ <label class="form-check-label" for="allFields">All fields</label>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </form>
89
+ </div>
90
+ <div class="modal-footer">
91
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
92
+ <button type="button" class="btn btn-primary" id="downloadButton">Download</button>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ </div>
97
+
98
+ <style>
99
+ .dropdown-menu#column-visibility {
100
+ max-height: 300px;
101
+ width: 200px;
102
+ overflow-y: auto;
103
+ }
104
+
105
+ .dropdown-menu#column-visibility::before {
106
+ content: 'Drag to reorder columns';
107
+ display: block;
108
+ height: 30px;
109
+ text-align: center;
110
+ color: darkgrey;
111
+ padding-top: 5px;
112
+ }
113
+
114
+ .dropdown-menu {
115
+ padding: 5px;
116
+ }
117
+
118
+ .toggle-button-right {
119
+ float: right;
120
+ margin-bottom: 10px;
121
+ margin-left: 10px;
122
+ background-color: white;
123
+ color: black;
124
+ text-transform: none;
125
+ border: 1px solid #ccc;
126
+ padding: 8px 15px;
127
+ }
128
+
129
+ .download-button-right {
130
+ float: right;
131
+ margin-bottom: 10px;
132
+ margin-left: 10px;
133
+ background-color: white;
134
+ color: black;
135
+ text-transform: none;
136
+ border: 1px solid #ccc;
137
+ padding: 8px 15px;
138
+ }
139
+
140
+ .icon-drag {
141
+ float: right;
142
+ padding: 5px;
143
+ }
144
+
145
+ .dropdown-container {
146
+ display: flex;
147
+ justify-content: flex-end;
148
+ }
149
+
150
+ .label-group-item-manual {
151
+ margin: 5px;
152
+ width: -webkit-fill-available;
153
+ cursor: grab;
154
+ }
155
+ .label-group-item-manual:active {
156
+ cursor: grabbing;
157
+ }
158
+ </style>
159
+
160
+ <%= javascript_tag do %>
161
+ $(document).ready(function() {
162
+ $('.dropdown-menu').on('click', 'input[type="checkbox"], label', function(event) {
163
+ event.stopPropagation();
164
+ });
165
+
166
+ $('#modalDownloadButton').click(function() {
167
+ $('#downloadCsvModal').modal('show');
168
+ });
169
+
170
+ $('#startDate, #endDate').datepicker({
171
+ dateFormat: 'yy-mm-dd'
172
+ });
173
+
174
+ $('#downloadCsvModal').on('show.bs.modal', function (e) {
175
+ $('#allData').prop('checked', true);
176
+ $('#startDate, #endDate').prop('disabled', true);
177
+ $('#startDate').val(null);
178
+ $('#endDate').val(null);
179
+ });
180
+
181
+ $('#allData').change(function() {
182
+ $('#startDate').val(null);
183
+ $('#endDate').val(null);
184
+ $('#startDate, #endDate').prop('disabled', true);
185
+ });
186
+
187
+ $('#thisWeek').change(function() {
188
+ if ($(this).is(':checked')) {
189
+ setDateRange("week");
190
+ }
191
+ });
192
+
193
+ $('#thisMonth').change(function() {
194
+ if ($(this).is(':checked')) {
195
+ setDateRange("month");
196
+ }
197
+ });
198
+
199
+ $('#thisYear').change(function() {
200
+ if ($(this).is(':checked')) {
201
+ setDateRange("year");
202
+ }
203
+ });
204
+
205
+ $('#customDate').change(function() {
206
+ if ($(this).is(':checked')) {
207
+ setDateRange("day");
208
+ $('#startDate, #endDate').prop('disabled', false);
209
+ }
210
+ });
211
+
212
+ var downloadButton = document.getElementById('downloadButton');
213
+ if (downloadButton) {
214
+ downloadButton.addEventListener('click', function() {
215
+ event.preventDefault();
216
+
217
+ var allFieldsChecked = document.getElementById('allFields').checked;
218
+ var startDate = $('#startDate').val();
219
+ var endDate = $('#endDate').val();
220
+ var downloadAll = $('#allData').is(':checked');
221
+ var thElements = document.querySelectorAll('#accounts-table th');
222
+ var columnTitles = Array.from(thElements).map(function(th) {
223
+ return th.textContent.trim();
224
+ });
225
+ var columnsString = columnTitles.join(',')
226
+ var url = new URL("<%= download_accounts_path %>", window.location.origin);
227
+ var params = new URLSearchParams();
228
+ params.append('columnsString', columnsString);
229
+ if (!downloadAll) {
230
+ params.append('startDate', startDate);
231
+ params.append('endDate', endDate);
232
+ }
233
+ params.append('allFieldsChecked', allFieldsChecked);
234
+ url.search = params.toString();
235
+ console.log(url.toString());
236
+ window.open(url.toString(), '_blank');
237
+ });
238
+ }
239
+
240
+ updateDropdownOrder();
241
+
242
+ function updateDropdownOrder() {
243
+ var state = JSON.parse(localStorage.getItem('DataTables_accounts-table_' + window.location.pathname));
244
+ if (state === null) {
245
+ return;
246
+ }
247
+ var columnOrder = state.ColReorder;
248
+ var $list = $('#column-visibility');
249
+ var thElements = document.querySelectorAll('#accounts-table th');
250
+ var $columnTitles = Array.from(thElements).map(function(th) {
251
+ return th.textContent.trim();
252
+ });
253
+
254
+ if (columnOrder !== undefined) {
255
+ $list.empty();
256
+ var state = JSON.parse(localStorage.getItem('DataTables_accounts-table_' + window.location.pathname));
257
+ if (state !== null) {
258
+ var colsOrder = state.ColReorder;
259
+ }
260
+ columnOrder.forEach(function(colIdx, index) {
261
+ if (colsOrder) {
262
+ var data_id = colsOrder[index];
263
+ } else {
264
+ var data_id = index;
265
+ }
266
+ var $item = $('<li>', { class: "list-group-item-manual", "data-id": data_id });
267
+ var column = state.columns[colIdx];
268
+ var col_name = $columnTitles[colIdx];
269
+ var $label = $('<label>', {
270
+ class: "label-group-item-manual",
271
+ });
272
+ var $checkbox = $("<input>", {
273
+ type: "checkbox",
274
+ value: colIdx,
275
+ checked: column.visible,
276
+ "data-column": colIdx,
277
+ class: "column-toggle"
278
+ });
279
+ $label.append($checkbox).append(" " + col_name);
280
+ var $icon = $("<span>", { class: "glyphicon glyphicon-option-vertical icon-drag"});
281
+ $label.append($icon);
282
+ $item.append($label);
283
+ $list.append($item);
284
+ });
285
+ }
286
+ resetDataColumn();
287
+ resetDataId();
288
+ }
289
+
290
+ $("#column-visibility").sortable({
291
+ axis: "y",
292
+ containment: "parent",
293
+ stop: function(event, ui) {
294
+ var order = $("#column-visibility").sortable('toArray', {attribute: 'data-id'});
295
+ reorderTableColumns(order);
296
+ }
297
+ });
298
+ $("#column-visibility").disableSelection();
299
+
300
+ function reorderTableColumns(order) {
301
+ var table = $('#accounts-table').DataTable();
302
+ var columnIndexes = order.map(Number);
303
+ console.log('New column order:', columnIndexes);
304
+ table.colReorder.order(columnIndexes);
305
+ resetDataColumn();
306
+ resetDataId();
307
+ }
308
+
309
+ function resetDataId() {
310
+ var elements = document.querySelectorAll('.list-group-item-manual');
311
+ elements.forEach(function(element, index) {
312
+ element.setAttribute('data-id', index);
313
+ });
314
+ }
315
+
316
+ function resetDataColumn() {
317
+ var elements = document.querySelectorAll('.column-toggle');
318
+ elements.forEach(function(element, index) {
319
+ element.setAttribute('data-column', index);
320
+ });
321
+ }
322
+
323
+ $('.column-toggle').on('change', function() {
324
+ var table = $('#accounts-table').DataTable();
325
+ var column = table.column($(this).attr('data-column'));
326
+ column.visible(!column.visible());
327
+ });
328
+ });
329
+ <% end %>
@@ -7,13 +7,12 @@
7
7
  <% else %>
8
8
  <h1>Showing all accounts</h1>
9
9
  <% end %>
10
+ <%= render :partial => 'multi_functions_bar' %>
10
11
 
11
- <table id="accounts-table" class="table table-condensed mobile-data">
12
+ <table id="accounts-table" class="table table-condensed mobile-data" style="width:100%">
12
13
  <thead>
13
14
  <tr>
14
- <th></th>
15
- <th>ID</th>
16
- <% Kaui.account_search_columns.call()[0].each do |title| %>
15
+ <% Kaui.account_search_columns.call[0].each do |title| %>
17
16
  <th><%= title %></th>
18
17
  <% end %>
19
18
  </tr>
@@ -24,15 +23,26 @@
24
23
  </tr>
25
24
  </tbody>
26
25
  </table>
27
-
28
26
  </div>
29
-
30
27
  </div>
31
28
 
29
+ <style>
30
+ #accounts-table td, #accounts-table tr {
31
+ white-space: nowrap;
32
+ }
33
+ .custom-checkbox {
34
+ pointer-events: none;
35
+ }
36
+ </style>
37
+
32
38
  <%= javascript_tag do %>
33
39
  $(document).ready(function() {
34
-
35
40
  var table = $('#accounts-table').DataTable({
41
+ "colReorder": {
42
+ "enable": false
43
+ },
44
+ "stateSave": true,
45
+ "scrollX": true,
36
46
  "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
37
47
  "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
38
48
  "language": {
@@ -49,17 +59,21 @@ $(document).ready(function() {
49
59
  "processing": true,
50
60
  "serverSide": true,
51
61
  "search": {"search": "<%= @search_query %>"},
52
- "ajax": "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
53
- "columnDefs": [
54
- { "orderable": false, "targets": 0, "createdCell": function (td, cellData, rowData, row, col) {
55
- $(td).css('padding-left', '20px');
56
- $(td).css('width', '60px');
57
-
58
- } }
59
- ],
60
- drawCallback: function() {
61
- setObjectIdPopover();
62
- }
62
+ "ajax": {
63
+ url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
64
+ dataSrc: function(json) {
65
+ var colOrder = table.colReorder.order();
66
+ var reorderedData = json.data.map(function(row) {
67
+ var newRow = [];
68
+ for (var i = 0; i < colOrder.length; i++) {
69
+ newRow.push(row[colOrder[i]]);
70
+ }
71
+ return newRow;
72
+ });
73
+ return reorderedData;
74
+ }
75
+ },
76
+ "columns": <%= raw @visible_columns.to_json %>
63
77
  });
64
78
 
65
79
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->