|
|
@@ -441,7 +441,7 @@
|
|
|
"data_proprietari", "data_coproprietari", "data_conducenti",
|
|
|
"data_passeggero_0", "data_passeggero_1", "data_passeggero_2", "data_passeggero_3",
|
|
|
"data_infortunato_extra_0", "data_infortunato_extra_1", "data_infortunato_extra_2",
|
|
|
- "data_infortunato_extra_3"
|
|
|
+ "data_infortunato_extra_3","anagrafica_id"
|
|
|
];
|
|
|
|
|
|
function initializeSelect2(element, url = '/anagrafica') {
|
|
|
@@ -524,7 +524,143 @@
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ $('.compagnia_id').each(function() {
|
|
|
+ if ($(this).data('select2')) {
|
|
|
+ $(this).select2('destroy');
|
|
|
+ }
|
|
|
+ const currentValue = $(this).val();
|
|
|
+ const currentText = $(this).find('option:selected').text();
|
|
|
+
|
|
|
+ $(this).select2({
|
|
|
+ dropdownParent: document.body,
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/compagnie',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function(e) {
|
|
|
+ @this.set('compagnia_id', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ if (currentValue && currentText) {
|
|
|
+ const option = new Option(currentText, currentValue, true, true);
|
|
|
+ $(this).append(option).trigger('change');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.agenzia').each(function() {
|
|
|
+ if ($(this).data('select2')) {
|
|
|
+ $(this).select2('destroy');
|
|
|
+ }
|
|
|
+ const currentValue = $(this).val();
|
|
|
+ const currentText = $(this).find('option:selected').text();
|
|
|
+
|
|
|
+ $(this).select2({
|
|
|
+ dropdownParent: document.body,
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/polizze/agenzie',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function(e) {
|
|
|
+ @this.set('agenzia', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ if (currentValue && currentText) {
|
|
|
+ const option = new Option(currentText, currentValue, true, true);
|
|
|
+ $(this).append(option).trigger('change');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.valida_dal').on('change', function(e) {
|
|
|
+ @this.set('valida_dal', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.valida_al').on('change', function(e) {
|
|
|
+ @this.set('valida_al', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.polizza_num').on('input', function(e) {
|
|
|
+ @this.set('polizza_num', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
+ Livewire.on('updatePolizzaSelects', data => {
|
|
|
+ // Initialize anagrafica_id select2
|
|
|
+ const $anagrafica = $('.anagrafica_id');
|
|
|
+ if ($anagrafica.data('select2')) {
|
|
|
+ $anagrafica.select2('destroy');
|
|
|
+ }
|
|
|
+ $anagrafica.select2({
|
|
|
+ dropdownParent: document.body,
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/anagrafica',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function(e) {
|
|
|
+ @this.set('anagrafica_id', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ // Set anagrafica value if exists
|
|
|
+ if (data.anagrafica) {
|
|
|
+ const option = new Option(data.anagrafica.text, data.anagrafica.id, true, true);
|
|
|
+ $anagrafica.append(option).trigger('change');
|
|
|
+ }
|
|
|
+
|
|
|
+ // Initialize compagnia_id select2
|
|
|
+ const $compagnia = $('.compagnia_id');
|
|
|
+ if ($compagnia.data('select2')) {
|
|
|
+ $compagnia.select2('destroy');
|
|
|
+ }
|
|
|
+ $compagnia.select2({
|
|
|
+ dropdownParent: document.body,
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/compagnie',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function(e) {
|
|
|
+ @this.set('compagnia_id', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ // Set compagnia value if exists
|
|
|
+ if (data.compagnia) {
|
|
|
+ const option = new Option(data.compagnia.text, data.compagnia.id, true, true);
|
|
|
+ $compagnia.append(option).trigger('change');
|
|
|
+ }
|
|
|
+
|
|
|
+ // Initialize agenzia select2
|
|
|
+ const $agenzia = $('.agenzia');
|
|
|
+ if ($agenzia.data('select2')) {
|
|
|
+ $agenzia.select2('destroy');
|
|
|
+ }
|
|
|
+ $agenzia.select2({
|
|
|
+ dropdownParent: document.body,
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/polizze/agenzie',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function(e) {
|
|
|
+ @this.set('agenzia', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ // Set agenzia value if exists
|
|
|
+ if (data.agenzia) {
|
|
|
+ const option = new Option(data.agenzia, data.agenzia, true, true);
|
|
|
+ $agenzia.append(option).trigger('change');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
Livewire.on('load-select-pedone', () => {
|
|
|
|
|
|
var x = $("#generalizzato").val();
|
|
|
@@ -651,96 +787,13 @@
|
|
|
$("." + cls + "Text").hide();
|
|
|
});
|
|
|
|
|
|
- Livewire.on('load-polizza-modal', () => {
|
|
|
- $('.valida_dal').on('change', function (e) {
|
|
|
- @this.set('valida_dal', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- $('.valida_al').on('change', function (e) {
|
|
|
- @this.set('valida_al', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- $('.polizza_num').on('input', function (e) {
|
|
|
- @this.set('polizza_num', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- $('.anagrafica_id').select2({
|
|
|
- dropdownParent: $('#polizzaParte .modal-content'),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/anagrafica',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function (e) {
|
|
|
- @this.set('anagrafica_id', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- $('.compagnia_id').select2({
|
|
|
- dropdownParent: $('#polizzaParte .modal-content'),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/compagnie',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function (e) {
|
|
|
- @this.set('compagnia_id', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- $('.agenzia').select2({
|
|
|
- dropdownParent: $('#polizzaParte .modal-content'),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/polizze/agenzie',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function (e) {
|
|
|
- @this.set('agenzia', $(this).val());
|
|
|
- });
|
|
|
-
|
|
|
- window.addEventListener('show-polizza-modal', event => {
|
|
|
- $('#polizzaParte').modal('show');
|
|
|
- });
|
|
|
-
|
|
|
- Livewire.on('hide-polizza-modal', () => {
|
|
|
- $('#polizzaParte').modal('hide');
|
|
|
- Livewire.emit('load-select');
|
|
|
- });
|
|
|
-
|
|
|
- $('#polizzaParte').on('hidden.bs.modal', () => {
|
|
|
- $('#polizzaParte').modal('hide');
|
|
|
- setTimeout(() => {
|
|
|
- Livewire.emit('load-select-modal');
|
|
|
- }, 200);
|
|
|
- });
|
|
|
-
|
|
|
- Livewire.on('polizza-saved', (polizzaId, polizzaText) => {
|
|
|
- let $select = $('.data_polizze');
|
|
|
- $select.append(new Option(polizzaText, polizzaId, true, true)).trigger('change');
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- Livewire.on('updatePolizzaSelects', data => {
|
|
|
- if (data.anagrafica) {
|
|
|
- let option = new Option(data.anagrafica.text, data.anagrafica.id, true, true);
|
|
|
- $('.anagrafica_id').append(option).trigger('change');
|
|
|
- }
|
|
|
-
|
|
|
- if (data.compagnia) {
|
|
|
- let option = new Option(data.compagnia.text, data.compagnia.id, true, true);
|
|
|
- $('.compagnia_id').append(option).trigger('change');
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
function initializeSelect2Controls() {
|
|
|
console.log("initializeSelect2Controls");
|
|
|
const modals = [
|
|
|
"data_proprietari", "data_coproprietari", "data_conducenti",
|
|
|
"data_passeggero_0", "data_passeggero_1", "data_passeggero_2", "data_passeggero_3",
|
|
|
"data_infortunato_extra_0", "data_infortunato_extra_1", "data_infortunato_extra_2",
|
|
|
- "data_infortunato_extra_3"
|
|
|
+ "data_infortunato_extra_3","anagrafica_id"
|
|
|
];
|
|
|
|
|
|
modals.forEach(value => {
|
|
|
@@ -754,16 +807,6 @@
|
|
|
width: '100%'
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- $('.data_polizze').select2({
|
|
|
- dropdownParent: document.body,
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/polizze',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
</script>
|