effective_datatables 3.7.7 → 4.0.0
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 +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
Binary file
|
Binary file
|
Binary file
|
@@ -1,182 +0,0 @@
|
|
1
|
-
/*! DataTables Bootstrap 3 integration
|
2
|
-
* ©2011-2015 SpryMedia Ltd - datatables.net/license
|
3
|
-
*/
|
4
|
-
|
5
|
-
/**
|
6
|
-
* DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
|
7
|
-
* DataTables 1.10 or newer.
|
8
|
-
*
|
9
|
-
* This file sets the defaults and adds options to DataTables to style its
|
10
|
-
* controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
|
11
|
-
* for further information.
|
12
|
-
*/
|
13
|
-
(function( factory ){
|
14
|
-
if ( typeof define === 'function' && define.amd ) {
|
15
|
-
// AMD
|
16
|
-
define( ['jquery', 'datatables.net'], function ( $ ) {
|
17
|
-
return factory( $, window, document );
|
18
|
-
} );
|
19
|
-
}
|
20
|
-
else if ( typeof exports === 'object' ) {
|
21
|
-
// CommonJS
|
22
|
-
module.exports = function (root, $) {
|
23
|
-
if ( ! root ) {
|
24
|
-
root = window;
|
25
|
-
}
|
26
|
-
|
27
|
-
if ( ! $ || ! $.fn.dataTable ) {
|
28
|
-
// Require DataTables, which attaches to jQuery, including
|
29
|
-
// jQuery if needed and have a $ property so we can access the
|
30
|
-
// jQuery object that is used
|
31
|
-
$ = require('datatables.net')(root, $).$;
|
32
|
-
}
|
33
|
-
|
34
|
-
return factory( $, root, root.document );
|
35
|
-
};
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
// Browser
|
39
|
-
factory( jQuery, window, document );
|
40
|
-
}
|
41
|
-
}(function( $, window, document, undefined ) {
|
42
|
-
'use strict';
|
43
|
-
var DataTable = $.fn.dataTable;
|
44
|
-
|
45
|
-
|
46
|
-
/* Set the defaults for DataTables initialisation */
|
47
|
-
$.extend( true, DataTable.defaults, {
|
48
|
-
dom:
|
49
|
-
"<'row'<'col-sm-6'l><'col-sm-6'f>>" +
|
50
|
-
"<'row'<'col-sm-12'tr>>" +
|
51
|
-
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
52
|
-
renderer: 'bootstrap'
|
53
|
-
} );
|
54
|
-
|
55
|
-
|
56
|
-
/* Default class modification */
|
57
|
-
$.extend( DataTable.ext.classes, {
|
58
|
-
sWrapper: "dataTables_wrapper form-inline dt-bootstrap",
|
59
|
-
sFilterInput: "form-control input-sm",
|
60
|
-
sLengthSelect: "form-control input-sm",
|
61
|
-
sProcessing: "dataTables_processing panel panel-default"
|
62
|
-
} );
|
63
|
-
|
64
|
-
|
65
|
-
/* Bootstrap paging button renderer */
|
66
|
-
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
|
67
|
-
var api = new DataTable.Api( settings );
|
68
|
-
var classes = settings.oClasses;
|
69
|
-
var lang = settings.oLanguage.oPaginate;
|
70
|
-
var aria = settings.oLanguage.oAria.paginate || {};
|
71
|
-
var btnDisplay, btnClass, counter=0;
|
72
|
-
|
73
|
-
var attach = function( container, buttons ) {
|
74
|
-
var i, ien, node, button;
|
75
|
-
var clickHandler = function ( e ) {
|
76
|
-
e.preventDefault();
|
77
|
-
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
|
78
|
-
api.page( e.data.action ).draw( 'page' );
|
79
|
-
}
|
80
|
-
};
|
81
|
-
|
82
|
-
for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
|
83
|
-
button = buttons[i];
|
84
|
-
|
85
|
-
if ( $.isArray( button ) ) {
|
86
|
-
attach( container, button );
|
87
|
-
}
|
88
|
-
else {
|
89
|
-
btnDisplay = '';
|
90
|
-
btnClass = '';
|
91
|
-
|
92
|
-
switch ( button ) {
|
93
|
-
case 'ellipsis':
|
94
|
-
btnDisplay = '…';
|
95
|
-
btnClass = 'disabled';
|
96
|
-
break;
|
97
|
-
|
98
|
-
case 'first':
|
99
|
-
btnDisplay = lang.sFirst;
|
100
|
-
btnClass = button + (page > 0 ?
|
101
|
-
'' : ' disabled');
|
102
|
-
break;
|
103
|
-
|
104
|
-
case 'previous':
|
105
|
-
btnDisplay = lang.sPrevious;
|
106
|
-
btnClass = button + (page > 0 ?
|
107
|
-
'' : ' disabled');
|
108
|
-
break;
|
109
|
-
|
110
|
-
case 'next':
|
111
|
-
btnDisplay = lang.sNext;
|
112
|
-
btnClass = button + (page < pages-1 ?
|
113
|
-
'' : ' disabled');
|
114
|
-
break;
|
115
|
-
|
116
|
-
case 'last':
|
117
|
-
btnDisplay = lang.sLast;
|
118
|
-
btnClass = button + (page < pages-1 ?
|
119
|
-
'' : ' disabled');
|
120
|
-
break;
|
121
|
-
|
122
|
-
default:
|
123
|
-
btnDisplay = button + 1;
|
124
|
-
btnClass = page === button ?
|
125
|
-
'active' : '';
|
126
|
-
break;
|
127
|
-
}
|
128
|
-
|
129
|
-
if ( btnDisplay ) {
|
130
|
-
node = $('<li>', {
|
131
|
-
'class': classes.sPageButton+' '+btnClass,
|
132
|
-
'id': idx === 0 && typeof button === 'string' ?
|
133
|
-
settings.sTableId +'_'+ button :
|
134
|
-
null
|
135
|
-
} )
|
136
|
-
.append( $('<a>', {
|
137
|
-
'href': '#',
|
138
|
-
'aria-controls': settings.sTableId,
|
139
|
-
'aria-label': aria[ button ],
|
140
|
-
'data-dt-idx': counter,
|
141
|
-
'tabindex': settings.iTabIndex
|
142
|
-
} )
|
143
|
-
.html( btnDisplay )
|
144
|
-
)
|
145
|
-
.appendTo( container );
|
146
|
-
|
147
|
-
settings.oApi._fnBindAction(
|
148
|
-
node, {action: button}, clickHandler
|
149
|
-
);
|
150
|
-
|
151
|
-
counter++;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
};
|
156
|
-
|
157
|
-
// IE9 throws an 'unknown error' if document.activeElement is used
|
158
|
-
// inside an iframe or frame.
|
159
|
-
var activeEl;
|
160
|
-
|
161
|
-
try {
|
162
|
-
// Because this approach is destroying and recreating the paging
|
163
|
-
// elements, focus is lost on the select button which is bad for
|
164
|
-
// accessibility. So we want to restore focus once the draw has
|
165
|
-
// completed
|
166
|
-
activeEl = $(host).find(document.activeElement).data('dt-idx');
|
167
|
-
}
|
168
|
-
catch (e) {}
|
169
|
-
|
170
|
-
attach(
|
171
|
-
$(host).empty().html('<ul class="pagination"/>').children('ul'),
|
172
|
-
buttons
|
173
|
-
);
|
174
|
-
|
175
|
-
if ( activeEl !== undefined ) {
|
176
|
-
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
|
177
|
-
}
|
178
|
-
};
|
179
|
-
|
180
|
-
|
181
|
-
return DataTable;
|
182
|
-
}));
|
@@ -1,33 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* English - this is the default DataTables ships with
|
3
|
-
* @name English
|
4
|
-
* @anchor English
|
5
|
-
* @author <a href="http://www.sprymedia.co.uk/">Allan Jardine</a>
|
6
|
-
*/
|
7
|
-
|
8
|
-
{
|
9
|
-
"sEmptyTable": "No data available in table",
|
10
|
-
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
|
11
|
-
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
|
12
|
-
"sInfoFiltered": "(filtered from _MAX_ total entries)",
|
13
|
-
"sInfoPostFix": "",
|
14
|
-
"sInfoThousands": ",",
|
15
|
-
"sLengthMenu": " with _MENU_ per page",
|
16
|
-
"sLoadingRecords": "Loading...",
|
17
|
-
"sProcessing": "Processing...",
|
18
|
-
"sSearch": "Search:",
|
19
|
-
"sZeroRecords": "No matching records found",
|
20
|
-
"oPaginate": {
|
21
|
-
"sFirst": "First",
|
22
|
-
"sLast": "Last",
|
23
|
-
"sNext": "Next",
|
24
|
-
"sPrevious": "Previous"
|
25
|
-
},
|
26
|
-
"oAria": {
|
27
|
-
"sSortAscending": ": activate to sort column ascending",
|
28
|
-
"sSortDescending": ": activate to sort column descending"
|
29
|
-
},
|
30
|
-
"buttons": {
|
31
|
-
"colvis": "Show / Hide"
|
32
|
-
}
|
33
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Spanish translation
|
3
|
-
* @name Spanish
|
4
|
-
* @anchor Spanish
|
5
|
-
* @author Giovanni Ariza, Aristobulo Gomez and Roberto Poo
|
6
|
-
*/
|
7
|
-
|
8
|
-
{
|
9
|
-
"sProcessing": "Procesando...",
|
10
|
-
"sLengthMenu": "Mostrar _MENU_ registros",
|
11
|
-
"sZeroRecords": "No se encontraron resultados",
|
12
|
-
"sEmptyTable": "Ningún dato disponible en esta tabla =(",
|
13
|
-
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
|
14
|
-
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
|
15
|
-
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
|
16
|
-
"sLengthMenu": " con _MENU_ por página",
|
17
|
-
"sInfoPostFix": "",
|
18
|
-
"sSearch": "Buscar:",
|
19
|
-
"sUrl": "",
|
20
|
-
"sInfoThousands": ",",
|
21
|
-
"sLoadingRecords": "Cargando...",
|
22
|
-
"oPaginate": {
|
23
|
-
"sFirst": "Primero",
|
24
|
-
"sLast": "Último",
|
25
|
-
"sNext": "Siguiente",
|
26
|
-
"sPrevious": "Anterior"
|
27
|
-
},
|
28
|
-
"oAria": {
|
29
|
-
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
|
30
|
-
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
|
31
|
-
},
|
32
|
-
"buttons": {
|
33
|
-
"copy": "Copiar",
|
34
|
-
"colvis": "Mostrar/Ocultar"
|
35
|
-
}
|
36
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Dutch translation
|
3
|
-
* @name Dutch
|
4
|
-
* @anchor Dutch
|
5
|
-
* @author <a href="http://www.blikgooien.nl/">Erwin Kerk</a> and <i>ashwin</i>
|
6
|
-
*/
|
7
|
-
|
8
|
-
{
|
9
|
-
"sProcessing": "Bezig...",
|
10
|
-
"sLengthMenu": "_MENU_ resultaten weergeven",
|
11
|
-
"sZeroRecords": "Geen resultaten gevonden",
|
12
|
-
"sInfo": "_START_ tot _END_ van _TOTAL_ resultaten",
|
13
|
-
"sInfoEmpty": "Geen resultaten om weer te geven",
|
14
|
-
"sInfoFiltered": " (gefilterd uit _MAX_ resultaten)",
|
15
|
-
"sInfoPostFix": "",
|
16
|
-
"sSearch": "Zoeken:",
|
17
|
-
"sEmptyTable": "Geen resultaten aanwezig in de tabel",
|
18
|
-
"sInfoThousands": ".",
|
19
|
-
"sLoadingRecords": "Een moment geduld aub - bezig met laden...",
|
20
|
-
"oPaginate": {
|
21
|
-
"sFirst": "Eerste",
|
22
|
-
"sLast": "Laatste",
|
23
|
-
"sNext": "Volgende",
|
24
|
-
"sPrevious": "Vorige"
|
25
|
-
},
|
26
|
-
"oAria": {
|
27
|
-
"sSortAscending": ": activeer om kolom oplopend te sorteren",
|
28
|
-
"sSortDescending": ": activeer om kolom aflopend te sorteren"
|
29
|
-
}
|
30
|
-
}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
flash = (message, status = '') ->
|
2
|
-
@context[0].oFeatures.bProcessing = false
|
3
|
-
|
4
|
-
message ||= 'Processing...'
|
5
|
-
|
6
|
-
if status == 'danger'
|
7
|
-
message = 'Error: ' + message
|
8
|
-
|
9
|
-
$processing = $(@table().node()).siblings('.dataTables_processing')
|
10
|
-
|
11
|
-
if status.length > 0
|
12
|
-
$processing.addClass("alert-#{status}")
|
13
|
-
|
14
|
-
$processing.html(message).show()
|
15
|
-
|
16
|
-
timeout = $processing.data('timeout')
|
17
|
-
clearTimeout(timeout) if timeout
|
18
|
-
|
19
|
-
delay = (if status == 'danger' then 4000 else 1500)
|
20
|
-
|
21
|
-
$processing.html(message).data('timeout', setTimeout( =>
|
22
|
-
$processing.html('Processing...')
|
23
|
-
$processing.removeClass('alert-success alert-info alert-warning alert-danger alert-error')
|
24
|
-
$processing.hide()
|
25
|
-
@context[0].oFeatures.bProcessing = true
|
26
|
-
, delay)
|
27
|
-
)
|
28
|
-
|
29
|
-
return @
|
30
|
-
|
31
|
-
$.fn.DataTable.Api.register('flash()', flash);
|
@@ -1,217 +0,0 @@
|
|
1
|
-
# To achieve inline crud, we use rails' data-remote links, and override their behaviour when inside a datatable
|
2
|
-
# This works with EffectiveForm.remote_form which is part of the effective_bootstrap gem.
|
3
|
-
|
4
|
-
# We click the New/Edit/Action button from the col-actions
|
5
|
-
$(document).on 'ajax:beforeSend', '.dataTables_wrapper .col-actions', (e, xhr, settings) ->
|
6
|
-
$action = $(e.target)
|
7
|
-
$table = $(e.target).closest('table')
|
8
|
-
|
9
|
-
return true if ('' + $action.data('inline')) == 'false'
|
10
|
-
|
11
|
-
$params = $.param({_datatable_id: $table.attr('id'), _datatable_attributes: $table.data('attributes'), _datatable_action: true })
|
12
|
-
settings.url += (if settings.url.indexOf('?') == -1 then '?' else '&') + $params
|
13
|
-
|
14
|
-
if $action.closest('.effective-datatables-inline-row,table.dataTable').hasClass('effective-datatables-inline-row')
|
15
|
-
# Nothing.
|
16
|
-
else if $action.closest('tr').parent().prop('tagName') == 'THEAD'
|
17
|
-
beforeNew($action)
|
18
|
-
else
|
19
|
-
beforeEdit($action)
|
20
|
-
|
21
|
-
true
|
22
|
-
|
23
|
-
# We have either completed the resource action, or fetched the inline form to load.
|
24
|
-
$(document).on 'ajax:success', '.dataTables_wrapper .col-actions', (event, data) ->
|
25
|
-
$action = $(event.target)
|
26
|
-
|
27
|
-
return true if ('' + $action.data('inline')) == 'false'
|
28
|
-
|
29
|
-
if data.length > 0
|
30
|
-
return true if data.indexOf('Turbolinks.clearCache()') == 0 && data.includes("Turbolinks.visit(")
|
31
|
-
return true if data.indexOf('<html') >= 0
|
32
|
-
|
33
|
-
if ($action.data('method') || 'get') == 'get'
|
34
|
-
if $action.closest('tr').parent().prop('tagName') == 'THEAD' then afterNew($action) else afterEdit($action)
|
35
|
-
else
|
36
|
-
afterAction($action)
|
37
|
-
|
38
|
-
EffectiveForm.remote_form_payload = ''
|
39
|
-
EffectiveForm.remote_form_commit = ''
|
40
|
-
EffectiveForm.remote_form_flash = ''
|
41
|
-
|
42
|
-
true
|
43
|
-
|
44
|
-
# There was an error completing something
|
45
|
-
$(document).on 'ajax:error', '.dataTables_wrapper', (event) ->
|
46
|
-
$action = $(event.target)
|
47
|
-
|
48
|
-
return true if ('' + $action.data('inline')) == 'false'
|
49
|
-
|
50
|
-
afterError($action)
|
51
|
-
|
52
|
-
EffectiveForm.remote_form_payload = ''
|
53
|
-
EffectiveForm.remote_form_commit = ''
|
54
|
-
EffectiveForm.remote_form_flash = ''
|
55
|
-
true
|
56
|
-
|
57
|
-
# Submitting an inline datatables form
|
58
|
-
$(document).on 'ajax:beforeSend', '.dataTables_wrapper .col-inline-form', (e, xhr, settings) ->
|
59
|
-
$table = $(e.target).closest('table')
|
60
|
-
|
61
|
-
$params = $.param({_datatable_id: $table.attr('id'), _datatable_attributes: $table.data('attributes') })
|
62
|
-
settings.url += (if settings.url.indexOf('?') == -1 then '?' else '&') + $params
|
63
|
-
|
64
|
-
true
|
65
|
-
|
66
|
-
# The inline form has been submitted successfully
|
67
|
-
$(document).on 'effective-form:success', '.dataTables_wrapper .col-inline-form', (event, flash) ->
|
68
|
-
$action = $(event.target)
|
69
|
-
|
70
|
-
$tr = $action.closest('tr')
|
71
|
-
$table = $tr.closest('table')
|
72
|
-
|
73
|
-
if $tr.hasClass('effective-datatables-new-resource')
|
74
|
-
$table.DataTable().flash(flash || 'Item created', 'success')
|
75
|
-
$tr.fadeOut('slow')
|
76
|
-
|
77
|
-
$actions = $table.children('thead').find('th.col-actions')
|
78
|
-
$actions.children('svg').remove()
|
79
|
-
$actions.children('a').fadeIn()
|
80
|
-
else
|
81
|
-
$table.DataTable().flash(flash || 'Item updated', 'success')
|
82
|
-
$tr.fadeOut('slow')
|
83
|
-
|
84
|
-
$table.DataTable().draw()
|
85
|
-
|
86
|
-
beforeNew = ($action) ->
|
87
|
-
$table = $action.closest('table')
|
88
|
-
$th = $action.closest('th')
|
89
|
-
|
90
|
-
# Hide New Button
|
91
|
-
$th.children('a').hide()
|
92
|
-
|
93
|
-
# Append spinner and show Processing
|
94
|
-
$th.append($table.data('spinner'))
|
95
|
-
$table.DataTable().flash()
|
96
|
-
$table.one 'draw.dt', (event) ->
|
97
|
-
$th.find('a').show().siblings('svg').remove() if event.target == event.currentTarget
|
98
|
-
|
99
|
-
afterNew = ($action) ->
|
100
|
-
$tr = $action.closest('tr')
|
101
|
-
$table = $tr.closest('table')
|
102
|
-
$action.siblings('svg').remove()
|
103
|
-
|
104
|
-
html = buildRow($tr.children('th').length, EffectiveForm.remote_form_payload)
|
105
|
-
|
106
|
-
$tr = $("<tr class='effective-datatables-inline-row effective-datatables-new-resource' role='row'>#{html}</tr>")
|
107
|
-
$table.children('tbody').prepend($tr)
|
108
|
-
|
109
|
-
expand($table)
|
110
|
-
$tr.trigger('turbolinks:load')
|
111
|
-
$tr.hide().fadeIn()
|
112
|
-
|
113
|
-
beforeEdit = ($action) ->
|
114
|
-
$table = $action.closest('table')
|
115
|
-
$td = $action.closest('td')
|
116
|
-
|
117
|
-
# Hide dropdown
|
118
|
-
$td.find('.dropdown-toggle').dropdown('toggle')
|
119
|
-
$td.children('.btn-group').hide()
|
120
|
-
$td.children('a').hide()
|
121
|
-
|
122
|
-
# Append spinner and show Processing
|
123
|
-
$td.append($table.data('spinner'))
|
124
|
-
$table.DataTable().flash()
|
125
|
-
|
126
|
-
afterEdit = ($action) ->
|
127
|
-
$tr = $action.closest('tr')
|
128
|
-
$table = $tr.closest('table')
|
129
|
-
|
130
|
-
html = buildRow($tr.children('td').length, EffectiveForm.remote_form_payload)
|
131
|
-
|
132
|
-
$tr.data('inline-form-original-html', $tr.children().detach())
|
133
|
-
$tr.html(html)
|
134
|
-
$tr.addClass('effective-datatables-inline-row')
|
135
|
-
|
136
|
-
expand($table)
|
137
|
-
$tr.trigger('turbolinks:load')
|
138
|
-
$tr.hide().fadeIn()
|
139
|
-
|
140
|
-
# This is when one of the resource actions completes
|
141
|
-
afterAction = ($action) ->
|
142
|
-
$table = $action.closest('table')
|
143
|
-
|
144
|
-
if EffectiveForm.remote_form_flash.length > 0
|
145
|
-
flash = EffectiveForm.remote_form_flash[0]
|
146
|
-
$table.DataTable().flash(flash[1], flash[0])
|
147
|
-
else
|
148
|
-
$table.DataTable().flash('Successfully ' + $action.attr('title'), 'success')
|
149
|
-
|
150
|
-
$table.DataTable().draw()
|
151
|
-
|
152
|
-
afterError = ($action) ->
|
153
|
-
$table = $action.closest('table')
|
154
|
-
$td = $action.closest('td')
|
155
|
-
|
156
|
-
# Show dropdown
|
157
|
-
$td.children('.btn-group').show()
|
158
|
-
|
159
|
-
# Hide spinner
|
160
|
-
$td.children('svg').hide()
|
161
|
-
|
162
|
-
# Cancel
|
163
|
-
cancel($table)
|
164
|
-
|
165
|
-
# Don't redraw
|
166
|
-
$table.DataTable().flash('unable to ' + ($action.attr('title') || 'complete action'), 'danger')
|
167
|
-
|
168
|
-
buildRow = (length, payload) ->
|
169
|
-
"<td class='col-inline-form' colspan='#{length-1}'><div class='container'>#{payload}</div></td>" +
|
170
|
-
"<td class='col-actions col-actions-inline-form'>" +
|
171
|
-
"<a href='#' class='btn btn-sm btn-outline-primary' title='Cancel' data-role='inline-form-cancel'>Cancel</a>" +
|
172
|
-
"</td>"
|
173
|
-
|
174
|
-
expand = ($table) ->
|
175
|
-
$wrapper = $table.closest('.dataTables_wrapper').addClass('effective-datatables-inline-expanded')
|
176
|
-
$table.on 'draw.dt', (event) ->
|
177
|
-
$wrapper.removeClass('effective-datatables-inline-expanded') if event.target == event.currentTarget
|
178
|
-
|
179
|
-
cancel = ($table) ->
|
180
|
-
$wrapper = $table.closest('.dataTables_wrapper')
|
181
|
-
if $wrapper.find('.effective-datatables-inline-row').length == 0
|
182
|
-
$wrapper.removeClass('effective-datatables-inline-expanded')
|
183
|
-
|
184
|
-
# Cancel button clicked. Blow away new tr, or restore edit tr
|
185
|
-
# No data will have changed at this point
|
186
|
-
$(document).on 'click', ".dataTables_wrapper a[data-role='inline-form-cancel']", (event) ->
|
187
|
-
$tr = $(event.currentTarget).closest('tr')
|
188
|
-
|
189
|
-
if $tr.hasClass('effective-datatables-new-resource')
|
190
|
-
$tr.fadeOut('slow', ->
|
191
|
-
$table = $(this).closest('table')
|
192
|
-
|
193
|
-
$actions = $table.children('thead').find('th.col-actions')
|
194
|
-
$actions.children('svg').remove()
|
195
|
-
$actions.children('a').fadeIn()
|
196
|
-
|
197
|
-
$(this).remove()
|
198
|
-
cancel($table)
|
199
|
-
)
|
200
|
-
else
|
201
|
-
$tr.fadeOut('slow', ->
|
202
|
-
$table = $(this).closest('table')
|
203
|
-
$tr.html($tr.data('inline-form-original-html'))
|
204
|
-
|
205
|
-
$td = $tr.children('.col-actions').first()
|
206
|
-
$td.children('svg').remove()
|
207
|
-
|
208
|
-
$toggle = $td.find('.dropdown-toggle')
|
209
|
-
$toggle.dropdown('toggle') if $toggle.parent().hasClass('show')
|
210
|
-
$td.children('.btn-group').show()
|
211
|
-
$td.children('a').show()
|
212
|
-
|
213
|
-
$tr.removeClass('effective-datatables-inline-row').fadeIn()
|
214
|
-
cancel($table)
|
215
|
-
)
|
216
|
-
|
217
|
-
false
|