effective_datatables 3.7.7 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +32 -32
  4. data/app/assets/images/dataTables/sort-down.svg +1 -0
  5. data/app/assets/images/dataTables/sort-up.svg +1 -0
  6. data/app/assets/images/dataTables/sort.svg +1 -0
  7. data/app/assets/javascripts/dataTables/buttons/{buttons.bootstrap.js → buttons.bootstrap4.js} +7 -15
  8. data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +184 -0
  9. data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +30 -11
  10. data/app/assets/javascripts/dataTables/responsive/{responsive.bootstrap.js → responsive.bootstrap4.js} +6 -6
  11. data/app/assets/javascripts/effective_datatables.js +4 -4
  12. data/app/assets/javascripts/effective_datatables/bulk_actions.js.coffee +43 -43
  13. data/app/assets/javascripts/effective_datatables/events.js.coffee +7 -4
  14. data/app/assets/javascripts/effective_datatables/filters.js.coffee +0 -1
  15. data/app/assets/javascripts/effective_datatables/initialize.js.coffee +45 -49
  16. data/app/assets/javascripts/effective_datatables/overrides.js +12 -0
  17. data/app/assets/javascripts/effective_datatables/reset.js.coffee +1 -1
  18. data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.scss → buttons.bootstrap4.css} +68 -1
  19. data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.scss → dataTables.bootstrap4.css} +44 -29
  20. data/app/assets/stylesheets/dataTables/responsive/{responsive.bootstrap.scss → responsive.bootstrap4.css} +3 -3
  21. data/app/assets/stylesheets/effective_datatables.scss +3 -4
  22. data/app/assets/stylesheets/effective_datatables/_overrides.scss +72 -152
  23. data/app/controllers/effective/datatables_controller.rb +6 -39
  24. data/app/helpers/effective_datatables_helper.rb +55 -50
  25. data/app/helpers/effective_datatables_private_helper.rb +47 -179
  26. data/app/models/effective/datatable.rb +16 -44
  27. data/app/models/effective/datatable_column.rb +0 -1
  28. data/app/models/effective/datatable_column_tool.rb +1 -1
  29. data/app/models/effective/datatable_dsl_tool.rb +3 -11
  30. data/app/models/effective/datatable_value_tool.rb +23 -23
  31. data/app/models/effective/effective_datatable/attributes.rb +13 -5
  32. data/app/models/effective/effective_datatable/collection.rb +3 -18
  33. data/app/models/effective/effective_datatable/compute.rb +6 -17
  34. data/app/models/effective/effective_datatable/cookie.rb +20 -19
  35. data/app/models/effective/effective_datatable/dsl.rb +3 -8
  36. data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +25 -14
  37. data/app/models/effective/effective_datatable/dsl/datatable.rb +28 -70
  38. data/app/models/effective/effective_datatable/dsl/filters.rb +5 -5
  39. data/app/models/effective/effective_datatable/format.rb +50 -95
  40. data/app/models/effective/effective_datatable/params.rb +3 -8
  41. data/app/models/effective/effective_datatable/resource.rb +76 -137
  42. data/app/models/effective/effective_datatable/state.rb +15 -30
  43. data/app/views/effective/datatables/_actions_column.html.haml +8 -1
  44. data/app/views/effective/datatables/_bulk_actions_column.html.haml +1 -1
  45. data/app/views/effective/datatables/_filters.html.haml +11 -12
  46. data/app/views/effective/datatables/_resource_column.html.haml +8 -11
  47. data/config/effective_datatables.rb +14 -12
  48. data/config/routes.rb +0 -1
  49. data/lib/effective_datatables.rb +4 -57
  50. data/lib/effective_datatables/engine.rb +1 -1
  51. data/lib/effective_datatables/version.rb +1 -1
  52. metadata +20 -30
  53. data/app/assets/images/dataTables/sort_asc.png +0 -0
  54. data/app/assets/images/dataTables/sort_both.png +0 -0
  55. data/app/assets/images/dataTables/sort_desc.png +0 -0
  56. data/app/assets/javascripts/dataTables/dataTables.bootstrap.js +0 -182
  57. data/app/assets/javascripts/dataTables/locales/en.lang +0 -33
  58. data/app/assets/javascripts/dataTables/locales/es.lang +0 -36
  59. data/app/assets/javascripts/dataTables/locales/nl.lang +0 -30
  60. data/app/assets/javascripts/effective_datatables/flash.js.coffee +0 -31
  61. data/app/assets/javascripts/effective_datatables/inline_crud.js.coffee +0 -217
  62. data/app/assets/javascripts/effective_datatables/overrides.js.coffee +0 -7
  63. data/app/assets/javascripts/effective_datatables/reorder.js.coffee +0 -43
  64. data/app/assets/stylesheets/effective_datatables/_filters.scss +0 -7
  65. data/app/views/effective/datatables/_reorder_column.html.haml +0 -5
  66. data/config/locales/en.yml +0 -12
  67. data/config/locales/es.yml +0 -12
  68. data/config/locales/nl.yml +0 -12
@@ -42,7 +42,7 @@ div.dataTables_wrapper div.dataTables_filter input {
42
42
  width: auto;
43
43
  }
44
44
  div.dataTables_wrapper div.dataTables_info {
45
- padding-top: 8px;
45
+ padding-top: 0.85em;
46
46
  white-space: nowrap;
47
47
  }
48
48
  div.dataTables_wrapper div.dataTables_paginate {
@@ -53,6 +53,7 @@ div.dataTables_wrapper div.dataTables_paginate {
53
53
  div.dataTables_wrapper div.dataTables_paginate ul.pagination {
54
54
  margin: 2px 0;
55
55
  white-space: nowrap;
56
+ justify-content: flex-end;
56
57
  }
57
58
  div.dataTables_wrapper div.dataTables_processing {
58
59
  position: absolute;
@@ -83,52 +84,61 @@ table.dataTable thead .sorting_desc_disabled {
83
84
  cursor: pointer;
84
85
  position: relative;
85
86
  }
86
- table.dataTable thead .sorting:after,
87
+ table.dataTable thead .sorting:before, table.dataTable thead .sorting:after,
88
+ table.dataTable thead .sorting_asc:before,
87
89
  table.dataTable thead .sorting_asc:after,
90
+ table.dataTable thead .sorting_desc:before,
88
91
  table.dataTable thead .sorting_desc:after,
92
+ table.dataTable thead .sorting_asc_disabled:before,
89
93
  table.dataTable thead .sorting_asc_disabled:after,
94
+ table.dataTable thead .sorting_desc_disabled:before,
90
95
  table.dataTable thead .sorting_desc_disabled:after {
91
96
  position: absolute;
92
- bottom: 8px;
93
- right: 8px;
97
+ bottom: 0.9em;
94
98
  display: block;
95
- font-family: 'Glyphicons Halflings';
96
- opacity: 0.5;
99
+ opacity: 0.3;
97
100
  }
98
- table.dataTable thead .sorting:after {
99
- opacity: 0.2;
100
- content: "\e150";
101
- /* sort */
101
+ table.dataTable thead .sorting:before,
102
+ table.dataTable thead .sorting_asc:before,
103
+ table.dataTable thead .sorting_desc:before,
104
+ table.dataTable thead .sorting_asc_disabled:before,
105
+ table.dataTable thead .sorting_desc_disabled:before {
106
+ right: 1em;
107
+ content: "\2191";
102
108
  }
103
- table.dataTable thead .sorting_asc:after {
104
- content: "\e155";
105
- /* sort-by-attributes */
109
+ table.dataTable thead .sorting:after,
110
+ table.dataTable thead .sorting_asc:after,
111
+ table.dataTable thead .sorting_desc:after,
112
+ table.dataTable thead .sorting_asc_disabled:after,
113
+ table.dataTable thead .sorting_desc_disabled:after {
114
+ right: 0.5em;
115
+ content: "\2193";
106
116
  }
117
+ table.dataTable thead .sorting_asc:before,
107
118
  table.dataTable thead .sorting_desc:after {
108
- content: "\e156";
109
- /* sort-by-attributes-alt */
119
+ opacity: 1;
110
120
  }
111
- table.dataTable thead .sorting_asc_disabled:after,
121
+ table.dataTable thead .sorting_asc_disabled:before,
112
122
  table.dataTable thead .sorting_desc_disabled:after {
113
- color: #eee;
123
+ opacity: 0;
114
124
  }
115
125
 
116
126
  div.dataTables_scrollHead table.dataTable {
117
127
  margin-bottom: 0 !important;
118
128
  }
119
129
 
120
- div.dataTables_scrollBody > table {
130
+ div.dataTables_scrollBody table {
121
131
  border-top: none;
122
132
  margin-top: 0 !important;
123
133
  margin-bottom: 0 !important;
124
134
  }
125
- div.dataTables_scrollBody > table > thead .sorting:after,
126
- div.dataTables_scrollBody > table > thead .sorting_asc:after,
127
- div.dataTables_scrollBody > table > thead .sorting_desc:after {
135
+ div.dataTables_scrollBody table thead .sorting:after,
136
+ div.dataTables_scrollBody table thead .sorting_asc:after,
137
+ div.dataTables_scrollBody table thead .sorting_desc:after {
128
138
  display: none;
129
139
  }
130
- div.dataTables_scrollBody > table > tbody > tr:first-child > th,
131
- div.dataTables_scrollBody > table > tbody > tr:first-child > td {
140
+ div.dataTables_scrollBody table tbody tr:first-child th,
141
+ div.dataTables_scrollBody table tbody tr:first-child td {
132
142
  border-top: none;
133
143
  }
134
144
 
@@ -148,14 +158,19 @@ div.dataTables_scrollFoot > .dataTables_scrollFootInner > table {
148
158
  text-align: center;
149
159
  }
150
160
  }
151
- table.dataTable.table-condensed > thead > tr > th {
161
+ table.dataTable.table-sm > thead > tr > th {
152
162
  padding-right: 20px;
153
163
  }
154
- table.dataTable.table-condensed .sorting:after,
155
- table.dataTable.table-condensed .sorting_asc:after,
156
- table.dataTable.table-condensed .sorting_desc:after {
157
- top: 6px;
158
- right: 6px;
164
+ table.dataTable.table-sm .sorting:before,
165
+ table.dataTable.table-sm .sorting_asc:before,
166
+ table.dataTable.table-sm .sorting_desc:before {
167
+ top: 5px;
168
+ right: 0.85em;
169
+ }
170
+ table.dataTable.table-sm .sorting:after,
171
+ table.dataTable.table-sm .sorting_asc:after,
172
+ table.dataTable.table-sm .sorting_desc:after {
173
+ top: 5px;
159
174
  }
160
175
 
161
176
  table.table-bordered.dataTable th,
@@ -16,7 +16,7 @@ table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child {
16
16
  }
17
17
  table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child:before,
18
18
  table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child:before {
19
- top: 9px;
19
+ top: 12px;
20
20
  left: 4px;
21
21
  height: 14px;
22
22
  width: 14px;
@@ -32,7 +32,7 @@ table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child:b
32
32
  font-family: 'Courier New', Courier, monospace;
33
33
  line-height: 14px;
34
34
  content: '+';
35
- background-color: #337ab7;
35
+ background-color: #0275d8;
36
36
  }
37
37
  table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child:before,
38
38
  table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th:first-child:before {
@@ -78,7 +78,7 @@ table.dataTable.dtr-column > tbody > tr > th.control:before {
78
78
  font-family: 'Courier New', Courier, monospace;
79
79
  line-height: 14px;
80
80
  content: '+';
81
- background-color: #337ab7;
81
+ background-color: #0275d8;
82
82
  }
83
83
  table.dataTable.dtr-column > tbody > tr.parent td.control:before,
84
84
  table.dataTable.dtr-column > tbody > tr.parent th.control:before {
@@ -1,7 +1,6 @@
1
- @import 'dataTables/dataTables.bootstrap';
1
+ @import 'dataTables/dataTables.bootstrap4';
2
2
 
3
- @import 'dataTables/buttons/buttons.bootstrap';
4
- @import 'dataTables/responsive/responsive.bootstrap';
3
+ @import 'dataTables/buttons/buttons.bootstrap4';
4
+ @import 'dataTables/responsive/responsive.bootstrap4';
5
5
 
6
- @import 'effective_datatables/filters';
7
6
  @import 'effective_datatables/overrides';
@@ -1,73 +1,91 @@
1
- // Use asset-data-url to prevent 3 additional GET requests for icons
2
- table.dataTable thead .sorting {
3
- background-image: asset-data-url('dataTables/sort_both.png');
4
- background-position: right 0px bottom 14px;
1
+ // Override dataTables.bootstrap4.css defaults
2
+ table.dataTable { border-collapse: collapse !important; }
3
+
4
+ // Override default padding
5
+ table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc, table.dataTable thead > tr > th.sorting,
6
+ table.dataTable thead > tr > td.sorting_asc,
7
+ table.dataTable thead > tr > td.sorting_desc,
8
+ table.dataTable thead > tr > td.sorting { padding: 0.5em 0.5em 0.5em 0.5em; }
9
+
10
+ // Override default sort icons
11
+ table.dataTable thead .sorting:before,
12
+ table.dataTable thead .sorting_asc:before,
13
+ table.dataTable thead .sorting_desc:before,
14
+ table.dataTable thead .sorting_asc_disabled:before,
15
+ table.dataTable thead .sorting_desc_disabled:before,
16
+ table.dataTable thead .sorting:after,
17
+ table.dataTable thead .sorting_asc:after,
18
+ table.dataTable thead .sorting_desc:after,
19
+ table.dataTable thead .sorting_asc_disabled:after,
20
+ table.dataTable thead .sorting_desc_disabled:after { content: ''; }
21
+
22
+ table.dataTable > thead th {
23
+ vertical-align: top;
24
+ background-repeat: no-repeat;
25
+
26
+ > span { padding-right: 1rem; }
5
27
  }
6
28
 
7
- table.dataTable thead .sorting_asc {
8
- background-image: asset-data-url('dataTables/sort_asc.png');
9
- background-position: right 0px bottom 14px;
29
+ table.dataTable > thead .sorting {
30
+ background-image: asset-data-url('dataTables/sort.svg');
31
+ background-position: right 0.25rem top 0.25rem;
10
32
  }
11
33
 
12
- table.dataTable thead .sorting_desc {
13
- background-image: asset-data-url('dataTables/sort_desc.png');
14
- background-position: right 0px bottom 14px;
34
+ table.dataTable > thead .sorting_asc {
35
+ background-image: asset-data-url('dataTables/sort-up.svg');
36
+ background-position: right 0.25rem top 0.25rem;
15
37
  }
16
38
 
17
- // Override bootstrap default glyphicons
18
- table.dataTable thead .sorting:after { content: ''; }
19
- table.dataTable thead .sorting_asc:after { content: ''; }
20
- table.dataTable thead .sorting_desc:after { content: ''; }
39
+ table.dataTable > thead .sorting_desc {
40
+ background-image: asset-data-url('dataTables/sort-down.svg');
41
+ background-position: right 0.25rem top 0.25rem;
42
+ }
21
43
 
22
- // Table header
23
- table.dataTable thead > tr > th.sorting_asc,
24
- table.dataTable thead > tr > th.sorting_desc,
25
- table.dataTable thead > tr > th.sorting {
26
- background-repeat: no-repeat;
27
- padding-right: 18px;
44
+ // Collapsed Responsive View
45
+ table.dataTable > tbody > tr.child {
46
+ td, th { border: none; }
47
+
48
+ ul.dtr-details > li {
49
+ border-bottom: none;
50
+ padding-left: 0.5em;
51
+
52
+ &:hover { background-color: rgba(0, 0, 0, 0.075); }
53
+
54
+ span.dtr-title { min-width: 175px; margin-bottom: 0.25em; }
55
+ span.dtr-data { white-space: nowrap; }
56
+ .col-resource_item { margin-bottom: 0.25em; }
57
+ }
58
+ }
59
+
60
+ // Buttons
61
+ .dataTables_buttons {
62
+ text-align: right;
63
+ .btn { font-size: 0.75rem; }
28
64
  }
29
65
 
30
66
  // Search bar
31
- table.dataTable thead {
67
+ table.dataTable > thead {
32
68
  tr th {
33
- text-align: left;
34
- vertical-align: top;
35
69
  border-bottom: none;
36
70
  white-space: nowrap;
37
- padding: 6px;
38
71
 
39
- span { display: block; }
40
- }
72
+ .form-group {
73
+ font-weight: normal;
74
+ margin-bottom: 0em;
41
75
 
42
- .form-control, .form-group {
43
- width: 100%;
44
- font-weight: normal;
45
- margin: 0px;
76
+ input { max-height: 38px; }
77
+ }
46
78
  }
47
-
48
- .datatable_search__bulk_actions { margin-left: 5px; }
49
79
  }
50
80
 
51
81
  // Simple styles
52
- table.dataTable.simple {
53
- thead {
54
- .sorting { background-image: none; cursor: default; }
55
- .sorting_asc { background-image: none; cursor: default; }
56
- .sorting_desc { background-image: none; cursor: default; }
57
-
58
- .form-group { display: none; }
59
- .col-bulk_actions { display: none; }
60
- }
61
- }
82
+ table.dataTable.simple > thead {
83
+ .sorting { background-image: none; cursor: default; }
84
+ .sorting_asc { background-image: none; cursor: default; }
85
+ .sorting_desc { background-image: none; cursor: default; }
62
86
 
63
- // Processing popup
64
- div.dataTables_wrapper div.dataTables_processing {
65
- top: -10px;
66
- border: none;
67
- box-shadow: none;
68
- margin-left: -35%;
69
- margin-bottom: 0;
70
- width: 70%;
87
+ .form-group { display: none; }
88
+ .col-bulk_actions { display: none; }
71
89
  }
72
90
 
73
91
  // Datatables entries
@@ -82,7 +100,7 @@ div.dataTables_wrapper div.dataTables_processing {
82
100
  // Showing 1 to 2 of 2 entries (filtered from 10 total entries)
83
101
  div.dataTables_info {
84
102
  display: inline-block;
85
- padding: 5px 0px 6px 6px;
103
+ padding: 0.25em 0em 0.25em 0.25em;
86
104
  }
87
105
 
88
106
  // with 25 per page
@@ -95,7 +113,7 @@ div.dataTables_wrapper div.dataTables_processing {
95
113
  max-width: 45px;
96
114
 
97
115
  .select2-selection { border: none; }
98
- .select2-selection__rendered { padding: 0px; color: #909090; }
116
+ .select2-selection__rendered { padding: 0em; color: #909090; }
99
117
  }
100
118
 
101
119
  span.select2-container.select2-container--open { max-width: 60px; }
@@ -104,80 +122,8 @@ div.dataTables_wrapper div.dataTables_processing {
104
122
  }
105
123
  }
106
124
 
107
- // Buttons
108
- div.dt-buttons {
109
- float: right;
110
- display: inherit;
111
- width: auto;
112
- }
113
-
114
- .dt-buttons {
115
- a, button {
116
- border: none;
117
- color: #337ab7;
118
- border-color: transparent;
119
- background: #fff;
120
- font-size: 12px;
121
- padding: 6px;
122
- margin-right: 6px;
123
- float: none;
124
-
125
- &:hover,
126
- &:focus {
127
- border: none;
128
- border-color: transparent;
129
- background: #eee !important;
130
- }
131
-
132
- &:last-child { margin-right: 0px; }
133
-
134
- &.active {
135
- color: #fff;
136
- background: #03428d !important;
137
- }
138
-
139
- .caret {
140
- margin-bottom: 4px;
141
- }
142
- }
143
- }
144
-
145
- // Show / hide columns button
146
- ul.dt-button-collection {
147
- width: 400px;
148
-
149
- li {
150
- width: 198px;
151
- overflow: hidden;
152
- }
153
-
154
- li:nth-child(odd) {
155
- float: left;
156
- }
157
-
158
- li:nth-child(even) {
159
- float: right;
160
- }
161
-
162
- .buttons-colvisGroup {
163
- clear: left;
164
- border-top: 1px solid grey;
165
- }
166
-
167
- .buttons-colvisRestore {
168
- border-top: 1px solid grey;
169
- }
170
- }
171
-
172
- // Collapsed Responsive View
173
- table.dataTable > tbody > tr.child {
174
- span.dtr-title { min-width: 175px; margin-bottom: 4px; }
175
- span.dtr-data { white-space: nowrap; }
176
- .col-resource_item { margin-bottom: 4px; }
177
- }
178
-
179
125
  // Column specific adjustments
180
- table.dataTable {
126
+ table.dataTable > tbody {
181
127
  td.col-price { text-align: right; }
182
128
  td.col-decimal { text-align: right; }
183
129
  td.col-right { text-align: right; }
@@ -193,32 +139,6 @@ table.dataTable {
193
139
  td.col-resource_item { word-break: keep-all; }
194
140
 
195
141
  td {
196
- p { margin-bottom: 0px; }
142
+ p { margin-bottom: 0em; }
197
143
  }
198
144
  }
199
-
200
- // Simple styles
201
- table.dataTable.hide-sort > thead {
202
- .sorting { background-image: none; cursor: default; }
203
- .sorting_asc { background-image: none; cursor: default; }
204
- .sorting_desc { background-image: none; cursor: default; }
205
- }
206
-
207
- table.dataTable.hide-search > thead {
208
- .form-group { display: none; }
209
- }
210
-
211
- table.dataTable.hide-buttons {
212
- .col-bulk_actions { display: none; }
213
- }
214
-
215
- // Datatables entries
216
- @media screen and (max-width: 767px) {
217
- div.dataTables_wrapper div.dataTables_entries { text-align: center; }
218
- }
219
-
220
- .dataTables_buttons {
221
- .buttons-bulk-actions {
222
- button { font-size: 12px; }
223
- }
224
- }
@@ -5,7 +5,7 @@ module Effective
5
5
  # This will respond to both a GET and a POST
6
6
  def show
7
7
  begin
8
- @datatable = EffectiveDatatables.find(params[:id], params[:attributes])
8
+ @datatable = find_datatable(params[:id]).try(:new) || raise('unable to find datatable')
9
9
  @datatable.view = view_context
10
10
 
11
11
  EffectiveDatatables.authorize!(self, :index, @datatable.collection_class)
@@ -13,51 +13,18 @@ module Effective
13
13
  render json: @datatable.to_json
14
14
  rescue => e
15
15
  EffectiveDatatables.authorized?(self, :index, @datatable.try(:collection_class))
16
- render json: error_json(e)
17
16
 
18
- ExceptionNotifier.notify_exception(e) if defined?(ExceptionNotifier)
19
- raise e if Rails.env.development?
17
+ render json: error_json(e)
20
18
  end
21
19
  end
22
20
 
23
- def reorder
24
- begin
25
- @datatable = EffectiveDatatables.find(params[:id], params[:attributes])
26
- @datatable.view = view_context
27
-
28
- EffectiveDatatables.authorize!(self, :index, @datatable.collection_class)
29
-
30
- @resource = @datatable.collection.find(params[:reorder][:id])
31
-
32
- EffectiveDatatables.authorize!(self, :update, @resource)
33
-
34
- attribute = @datatable.columns[:_reorder][:reorder]
35
- old_index = params[:reorder][:old].to_i
36
- new_index = params[:reorder][:new].to_i
37
-
38
- @resource.class.transaction do
39
- if new_index > old_index
40
- @datatable.collection.where("#{attribute} > ? AND #{attribute} <= ?", old_index, new_index).update_all("#{attribute} = #{attribute} - 1")
41
- @resource.update_column(attribute, new_index)
42
- end
43
-
44
- if old_index > new_index
45
- @datatable.collection.where("#{attribute} >= ? AND #{attribute} < ?", new_index, old_index).update_all("#{attribute} = #{attribute} + 1")
46
- @resource.update_column(attribute, new_index)
47
- end
48
- end
49
-
50
- render status: :ok, body: :ok
51
- rescue Effective::AccessDenied => e
52
- render(status: :unauthorized, body: 'Access Denied')
53
- rescue => e
54
- render(status: :error, body: 'Unexpected Error')
55
- end
21
+ private
56
22
 
23
+ def find_datatable(id)
24
+ id = id.to_s.gsub(/-\d{12}\z/, '').gsub('-', '/')
25
+ id.classify.safe_constantize || id.classify.pluralize.safe_constantize
57
26
  end
58
27
 
59
- private
60
-
61
28
  def error_json(e)
62
29
  {
63
30
  data: [],