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.
- checksums.yaml +5 -5
- data/MIT-LICENSE +1 -1
- data/README.md +32 -32
- data/app/assets/images/dataTables/sort-down.svg +1 -0
- data/app/assets/images/dataTables/sort-up.svg +1 -0
- data/app/assets/images/dataTables/sort.svg +1 -0
- data/app/assets/javascripts/dataTables/buttons/{buttons.bootstrap.js → buttons.bootstrap4.js} +7 -15
- data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +184 -0
- data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +30 -11
- data/app/assets/javascripts/dataTables/responsive/{responsive.bootstrap.js → responsive.bootstrap4.js} +6 -6
- data/app/assets/javascripts/effective_datatables.js +4 -4
- data/app/assets/javascripts/effective_datatables/bulk_actions.js.coffee +43 -43
- data/app/assets/javascripts/effective_datatables/events.js.coffee +7 -4
- data/app/assets/javascripts/effective_datatables/filters.js.coffee +0 -1
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +45 -49
- data/app/assets/javascripts/effective_datatables/overrides.js +12 -0
- data/app/assets/javascripts/effective_datatables/reset.js.coffee +1 -1
- data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.scss → buttons.bootstrap4.css} +68 -1
- data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.scss → dataTables.bootstrap4.css} +44 -29
- data/app/assets/stylesheets/dataTables/responsive/{responsive.bootstrap.scss → responsive.bootstrap4.css} +3 -3
- data/app/assets/stylesheets/effective_datatables.scss +3 -4
- data/app/assets/stylesheets/effective_datatables/_overrides.scss +72 -152
- data/app/controllers/effective/datatables_controller.rb +6 -39
- data/app/helpers/effective_datatables_helper.rb +55 -50
- data/app/helpers/effective_datatables_private_helper.rb +47 -179
- data/app/models/effective/datatable.rb +16 -44
- data/app/models/effective/datatable_column.rb +0 -1
- data/app/models/effective/datatable_column_tool.rb +1 -1
- data/app/models/effective/datatable_dsl_tool.rb +3 -11
- data/app/models/effective/datatable_value_tool.rb +23 -23
- data/app/models/effective/effective_datatable/attributes.rb +13 -5
- data/app/models/effective/effective_datatable/collection.rb +3 -18
- data/app/models/effective/effective_datatable/compute.rb +6 -17
- data/app/models/effective/effective_datatable/cookie.rb +20 -19
- data/app/models/effective/effective_datatable/dsl.rb +3 -8
- data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +25 -14
- data/app/models/effective/effective_datatable/dsl/datatable.rb +28 -70
- data/app/models/effective/effective_datatable/dsl/filters.rb +5 -5
- data/app/models/effective/effective_datatable/format.rb +50 -95
- data/app/models/effective/effective_datatable/params.rb +3 -8
- data/app/models/effective/effective_datatable/resource.rb +76 -137
- data/app/models/effective/effective_datatable/state.rb +15 -30
- data/app/views/effective/datatables/_actions_column.html.haml +8 -1
- data/app/views/effective/datatables/_bulk_actions_column.html.haml +1 -1
- data/app/views/effective/datatables/_filters.html.haml +11 -12
- data/app/views/effective/datatables/_resource_column.html.haml +8 -11
- data/config/effective_datatables.rb +14 -12
- data/config/routes.rb +0 -1
- data/lib/effective_datatables.rb +4 -57
- data/lib/effective_datatables/engine.rb +1 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +20 -30
- data/app/assets/images/dataTables/sort_asc.png +0 -0
- data/app/assets/images/dataTables/sort_both.png +0 -0
- data/app/assets/images/dataTables/sort_desc.png +0 -0
- data/app/assets/javascripts/dataTables/dataTables.bootstrap.js +0 -182
- data/app/assets/javascripts/dataTables/locales/en.lang +0 -33
- data/app/assets/javascripts/dataTables/locales/es.lang +0 -36
- data/app/assets/javascripts/dataTables/locales/nl.lang +0 -30
- data/app/assets/javascripts/effective_datatables/flash.js.coffee +0 -31
- data/app/assets/javascripts/effective_datatables/inline_crud.js.coffee +0 -217
- data/app/assets/javascripts/effective_datatables/overrides.js.coffee +0 -7
- data/app/assets/javascripts/effective_datatables/reorder.js.coffee +0 -43
- data/app/assets/stylesheets/effective_datatables/_filters.scss +0 -7
- data/app/views/effective/datatables/_reorder_column.html.haml +0 -5
- data/config/locales/en.yml +0 -12
- data/config/locales/es.yml +0 -12
- data/config/locales/nl.yml +0 -12
data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.scss → dataTables.bootstrap4.css}
RENAMED
@@ -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:
|
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:
|
93
|
-
right: 8px;
|
97
|
+
bottom: 0.9em;
|
94
98
|
display: block;
|
95
|
-
|
96
|
-
opacity: 0.5;
|
99
|
+
opacity: 0.3;
|
97
100
|
}
|
98
|
-
table.dataTable thead .sorting:
|
99
|
-
|
100
|
-
|
101
|
-
|
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 .
|
104
|
-
|
105
|
-
|
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
|
-
|
109
|
-
/* sort-by-attributes-alt */
|
119
|
+
opacity: 1;
|
110
120
|
}
|
111
|
-
table.dataTable thead .sorting_asc_disabled:
|
121
|
+
table.dataTable thead .sorting_asc_disabled:before,
|
112
122
|
table.dataTable thead .sorting_desc_disabled:after {
|
113
|
-
|
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
|
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
|
126
|
-
div.dataTables_scrollBody
|
127
|
-
div.dataTables_scrollBody
|
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
|
131
|
-
div.dataTables_scrollBody
|
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-
|
161
|
+
table.dataTable.table-sm > thead > tr > th {
|
152
162
|
padding-right: 20px;
|
153
163
|
}
|
154
|
-
table.dataTable.table-
|
155
|
-
table.dataTable.table-
|
156
|
-
table.dataTable.table-
|
157
|
-
top:
|
158
|
-
right:
|
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:
|
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: #
|
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: #
|
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.
|
1
|
+
@import 'dataTables/dataTables.bootstrap4';
|
2
2
|
|
3
|
-
@import 'dataTables/buttons/buttons.
|
4
|
-
@import 'dataTables/responsive/responsive.
|
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
|
-
//
|
2
|
-
table.dataTable
|
3
|
-
|
4
|
-
|
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 .
|
8
|
-
background-image: asset-data-url('dataTables/
|
9
|
-
background-position: right
|
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 .
|
13
|
-
background-image: asset-data-url('dataTables/
|
14
|
-
background-position: right
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
//
|
23
|
-
table.dataTable
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
40
|
-
|
72
|
+
.form-group {
|
73
|
+
font-weight: normal;
|
74
|
+
margin-bottom: 0em;
|
41
75
|
|
42
|
-
|
43
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
64
|
-
|
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:
|
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:
|
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:
|
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 =
|
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
|
-
|
19
|
-
raise e if Rails.env.development?
|
17
|
+
render json: error_json(e)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
|
-
|
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: [],
|