-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathduplicate.js
37 lines (37 loc) · 1.25 KB
/
duplicate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* DataTables duplicate button.
*
* -- Laravel Integration --
*
* Button::make('duplicate')
*
*/
document.addEventListener('DOMContentLoaded', function () {
$.fn.dataTable.ext.buttons.duplicate = {
name: 'duplicate',
extend: 'selected',
className: 'buttons-duplicate btn-success',
text: '<i class="bi bi-copy"></i> Duplicate',
action: function (e, dt, node, config) {
// Start in edit mode, and then change to create
let editor = config.editor || dt.editor();
editor.edit(dt.rows({selected: true}).indexes(), {
title: config.formTitle || 'Duplicate Record',
buttons: config.formButtons || [
{
text: '<i class="bi bi-copy"></i> Duplicate',
className: 'btn btn-success btn-editor-duplicate',
action: function () {
this.submit();
}
},
{
text: 'Cancel', className: 'btn ml-2', action: function () {
this.close();
}
}
]
}).mode('create');
}
};
});