|
|
@@ -246,170 +246,86 @@
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
Livewire.on('load-anagrafica-modal', () => {
|
|
|
+ const modalsAnag = [
|
|
|
+ "anag_birth_town_id",
|
|
|
+ "anag_residenza_town_id",
|
|
|
+ "anag_documento_rilasciato_da_di_foreign_localita",
|
|
|
+ "anag_sede_legale_town_id",
|
|
|
+ "anag_foreign_birth_country",
|
|
|
+ "anag_foreign_residence_country",
|
|
|
+ "anag_pg_foreign_residence_country"
|
|
|
+ ];
|
|
|
|
|
|
- const modal = $('#anagraficaParte');
|
|
|
- if (modal.length) {
|
|
|
- // Show the modal
|
|
|
- modal.modal('show');
|
|
|
- const modalsAnag = [
|
|
|
- "anag_birth_town_id",
|
|
|
- "anag_residenza_town_id",
|
|
|
- "anag_documento_rilasciato_da_di_foreign_localita",
|
|
|
- "anag_sede_legale_town_id",
|
|
|
- "anag_foreign_birth_country",
|
|
|
- "anag_foreign_residence_country",
|
|
|
- "anag_pg_foreign_residence_country"
|
|
|
- ];
|
|
|
-
|
|
|
- const countryFields = [
|
|
|
- "anag_foreign_birth_country",
|
|
|
- "anag_foreign_residence_country"
|
|
|
- ];
|
|
|
-
|
|
|
- function modalsAnagSelect(value) {
|
|
|
- $('.' + value).select2({
|
|
|
- dropdownParent: $("#anagraficaParte .modal-content"),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/localita',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function (e) {
|
|
|
- var data = $('.' + value).select2("val");
|
|
|
- @this.set(value, data);
|
|
|
- });
|
|
|
-
|
|
|
- const currentValue = $('.' + value).val();
|
|
|
- const currentText = $('.' + value).find('option:selected').text();
|
|
|
- if (currentValue) {
|
|
|
- let option = new Option(currentText, currentValue, true, true);
|
|
|
- $('.' + value).append(option).trigger('change');
|
|
|
- }
|
|
|
- }
|
|
|
+ const countryFields = [
|
|
|
+ "anag_foreign_birth_country",
|
|
|
+ "anag_foreign_residence_country"
|
|
|
+ ];
|
|
|
|
|
|
- function initializeCountrySelects(value) {
|
|
|
- $('.' + value).select2({
|
|
|
- dropdownParent: $("#anagraficaParte .modal-content"),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/countries',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function (e) {
|
|
|
- var data = $('.' + value).select2("val");
|
|
|
- @this.set(value, data);
|
|
|
- });
|
|
|
-
|
|
|
- const currentValue = $('.' + value).val();
|
|
|
- const currentText = $('.' + value).find('option:selected').text();
|
|
|
- if (currentValue) {
|
|
|
- let option = new Option(currentText, currentValue, true, true);
|
|
|
- $('.' + value).append(option).trigger('change');
|
|
|
- }
|
|
|
- }
|
|
|
+ function modalsAnagSelect(value) {
|
|
|
+ $('.' + value).select2({
|
|
|
+ dropdownParent: $("#anagraficaParte .modal-content"),
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/localita',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function (e) {
|
|
|
+ var data = $('.' + value).select2("val");
|
|
|
+ @this.set(value, data);
|
|
|
+ });
|
|
|
|
|
|
- function initializeModalState() {
|
|
|
- const currentType = $('input[name="anag_type"]:checked').val();
|
|
|
- if (currentType == 0 || !currentType) {
|
|
|
- $("#boxPersonaFisica").show();
|
|
|
- $("#boxPersonaGiuridica").hide();
|
|
|
-
|
|
|
- const isStraniera = $('select[wire\\:model="anag_nazionalita"]').val() === "1";
|
|
|
- $("#foreignBirthCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
- $("#foreignBirthCity")[isStraniera ? 'show' : 'hide']();
|
|
|
- $("#foreignResidenceCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
- $("#foreignResidenceCity")[isStraniera ? 'show' : 'hide']();
|
|
|
- if (isStraniera) {
|
|
|
- $("#pippo").hide();
|
|
|
- $(".anag_residenza_town_id").closest('.row').hide();
|
|
|
- }
|
|
|
- } else {
|
|
|
- $("#boxPersonaFisica").hide();
|
|
|
- $("#boxPersonaGiuridica").show();
|
|
|
-
|
|
|
- const isPGStraniera = $('select[wire\\:model="nazionalita"]').val() === "1";
|
|
|
- $("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
|
|
|
- $("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();
|
|
|
-
|
|
|
- if (isPGStraniera) {
|
|
|
- $(".anag_sede_legale_town_id").closest('.row').hide();
|
|
|
- $(".anag_sede_legale_cap").closest('.row').hide();
|
|
|
- $(".anag_sede_legale_prov_id").closest('.row').hide();
|
|
|
- } else {
|
|
|
- $(".anag_sede_legale_town_id").closest('.row').show();
|
|
|
- $(".anag_sede_legale_cap").closest('.row').show();
|
|
|
- $(".anag_sede_legale_prov_id").closest('.row').show();
|
|
|
- }
|
|
|
- }
|
|
|
+ const currentValue = $('.' + value).val();
|
|
|
+ const currentText = $('.' + value).find('option:selected').text();
|
|
|
+ if (currentValue) {
|
|
|
+ let option = new Option(currentText, currentValue, true, true);
|
|
|
+ $('.' + value).append(option).trigger('change');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- modalsAnag.forEach(modalsAnagSelect);
|
|
|
- }, 100);
|
|
|
+ function initializeCountrySelects(value) {
|
|
|
+ $('.' + value).select2({
|
|
|
+ dropdownParent: $("#anagraficaParte .modal-content"),
|
|
|
+ theme: 'bootstrap4',
|
|
|
+ ajax: {
|
|
|
+ url: '/countries',
|
|
|
+ dataType: 'json'
|
|
|
+ },
|
|
|
+ width: '100%'
|
|
|
+ }).on('change', function (e) {
|
|
|
+ var data = $('.' + value).select2("val");
|
|
|
+ @this.set(value, data);
|
|
|
+ });
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- countryFields.forEach(initializeCountrySelects);
|
|
|
- }, 100);
|
|
|
+ const currentValue = $('.' + value).val();
|
|
|
+ const currentText = $('.' + value).find('option:selected').text();
|
|
|
+ if (currentValue) {
|
|
|
+ let option = new Option(currentText, currentValue, true, true);
|
|
|
+ $('.' + value).append(option).trigger('change');
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ function initializeModalState() {
|
|
|
+ const currentType = $('input[name="anag_type"]:checked').val();
|
|
|
+ if (currentType == 0 || !currentType) {
|
|
|
+ $("#boxPersonaFisica").show();
|
|
|
+ $("#boxPersonaGiuridica").hide();
|
|
|
|
|
|
- $('select[wire\\:model="anag_nazionalita"]').change(function () {
|
|
|
- const isStraniera = $(this).val() === "1";
|
|
|
+ const isStraniera = $('select[wire\\:model="anag_nazionalita"]').val() === "1";
|
|
|
$("#foreignBirthCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
$("#foreignBirthCity")[isStraniera ? 'show' : 'hide']();
|
|
|
$("#foreignResidenceCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
$("#foreignResidenceCity")[isStraniera ? 'show' : 'hide']();
|
|
|
-
|
|
|
if (isStraniera) {
|
|
|
$("#pippo").hide();
|
|
|
$(".anag_residenza_town_id").closest('.row').hide();
|
|
|
- $(".anag_documento_rilasciato_da_di_foreign_localita").closest('.row').hide();
|
|
|
- } else {
|
|
|
- $("#pippo").show();
|
|
|
- $(".anag_residenza_town_id").closest('.row').show();
|
|
|
- @this.set('anag_foreign_birth_country', '');
|
|
|
- @this.set('anag_foreign_birth_city', '');
|
|
|
- @this.set('anag_foreign_residence_country', '');
|
|
|
- @this.set('anag_foreign_residence_city', '');
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- initializeModalState();
|
|
|
-
|
|
|
- $('input[name="anag_type"]').change(function () {
|
|
|
- var x = $('input[name="anag_type"]:checked').val();
|
|
|
- if (x == 0) {
|
|
|
- $("#boxPersonaFisica").show();
|
|
|
- $("#boxPersonaGiuridica").hide();
|
|
|
- @this.changeAnagType(0);
|
|
|
- } else {
|
|
|
- $("#boxPersonaFisica").hide();
|
|
|
- $("#boxPersonaGiuridica").show();
|
|
|
- setTimeout(() => {
|
|
|
- modalsAnag.forEach(modalsAnagSelect);
|
|
|
- }, 100);
|
|
|
- @this.changeAnagType(1);
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- Livewire.on('change-visualization', (type) => {
|
|
|
- $('input:radio[name="anag_type"]').filter('[value="' + type + '"]').prop('checked', true);
|
|
|
- if (type == 0) {
|
|
|
- $("#boxPersonaFisica").show();
|
|
|
- $("#boxPersonaGiuridica").hide();
|
|
|
- } else {
|
|
|
- $("#boxPersonaFisica").hide();
|
|
|
- $("#boxPersonaGiuridica").show();
|
|
|
- setTimeout(() => {
|
|
|
- modalsAnag.forEach(modalsAnagSelect);
|
|
|
- }, 100);
|
|
|
- }
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ $("#boxPersonaFisica").hide();
|
|
|
+ $("#boxPersonaGiuridica").show();
|
|
|
|
|
|
- $('select[wire\\:model="nazionalita"]').change(function () {
|
|
|
- const isPGStraniera = $(this).val() === "1";
|
|
|
+ const isPGStraniera = $('select[wire\\:model="nazionalita"]').val() === "1";
|
|
|
$("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
|
|
|
$("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();
|
|
|
|
|
|
@@ -421,49 +337,101 @@
|
|
|
$(".anag_sede_legale_town_id").closest('.row').show();
|
|
|
$(".anag_sede_legale_cap").closest('.row').show();
|
|
|
$(".anag_sede_legale_prov_id").closest('.row').show();
|
|
|
- @this.set('anag_foreign_residence_country', '');
|
|
|
- @this.set('anag_foreign_residence_city', '');
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
- $('#anagraficaParte').on('show.bs.modal', function () {
|
|
|
- initializeModalState();
|
|
|
- });
|
|
|
+ setTimeout(() => {
|
|
|
+ modalsAnag.forEach(modalsAnagSelect);
|
|
|
+ }, 100);
|
|
|
|
|
|
- $('#anagraficaParte').on('hidden.bs.modal', function () {
|
|
|
- modalsAnag.forEach(value => {
|
|
|
- if ($('.' + value).data('select2')) {
|
|
|
- $('.' + value).select2('destroy');
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- modal.on('shown.bs.modal', function () {
|
|
|
+ setTimeout(() => {
|
|
|
+ countryFields.forEach(initializeCountrySelects);
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ $('select[wire\\:model="anag_nazionalita"]').change(function () {
|
|
|
+ const isStraniera = $(this).val() === "1";
|
|
|
+ $("#foreignBirthCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
+ $("#foreignBirthCity")[isStraniera ? 'show' : 'hide']();
|
|
|
+ $("#foreignResidenceCountry")[isStraniera ? 'show' : 'hide']();
|
|
|
+ $("#foreignResidenceCity")[isStraniera ? 'show' : 'hide']();
|
|
|
+
|
|
|
+ if (isStraniera) {
|
|
|
+ $("#pippo").hide();
|
|
|
+ $(".anag_residenza_town_id").closest('.row').hide();
|
|
|
+ $(".anag_documento_rilasciato_da_di_foreign_localita").closest('.row').hide();
|
|
|
+ } else {
|
|
|
+ $("#pippo").show();
|
|
|
+ $(".anag_residenza_town_id").closest('.row').show();
|
|
|
+ @this.set('anag_foreign_birth_country', '');
|
|
|
+ @this.set('anag_foreign_birth_city', '');
|
|
|
+ @this.set('anag_foreign_residence_country', '');
|
|
|
+ @this.set('anag_foreign_residence_city', '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ initializeModalState();
|
|
|
+
|
|
|
+ $('input[name="anag_type"]').change(function () {
|
|
|
+ var x = $('input[name="anag_type"]:checked').val();
|
|
|
+ if (x == 0) {
|
|
|
+ $("#boxPersonaFisica").show();
|
|
|
+ $("#boxPersonaGiuridica").hide();
|
|
|
+ @this.changeAnagType(0);
|
|
|
+ } else {
|
|
|
+ $("#boxPersonaFisica").hide();
|
|
|
+ $("#boxPersonaGiuridica").show();
|
|
|
setTimeout(() => {
|
|
|
- modalsAnag.forEach(value => {
|
|
|
- if ($('.' + value).data('select2')) {
|
|
|
- $('.' + value).select2('destroy');
|
|
|
- }
|
|
|
- initializeSelect2(value);
|
|
|
- });
|
|
|
+ modalsAnag.forEach(modalsAnagSelect);
|
|
|
}, 100);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ @this.changeAnagType(1);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- function initializeSelect2(value) {
|
|
|
- $('.' + value).select2({
|
|
|
- dropdownParent: $("#anagraficaParte .modal-content"),
|
|
|
- theme: 'bootstrap4',
|
|
|
- ajax: {
|
|
|
- url: '/localita',
|
|
|
- dataType: 'json'
|
|
|
- },
|
|
|
- width: '100%'
|
|
|
- }).on('change', function(e) {
|
|
|
- var data = $(this).select2("val");
|
|
|
- @this.set(value, data);
|
|
|
+ Livewire.on('change-visualization', (type) => {
|
|
|
+ $('input:radio[name="anag_type"]').filter('[value="' + type + '"]').prop('checked', true);
|
|
|
+ if (type == 0) {
|
|
|
+ $("#boxPersonaFisica").show();
|
|
|
+ $("#boxPersonaGiuridica").hide();
|
|
|
+ } else {
|
|
|
+ $("#boxPersonaFisica").hide();
|
|
|
+ $("#boxPersonaGiuridica").show();
|
|
|
+ setTimeout(() => {
|
|
|
+ modalsAnag.forEach(modalsAnagSelect);
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
});
|
|
|
- }
|
|
|
+
|
|
|
+ $('select[wire\\:model="nazionalita"]').change(function () {
|
|
|
+ const isPGStraniera = $(this).val() === "1";
|
|
|
+ $("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
|
|
|
+ $("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();
|
|
|
+
|
|
|
+ if (isPGStraniera) {
|
|
|
+ $(".anag_sede_legale_town_id").closest('.row').hide();
|
|
|
+ $(".anag_sede_legale_cap").closest('.row').hide();
|
|
|
+ $(".anag_sede_legale_prov_id").closest('.row').hide();
|
|
|
+ } else {
|
|
|
+ $(".anag_sede_legale_town_id").closest('.row').show();
|
|
|
+ $(".anag_sede_legale_cap").closest('.row').show();
|
|
|
+ $(".anag_sede_legale_prov_id").closest('.row').show();
|
|
|
+ @this.set('anag_foreign_residence_country', '');
|
|
|
+ @this.set('anag_foreign_residence_city', '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#anagraficaParte').on('show.bs.modal', function () {
|
|
|
+ initializeModalState();
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#anagraficaParte').on('hidden.bs.modal', function () {
|
|
|
+ modalsAnag.forEach(value => {
|
|
|
+ if ($('.' + value).data('select2')) {
|
|
|
+ $('.' + value).select2('destroy');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
Livewire.on('load-select-modal', () => {
|
|
|
|
|
|
@@ -667,8 +635,7 @@
|
|
|
}
|
|
|
|
|
|
if (data.polizza_num) {
|
|
|
- $('.polizza_num').val(data.polizza_num);
|
|
|
- @this.set('polizza_num', data.polizza_num);
|
|
|
+ $('.polizza_num').val(data.polizza_num); @this.set('polizza_num', data.polizza_num);
|
|
|
}
|
|
|
if (data.valida_dal) {
|
|
|
$('.valida_dal').val(data.valida_dal);
|
|
|
@@ -812,7 +779,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", "anagrafica_id"
|
|
|
+ "data_infortunato_extra_3"
|
|
|
];
|
|
|
|
|
|
modals.forEach(value => {
|
|
|
@@ -854,4 +821,5 @@
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
+
|
|
|
@endpush
|