]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5899 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Apr 2023 14:36:52 +0000 (16:36 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Apr 2023 14:36:52 +0000 (16:36 +0200)
resources/views/vendor/backpack/crud/buttons/delete.blade.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/delete.blade.php

index 3e977d1071648ece070199db09f0ceb41fab7f13..38f08d472b687d20c926cd33b25a63d340e7c1e3 100644 (file)
 @if ($crud->hasAccess('delete'))
-       <a href="javascript:void(0)" onclick="deleteEntry(this)" data-route="{{ url($crud->route.'/'.$entry->getKey()) }}" class="btn btn-sm btn-link" data-button-type="delete"><i class="la la-trash"></i> {{ trans('backpack::crud.delete') }}</a>
+    <a href="javascript:void(0)" onclick="deleteEntry(this)" data-route="{{ url($crud->route.'/'.$entry->getKey()) }}"
+       class="btn btn-sm btn-link" data-button-type="delete"><i
+            class="la la-trash"></i> {{ trans('backpack::crud.delete') }}</a>
 @endif
 
 {{-- Button Javascript --}}
 {{-- - used right away in AJAX operations (ex: List) --}}
 {{-- - pushed to the end of the page, after jQuery is loaded, for non-AJAX operations (ex: Show) --}}
-@push('after_scripts') @if (request()->ajax()) @endpush @endif
+@push('after_scripts') @if (request()->ajax())
+    @endpush
+@endif
 <script>
 
-       if (typeof deleteEntry != 'function') {
-         $("[data-button-type=delete]").unbind('click');
+    if (typeof deleteEntry != 'function') {
+        $("[data-button-type=delete]").unbind('click');
 
-         function deleteEntry(button) {
-               // ask for confirmation before deleting an item
-               // e.preventDefault();
-               var route = $(button).attr('data-route');
+        function deleteEntry(button) {
+            // ask for confirmation before deleting an item
+            // e.preventDefault();
+            var route = $(button).attr('data-route');
 
-               Swal.fire({
-                 title: "{!! trans('backpack::base.warning') !!}",
-                 text: "{!! trans('backpack::crud.delete_confirm') !!}",
-                 icon: "warning",
-                 buttons: ["{!! trans('backpack::crud.cancel') !!}", "{!! trans('backpack::crud.delete') !!}"],
-                 dangerMode: true,
-               }).then((value) => {
-                       if (value) {
-                               $.ajax({
-                             url: route,
-                             type: 'DELETE',
-                             success: function(result) {
-                                 if (result == 1) {
-                                                 // Redraw the table
-                                                 if (typeof crud != 'undefined' && typeof crud.table != 'undefined') {
-                                                         // Move to previous page in case of deleting the only item in table
-                                                         if(crud.table.rows().count() === 1) {
-                                                           crud.table.page("previous");
-                                                         }
+            Swal.fire({
+                title: "{{$deleteConfirmTitle??__('Suppression d\'un élément')}}",
+                text: "{{$deleteConfirmText??__('Souhaitez-vous réellement supprimer cet élément ?')}}",
+                icon: "warning",
+                showCloseButton: true,
+                showCancelButton: true,
+                focusConfirm: false,
+                focusCancel: true,
+                dangerMode: true,
+            }).then((value) => {
+                if (value.isConfirmed) {
+                    $.ajax({
+                        url: route,
+                        type: 'DELETE',
+                        success: function (result) {
+                            if (result == 1) {
+                                // Redraw the table
+                                if (typeof crud != 'undefined' && typeof crud.table != 'undefined') {
+                                    // Move to previous page in case of deleting the only item in table
+                                    if (crud.table.rows().count() === 1) {
+                                        crud.table.page("previous");
+                                    }
 
-                                                         crud.table.draw(false);
-                                                 }
+                                    crud.table.draw(false);
+                                }
 
-                                         // Show a success notification bubble
-                                     new Noty({
-                                   type: "success",
-                                   text: "{!! '<strong>'.trans('backpack::crud.delete_confirmation_title').'</strong><br>'.trans('backpack::crud.delete_confirmation_message') !!}"
-                                 }).show();
+                                // Show a success notification bubble
+                                new Noty({
+                                    type: "success",
+                                    text: "{!! '<strong>'.trans('backpack::crud.delete_confirmation_title').'</strong><br>'.trans('backpack::crud.delete_confirmation_message') !!}"
+                                }).show();
 
-                                     // Hide the modal, if any
-                                     $('.modal').modal('hide');
-                                 } else {
-                                     // if the result is an array, it means
-                                     // we have notification bubbles to show
-                                         if (result instanceof Object) {
-                                               // trigger one or more bubble notifications
-                                               Object.entries(result).forEach(function(entry, index) {
-                                                 var type = entry[0];
-                                                 entry[1].forEach(function(message, i) {
-                                                         new Noty({
-                                                   type: type,
-                                                   text: message
-                                                 }).show();
-                                                 });
-                                               });
-                                         } else {// Show an error alert
-                                             swal({
-                                               title: "{!! trans('backpack::crud.delete_confirmation_not_title') !!}",
-                                   text: "{!! trans('backpack::crud.delete_confirmation_not_message') !!}",
-                                               icon: "error",
-                                               timer: 4000,
-                                               buttons: false,
-                                             });
-                                         }
-                                 }
-                             },
-                             error: function(result) {
-                                 // Show an alert with the result
-                                 swal({
-                               title: "{!! trans('backpack::crud.delete_confirmation_not_title') !!}",
-                        text: "{!! trans('backpack::crud.delete_confirmation_not_message') !!}",
-                               icon: "error",
-                               timer: 4000,
-                               buttons: false,
-                             });
-                             }
-                         });
-                       }
-               });
+                                // Hide the modal, if any
+                                $('.modal').modal('hide');
+                            } else {
+                                // if the result is an array, it means
+                                // we have notification bubbles to show
+                                if (result instanceof Object) {
+                                    // trigger one or more bubble notifications
+                                    Object.entries(result).forEach(function (entry, index) {
+                                        var type = entry[0];
+                                        entry[1].forEach(function (message, i) {
+                                            new Noty({
+                                                type: type,
+                                                text: message
+                                            }).show();
+                                        });
+                                    });
+                                } else {// Show an error alert
+                                    swal({
+                                        title: "{!! trans('backpack::crud.delete_confirmation_not_title') !!}",
+                                        text: "{!! trans('backpack::crud.delete_confirmation_not_message') !!}",
+                                        icon: "error",
+                                        timer: 4000,
+                                        buttons: false,
+                                    });
+                                }
+                            }
+                        },
+                        error: function (result) {
+                            // Show an alert with the result
+                            swal({
+                                title: "{!! trans('backpack::crud.delete_confirmation_not_title') !!}",
+                                text: "{!! trans('backpack::crud.delete_confirmation_not_message') !!}",
+                                icon: "error",
+                                timer: 4000,
+                                buttons: false,
+                            });
+                        }
+                    });
+                }
+            });
 
-      }
-       }
+        }
+    }
 
-       // make it so that the function above is run after each DataTable draw event
-       // crud.addFunctionToDataTablesDrawEventQueue('deleteEntry');
+    // make it so that the function above is run after each DataTable draw event
+    // crud.addFunctionToDataTablesDrawEventQueue('deleteEntry');
 </script>
-@if (!request()->ajax()) @endpush @endif
+@if (!request()->ajax())
+    @endpush
+@endif
index a9e489fa2e7d312785a2513335b4dd2c3ca835cc..9e27ce057cfc270085d0d15c3ba9c0829f94dfaa 100644 (file)
@@ -1,4 +1,8 @@
 {{-- __('!! Paramètres des fluidbooks') --}}
+@php
+    $deleteConfirmTitle=__('Suppression d\'une publication');
+    $deleteConfirmText=__('Souhaitez-vous réellement supprimer cette publication ?');
+@endphp
 @if($entry->allowsDelete())
     @include('crud::buttons.delete')
 @endif