diff --git a/resources/ts/bo/base/common.ts b/resources/ts/bo/base/common.ts new file mode 100644 index 0000000..ff969df --- /dev/null +++ b/resources/ts/bo/base/common.ts @@ -0,0 +1,64 @@ +import Swal from "sweetalert2"; +import trans from "../../modules/trans"; +const elements = document.getElementsByClassName("confirmDeleteTenantTS"); + +if (elements) { + for (const element of elements) { + element.addEventListener("submit", (e) => { + const self = e.target as HTMLFormElement; + e.preventDefault(); + Swal.fire({ + title: trans.methods.__("Confirmez"), + text: trans.methods.__("Voulez-vous vraiment supprimer cet élément ?"), + color: getComputedStyle(document.body).getPropertyValue("--bs-body-color"), + icon: "error", + showCancelButton: true, + confirmButtonText:trans.methods.__("Oui"), + cancelButtonText: trans.methods.__("Annuler"), + // * Bootstrap Styling + customClass: { + confirmButton: "btn btn-primary mx-1", + cancelButton: "btn btn-danger mx-1", + }, + buttonsStyling: false, + background: getComputedStyle(document.body).getPropertyValue("--bs-body-bg"), + }).then((result) => { + if (result.isConfirmed) { + Swal.fire({ + title: trans.methods.__("Attention au conséquences"), + html: "Attention cette action est irréversible, toutes les informations liées à ce tenant seront supprimées !", + color: getComputedStyle(document.body).getPropertyValue("--bs-body-color"), + icon: "warning", + showCancelButton: true, + confirmButtonText:trans.methods.__("Je comprends le danger et suis conscient que celà aura des conséquences"), + cancelButtonText: trans.methods.__("Annuler"), + // * Bootstrap Styling + customClass: { + confirmButton: "btn btn-primary mx-1", + cancelButton: "btn btn-danger mx-1 mt-1", + }, + buttonsStyling: false, + background: getComputedStyle(document.body).getPropertyValue("--bs-body-bg"), + }).then((result) => { + if (result.isConfirmed) { + self?.submit(); + } + }); + } else if ( + /* Read more about handling dismissals below */ + result.dismiss === Swal.DismissReason.cancel + ) { + Swal.fire({ + title: trans.methods.__("L'opération n'as pas été effectuée"), + confirmButtonText: trans.methods.__("Ok"), + // * Bootstrap Styling + customClass: { + confirmButton: "btn btn-primary", + }, + buttonsStyling: false, + }); + } + }); + }); + } +} diff --git a/resources/ts/bo/bo.ts b/resources/ts/bo/bo.ts index fc77140..3868c74 100644 --- a/resources/ts/bo/bo.ts +++ b/resources/ts/bo/bo.ts @@ -9,3 +9,6 @@ import "./utilities/vue-bo"; // MODULES import "./../modules/sweetalert"; + +// CUSTOM +import "./base/common"; diff --git a/resources/views/bo/pages/tenants/edit.blade.php b/resources/views/bo/pages/tenants/edit.blade.php index 026e2fa..c69fbae 100644 --- a/resources/views/bo/pages/tenants/edit.blade.php +++ b/resources/views/bo/pages/tenants/edit.blade.php @@ -18,7 +18,7 @@
@can('delete', $tenantModel) -
@endcan
diff --git a/resources/views/bo/pages/tenants/index-list.blade.php b/resources/views/bo/pages/tenants/index-list.blade.php index d864c06..98bee22 100644 --- a/resources/views/bo/pages/tenants/index-list.blade.php +++ b/resources/views/bo/pages/tenants/index-list.blade.php @@ -19,7 +19,7 @@ @can('delete', $tenantModel) + method="POST" class="d-inline confirmDeleteTenantTS"> @endcan @method('DELETE') @csrf