Browse Source

fix modal

FabioFratini 11 tháng trước cách đây
mục cha
commit
02bfb36cb3

+ 12 - 0
public/dist/css/app.css

@@ -281,3 +281,15 @@ select option,
     background-color: #023047 !important;
     box-shadow: none;
 }
+
+.modal-dialog {
+    max-height: 90vh;
+}
+
+.modal-content {
+    height: 90vh;
+    overflow-y: auto;
+}
+.select2-container--open {
+    z-index: 9999;
+}

+ 6 - 14
resources/views/components/report/veicoli/accordion/veicolo-assicurazione-accordion.blade.php

@@ -22,20 +22,12 @@
                             </select>
                         </div>
                         <div class="col-sm-3">
-                            @if ($anagrafica_id)
-                                <a class="btn btn-primary editAnagrafica"
-                                    wire:click.prevent="editAnagraficaPolizza()" data-target="#anagraficaParte"
-                                    style="background-color: orange;border-color: orange;">
-                                    <i class="fa fa-edit"></i>
-                                </a>
-                                <a class="btn btn-danger" wire:click.prevent="removeAnagraficaPolizza()">
-                                    <i class="fa fa-trash"></i>&nbsp;
-                                </a>
-                            @else
-                                <a class="btn btn-primary" wire:click.prevent="addAnagraficaPolizza()"
-                                    data-target="#anagraficaParte">+&nbsp;
-                                </a>
-                            @endif
+                            <a class="btn btn-primary"
+                            wire:click.prevent="addAnagraficaPolizza"
+                            href="#"
+                            role="button">
+                             +&nbsp;
+                         </a>
                         </div>
                     </div>
                 </div>

+ 212 - 181
resources/views/livewire/report.blade.php

@@ -7,20 +7,20 @@
     @if (!$add && !$update)
         @include('components.report.list.verbali')
     @else
-            <form>
-                @include('components.report.modifica.header')
-                @include('components.report.modifica.menu')
-                    <div class="tab-content" id="custom-tabs-three-tabContent">
-                        @include('components.report.protocollo.protocollo')
-                        @include('components.report.parti.parti-accertatori')
-                        @include('components.report.segnalazione.segnalazione-page')
-                        @include('components.report.campo-sinistro.campo-sinistro')
-                        @include('components.report.segnaletica.segnaletica')
-                        @include('components.report.testimoni.testimone')
-                        @include('components.report.allegati.allegato')
-                    </div>
-                @include('components.report.modifica.footer')
-            </form>
+        <form>
+            @include('components.report.modifica.header')
+            @include('components.report.modifica.menu')
+            <div class="tab-content" id="custom-tabs-three-tabContent">
+                @include('components.report.protocollo.protocollo')
+                @include('components.report.parti.parti-accertatori')
+                @include('components.report.segnalazione.segnalazione-page')
+                @include('components.report.campo-sinistro.campo-sinistro')
+                @include('components.report.segnaletica.segnaletica')
+                @include('components.report.testimoni.testimone')
+                @include('components.report.allegati.allegato')
+            </div>
+            @include('components.report.modifica.footer')
+        </form>
 
         @include('components.report.anagrafica.anagrafica-modal')
 
@@ -248,85 +248,168 @@
         });
 
         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 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 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 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 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 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);
-                });
+                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 initializeModalState() {
-                const currentType = $('input[name="anag_type"]:checked').val();
-                if (currentType == 0 || !currentType) {
-                    $("#boxPersonaFisica").show();
-                    $("#boxPersonaGiuridica").hide();
+                    setTimeout(() => {
+                        countryFields.forEach(initializeCountrySelects);
+                    }, 100);
+                }
 
-                    const isStraniera = $('select[wire\\:model="anag_nazionalita"]').val() === "1";
+                $('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', '');
                     }
-                } else {
-                    $("#boxPersonaFisica").hide();
-                    $("#boxPersonaGiuridica").show();
+                });
+
+                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);
+                    }
+                });
 
-                    const isPGStraniera = $('select[wire\\:model="nazionalita"]').val() === "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);
+                    }
+                });
+
+                $('select[wire\\:model="nazionalita"]').change(function () {
+                    const isPGStraniera = $(this).val() === "1";
                     $("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
                     $("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();
 
@@ -338,102 +421,50 @@
                         $(".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', '');
                     }
-                }
-
-                setTimeout(() => {
-                    modalsAnag.forEach(modalsAnagSelect);
-                }, 100);
-
-                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(modalsAnagSelect);
-                    }, 100);
-                    @this.changeAnagType(1);
-                }
-            });
+                $('#anagraficaParte').on('show.bs.modal', function () {
+                    initializeModalState();
+                });
 
-            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();
+                $('#anagraficaParte').on('hidden.bs.modal', function () {
+                    modalsAnag.forEach(value => {
+                        if ($('.' + value).data('select2')) {
+                            $('.' + value).select2('destroy');
+                        }
+                    });
+                });
+                modal.on('shown.bs.modal', function () {
                     setTimeout(() => {
-                        modalsAnag.forEach(modalsAnagSelect);
+                        modalsAnag.forEach(value => {
+                            if ($('.' + value).data('select2')) {
+                                $('.' + value).select2('destroy');
+                            }
+                            initializeSelect2(value);
+                        });
                     }, 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');
-                    }
                 });
-            });
+            }
         });
 
+        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('load-select-modal', () => {
 
             initializeSelect2Controls();
@@ -466,7 +497,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", "anagrafica_id"
             ];
 
             function initializeSelect2(element, url = '/anagrafica') {
@@ -550,11 +581,11 @@
                 });
             });
 
-            $('.compagnia_id').each(function() {
+            $('.compagnia_id').each(function () {
                 if ($(this).data('select2')) {
                     $(this).select2('destroy');
                 }
-                    const currentValue = $(this).val();
+                const currentValue = $(this).val();
                 const currentText = $(this).find('option:selected').text();
 
                 $(this).select2({
@@ -565,7 +596,7 @@
                         dataType: 'json'
                     },
                     width: '100%'
-                }).on('change', function(e) {
+                }).on('change', function (e) {
                     @this.set('compagnia_id', $(this).val());
                 });
 
@@ -575,7 +606,7 @@
                 }
             });
 
-            $('.agenzia').each(function() {
+            $('.agenzia').each(function () {
                 if ($(this).data('select2')) {
                     $(this).select2('destroy');
                 }
@@ -590,7 +621,7 @@
                         dataType: 'json'
                     },
                     width: '100%'
-                }).on('change', function(e) {
+                }).on('change', function (e) {
                     @this.set('agenzia', $(this).val());
                 });
 
@@ -600,15 +631,15 @@
                 }
             });
 
-            $('.valida_dal').on('change', function(e) {
+            $('.valida_dal').on('change', function (e) {
                 @this.set('valida_dal', $(this).val());
             });
 
-            $('.valida_al').on('change', function(e) {
+            $('.valida_al').on('change', function (e) {
                 @this.set('valida_al', $(this).val());
             });
 
-            $('.polizza_num').on('input', function(e) {
+            $('.polizza_num').on('input', function (e) {
                 @this.set('polizza_num', $(this).val());
             });
 
@@ -781,7 +812,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", "anagrafica_id"
             ];
 
             modals.forEach(value => {
@@ -797,28 +828,28 @@
             });
         }
 
-        $('.anagrafica_id').on('change', function(e) {
+        $('.anagrafica_id').on('change', function (e) {
             @this.set('anagrafica_id', $(this).val());
             updateAnagraficaButtons($(this).val());
         });
 
-        $('.compagnia_id').on('change', function(e) {
+        $('.compagnia_id').on('change', function (e) {
             @this.set('compagnia_id', $(this).val());
         });
 
-        $('.agenzia').on('change', function(e) {
+        $('.agenzia').on('change', function (e) {
             @this.set('agenzia', $(this).val());
         });
 
-        $('.polizza_num').on('input', function(e) {
+        $('.polizza_num').on('input', function (e) {
             @this.set('polizza_num', $(this).val());
         });
 
-        $('.valida_dal').on('change', function(e) {
+        $('.valida_dal').on('change', function (e) {
             @this.set('valida_dal', $(this).val());
         });
 
-        $('.valida_al').on('change', function(e) {
+        $('.valida_al').on('change', function (e) {
             @this.set('valida_al', $(this).val());
         });