2022-03-13 19:32:32 +01:00
|
|
|
const $ = require('jquery')
|
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
$('th.crud-batch-column input').change((e) => {
|
|
|
|
$('td.crud-batch-column input').prop('checked', $(e.target).is(':checked'))
|
|
|
|
})
|
|
|
|
|
|
|
|
const form = $('#form-batch')
|
|
|
|
|
|
|
|
form.submit((e) => {
|
2023-10-12 15:27:36 +02:00
|
|
|
const select = document.querySelector('#form-batch-action')
|
|
|
|
const options = select.querySelectorAll('#form-batch-action option')
|
|
|
|
let doPrevent = true
|
2022-03-13 19:32:32 +01:00
|
|
|
|
2023-10-12 15:27:36 +02:00
|
|
|
options.forEach((option) => {
|
|
|
|
if (option.value === select.value && option.getAttribute('data-isglobal') === 'true') {
|
|
|
|
doPrevent = false
|
|
|
|
}
|
|
|
|
})
|
2022-03-13 19:32:32 +01:00
|
|
|
|
2023-10-12 15:27:36 +02:00
|
|
|
if (doPrevent) {
|
|
|
|
e.preventDefault()
|
2022-03-13 19:32:32 +01:00
|
|
|
|
2023-10-12 15:27:36 +02:00
|
|
|
const route = form.attr('action')
|
|
|
|
const datas = form.serialize()
|
|
|
|
|
|
|
|
form.addClass('is-loading')
|
|
|
|
|
|
|
|
$.post(route, datas)
|
|
|
|
.always(() => {
|
|
|
|
document.location.reload()
|
|
|
|
})
|
|
|
|
}
|
2022-03-13 19:32:32 +01:00
|
|
|
})
|
|
|
|
}
|