{ | { | ||||
$assets = parent::configureAssets(); | $assets = parent::configureAssets(); | ||||
$assets->addWebpackEncoreEntry('adminlte-common'); | |||||
$assets->addWebpackEncoreEntry('adminlte-plugins'); | |||||
$assets->addWebpackEncoreEntry('adminlte-index'); | $assets->addWebpackEncoreEntry('adminlte-index'); | ||||
$assets->addWebpackEncoreEntry('adminlte-form'); | $assets->addWebpackEncoreEntry('adminlte-form'); | ||||
$assets->addWebpackEncoreEntry('adminlte-sort'); | $assets->addWebpackEncoreEntry('adminlte-sort'); | ||||
$assets->addWebpackEncoreEntry('adminlte-field-collection'); | $assets->addWebpackEncoreEntry('adminlte-field-collection'); | ||||
$assets->addWebpackEncoreEntry('adminlte-field-filemanager'); | $assets->addWebpackEncoreEntry('adminlte-field-filemanager'); | ||||
$assets->addWebpackEncoreEntry('adminlte-main'); | |||||
$assets->addWebpackEncoreEntry('sov-reminder'); | $assets->addWebpackEncoreEntry('sov-reminder'); | ||||
return $assets; | return $assets; |
id: $(this).data('id'), | id: $(this).data('id'), | ||||
done: $(this).is(':checked') | done: $(this).is(':checked') | ||||
}, function(data) { | }, function(data) { | ||||
Notification.add('success', 'Pense-bête mis à jour'); | |||||
SovNotification.add('success', 'Pense-bête mis à jour'); | |||||
}, 'json'); | }, 'json'); | ||||
}) ; | }) ; | ||||
} | } |
dataType: "json", | dataType: "json", | ||||
success: function (data) { | success: function (data) { | ||||
if (data.success) { | if (data.success) { | ||||
Notification.add('success', 'Le status a bien été mise à jour.'); | |||||
SovNotification.add('success', 'Le status a bien été mise à jour.'); | |||||
} else { | } else { | ||||
Notification.add('danger', 'Une erreur est survenue.'); | |||||
SovNotification.add('danger', 'Une erreur est survenue.'); | |||||
} | } | ||||
} | } | ||||
}); | }); |
/* Notifications */ | |||||
//Notification.init() ; | |||||
setDateRange(); | |||||
setAutoCompleteField(); | |||||
/* Tooltip */ | |||||
$('[data-toggle="tooltip"]').tooltip(); | |||||
/* Select2 */ | |||||
if ($('.select2, select.form-control').length) { | |||||
$('form .form-widget>select.form-control, .select2').each(function (i, elm) { | |||||
if (!$(this).hasClass('disable-select2')) { | |||||
setSelect2($(elm)); | |||||
} | |||||
}); | |||||
$('form select.form-control').each(function (i, elm) { | |||||
if (!$(this).hasClass('disable-select2')) { | |||||
setSelect2($(elm)); | |||||
} | |||||
}); | |||||
} | |||||
function setSelect2($select) { | |||||
if (typeof $select.data('select2-id') === 'undefined') { | |||||
$select.data('init', 'set') | |||||
var options = { | |||||
width: "100%", | |||||
theme: "bootstrap4", | |||||
dropdownAutoWidth: false, | |||||
allowClear: true, | |||||
minimumResultsForSearch: 8 | |||||
}; | |||||
if ($select.data('allow-clear') == 'false') { | |||||
options.allowClear = false; | |||||
} | |||||
if ($select.data('width')) { | |||||
options.width = 'auto' | |||||
} | |||||
if ($select.find('option[value=""]')) { | |||||
options.placeholder = $select.find('option[value=""]').html() | |||||
} | |||||
/*if($select.is(':required') == false) { | |||||
options.allowclear = true | |||||
}*/ | |||||
var myselect = $select.select2(options); | |||||
myselect.on('select2:select', function (e) { | |||||
var event = new Event('change'); | |||||
e.target.dispatchEvent(event); | |||||
}); | |||||
myselect.on('select2:unselect', function (e) { | |||||
var event = new Event('change'); | |||||
e.target.dispatchEvent(event); | |||||
}); | |||||
return myselect; | |||||
} | |||||
} | |||||
$('.action-delete').on('click', function (e) { | |||||
e.preventDefault(); | |||||
const formAction = $(this).attr('formaction'); | |||||
$('#modal-delete').modal({backdrop: true, keyboard: true}) | |||||
.off('click', '#modal-delete-button') | |||||
.on('click', '#modal-delete-button', function () { | |||||
let deleteForm = $('#delete-form'); | |||||
deleteForm.attr('action', formAction); | |||||
deleteForm.submit(); | |||||
}); | |||||
}); | |||||
function setDateRange(){ | |||||
$('.date-time-range, .date-range').each(function (i, picker) { | |||||
options = { | |||||
autoUpdateInput: false, | |||||
locale: { | |||||
"format": "DD/MM/YY", | |||||
"separator": " - ", | |||||
"applyLabel": "Appliquer", | |||||
"cancelLabel": "Annuler", | |||||
"fromLabel": "Du", | |||||
"toLabel": "au", | |||||
"customRangeLabel": "Custom", | |||||
"daysOfWeek": ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"], | |||||
"monthNames": ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"], | |||||
"firstDay": 1 | |||||
} | |||||
}; | |||||
if ($(picker).hasClass('date-time-range')){ | |||||
options = Object.assign(options, { | |||||
timePicker: true, | |||||
timePickerIncrement: 30, | |||||
timePicker24Hour: true, | |||||
locale: { | |||||
"format": "DD/MM/YYYY HH:mm", | |||||
} | |||||
}); | |||||
} | |||||
if ($(picker).nextAll('.date-time-range-fields').find('.date-start').val()) { | |||||
options.startDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-start').val()); | |||||
options.autoUpdateInput = true; | |||||
} | |||||
if ($(picker).nextAll('.date-time-range-fields').find('.date-end').val()) { | |||||
options.endDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-end').val()); | |||||
options.autoUpdateInput = true; | |||||
} | |||||
$(picker).daterangepicker(options); | |||||
$(picker).on('apply.daterangepicker', function (ev, pickerElm) { | |||||
if ($(picker).hasClass('date-time-range')) { | |||||
$(this).val(pickerElm.startDate.format('DD/MM/YY HH:mm') + ' - ' + pickerElm.endDate.format(options.locale.format)); | |||||
}else{ | |||||
$(this).val(pickerElm.startDate.format('DD/MM/YY') + ' - ' + pickerElm.endDate.format(options.locale.format)); | |||||
} | |||||
if ($(picker).hasClass('date-time-range')) { | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD HH:mm')); | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD HH:mm')); | |||||
}else{ | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD')); | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD')); | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
function setAutoCompleteField() { | |||||
var autocompleteFields = $('[data-lc-autocomplete-url]'); | |||||
autocompleteFields.each(function () { | |||||
var $this = $(this), | |||||
url = $this.data('lc-autocomplete-url'); | |||||
$this.autoComplete({ | |||||
noResultsText: 'Aucun résultat n\'a été trouvé.', | |||||
resolverSettings: { | |||||
url: url | |||||
} | |||||
}); | |||||
}); | |||||
} |
function log(name) { | |||||
try { | |||||
return console.log(name); | |||||
} catch (e) { | |||||
return null; | |||||
} | |||||
} |
let toggleRequest = $.ajax({type: "POST", url: toggleUrl, data: {}, dataType: 'json'}); | let toggleRequest = $.ajax({type: "POST", url: toggleUrl, data: {}, dataType: 'json'}); | ||||
toggleRequest.done(function (response) { | toggleRequest.done(function (response) { | ||||
Notification.add('success', 'La propriété a bien été mise à jour.'); | |||||
SovNotification.add('success', 'La propriété a bien été mise à jour.'); | |||||
}); | }); | ||||
toggleRequest.fail(function () { | toggleRequest.fail(function () { | ||||
toggle.checked = oldValue; | toggle.checked = oldValue; | ||||
toggle.disabled = true; | toggle.disabled = true; | ||||
toggle.closest('.checkbox-switch').classList.add('disabled'); | toggle.closest('.checkbox-switch').classList.add('disabled'); | ||||
Notification.add('error', 'Une erreur est survenue.'); | |||||
SovNotification.add('error', 'Une erreur est survenue.'); | |||||
}); | }); | ||||
}); | }); | ||||
} | } |
import './init.js'; | |||||
import './common.scss'; |
SovNotification.init() ; | |||||
SovWidgets.setDateRange(); | |||||
SovWidgets.setAutoCompleteField(); | |||||
/* Tooltip */ | |||||
$('[data-toggle="tooltip"]').tooltip(); | |||||
/* Select2 */ | |||||
if ($('.select2, select.form-control').length) { | |||||
$('form .form-widget>select.form-control, .select2').each(function (i, elm) { | |||||
if (!$(this).hasClass('disable-select2')) { | |||||
SovWidgets.setSelect2($(elm)); | |||||
} | |||||
}); | |||||
$('form select.form-control').each(function (i, elm) { | |||||
if (!$(this).hasClass('disable-select2')) { | |||||
SovWidgets.setSelect2($(elm)); | |||||
} | |||||
}); | |||||
} | |||||
$('.action-delete').on('click', function (e) { | |||||
e.preventDefault(); | |||||
const formAction = $(this).attr('formaction'); | |||||
$('#modal-delete').modal({backdrop: true, keyboard: true}) | |||||
.off('click', '#modal-delete-button') | |||||
.on('click', '#modal-delete-button', function () { | |||||
let deleteForm = $('#delete-form'); | |||||
deleteForm.attr('action', formAction); | |||||
deleteForm.submit(); | |||||
}); | |||||
}); |
import 'toastr/toastr.scss' ; | import 'toastr/toastr.scss' ; | ||||
global.toastr = toastr ; | global.toastr = toastr ; | ||||
// DaterangePicker | // DaterangePicker | ||||
import 'moment' ; | import 'moment' ; | ||||
import 'daterangepicker/daterangepicker.js' ; | import 'daterangepicker/daterangepicker.js' ; | ||||
import 'daterangepicker/daterangepicker.css' ; | import 'daterangepicker/daterangepicker.css' ; | ||||
// Tools | // Tools | ||||
import { Tools } from '../../../tools/tools.js'; | |||||
global.Tools = Tools; | |||||
import { SovTools } from '../../../functions/tools.js'; | |||||
global.SovTools = SovTools; | |||||
// Widgets | |||||
import { SovWidgets } from '../../../functions/widgets.js'; | |||||
global.SovWidgets = SovWidgets; | |||||
import { Notification } from './js/notification.js'; | |||||
global.Notification = Notification; | |||||
Notification.init() ; | |||||
import { SovNotification } from '../../../functions/notification.js'; | |||||
global.SovNotification = SovNotification; | |||||
// Common | |||||
import './common.scss'; | |||||
import './common.js' ; | |||||
export class Notification { | |||||
export class SovNotification { | |||||
static init() { | static init() { | ||||
toastr.options.timeOut = 3000; | toastr.options.timeOut = 3000; |
export class Tools { | |||||
export class SovTools { | |||||
static log(value) { | static log(value) { | ||||
try { | try { |
export class SovWidgets { | |||||
static setSelect2($select) { | |||||
if (typeof $select.data('select2-id') === 'undefined') { | |||||
$select.data('init', 'set') | |||||
var options = { | |||||
width: "100%", | |||||
theme: "bootstrap4", | |||||
dropdownAutoWidth: false, | |||||
allowClear: true, | |||||
minimumResultsForSearch: 8 | |||||
}; | |||||
if ($select.data('allow-clear') == 'false') { | |||||
options.allowClear = false; | |||||
} | |||||
if ($select.data('width')) { | |||||
options.width = 'auto' | |||||
} | |||||
if ($select.find('option[value=""]')) { | |||||
options.placeholder = $select.find('option[value=""]').html() | |||||
} | |||||
/*if($select.is(':required') == false) { | |||||
options.allowclear = true | |||||
}*/ | |||||
var myselect = $select.select2(options); | |||||
myselect.on('select2:select', function (e) { | |||||
var event = new Event('change'); | |||||
e.target.dispatchEvent(event); | |||||
}); | |||||
myselect.on('select2:unselect', function (e) { | |||||
var event = new Event('change'); | |||||
e.target.dispatchEvent(event); | |||||
}); | |||||
return myselect; | |||||
} | |||||
} | |||||
static setDateRange() { | |||||
$('.date-time-range, .date-range').each(function (i, picker) { | |||||
options = { | |||||
autoUpdateInput: false, | |||||
locale: { | |||||
"format": "DD/MM/YY", | |||||
"separator": " - ", | |||||
"applyLabel": "Appliquer", | |||||
"cancelLabel": "Annuler", | |||||
"fromLabel": "Du", | |||||
"toLabel": "au", | |||||
"customRangeLabel": "Custom", | |||||
"daysOfWeek": ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"], | |||||
"monthNames": ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"], | |||||
"firstDay": 1 | |||||
} | |||||
}; | |||||
if ($(picker).hasClass('date-time-range')) { | |||||
options = Object.assign(options, { | |||||
timePicker: true, | |||||
timePickerIncrement: 30, | |||||
timePicker24Hour: true, | |||||
locale: { | |||||
"format": "DD/MM/YYYY HH:mm", | |||||
} | |||||
}); | |||||
} | |||||
if ($(picker).nextAll('.date-time-range-fields').find('.date-start').val()) { | |||||
options.startDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-start').val()); | |||||
options.autoUpdateInput = true; | |||||
} | |||||
if ($(picker).nextAll('.date-time-range-fields').find('.date-end').val()) { | |||||
options.endDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-end').val()); | |||||
options.autoUpdateInput = true; | |||||
} | |||||
$(picker).daterangepicker(options); | |||||
$(picker).on('apply.daterangepicker', function (ev, pickerElm) { | |||||
if ($(picker).hasClass('date-time-range')) { | |||||
$(this).val(pickerElm.startDate.format('DD/MM/YY HH:mm') + ' - ' + pickerElm.endDate.format(options.locale.format)); | |||||
} else { | |||||
$(this).val(pickerElm.startDate.format('DD/MM/YY') + ' - ' + pickerElm.endDate.format(options.locale.format)); | |||||
} | |||||
if ($(picker).hasClass('date-time-range')) { | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD HH:mm')); | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD HH:mm')); | |||||
} else { | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD')); | |||||
$(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD')); | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
static setAutoCompleteField() { | |||||
var autocompleteFields = $('[data-lc-autocomplete-url]'); | |||||
autocompleteFields.each(function () { | |||||
var $this = $(this), | |||||
url = $this.data('lc-autocomplete-url'); | |||||
$this.autoComplete({ | |||||
noResultsText: 'Aucun résultat n\'a été trouvé.', | |||||
resolverSettings: { | |||||
url: url | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
} |
{% block class %}{{ loop.first ? 'active' }}{% endblock %} | {% block class %}{{ loop.first ? 'active' }}{% endblock %} | ||||
{% block id %}{{ panel_name }}{% endblock %} | {% block id %}{{ panel_name }}{% endblock %} | ||||
{% block content %} | {% block content %} | ||||
{{ dump() }} | |||||
{% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and field.vars.ea_crud_form.form_panel == panel_name) %} | {% for field in form|filter(field => 'hidden' not in field.vars.block_prefixes and field.vars.ea_crud_form.form_panel == panel_name) %} | ||||
{% if not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name %} | {% if not field.vars.ea_crud_form.form_tab or field.vars.ea_crud_form.form_tab == tab_name %} | ||||
{{ form_row(field) }} | {{ form_row(field) }} |
$(document).ready(function () { | $(document).ready(function () { | ||||
{% for label, messages in flash_messages %} | {% for label, messages in flash_messages %} | ||||
{% for message in messages %} | {% for message in messages %} | ||||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}"); | |||||
SovNotification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}"); | |||||
{% endfor %} | {% endfor %} | ||||
{% endfor %} | {% endfor %} | ||||
}); | }); |