]> _ Git - cubist_cms-back.git/commitdiff
wip #7930 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Jan 2026 15:42:20 +0000 (16:42 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Jan 2026 15:42:20 +0000 (16:42 +0100)
src/resources/views/fields/hiddenfilestandaloneform.blade.php

index 809de8f89ec466ee16ca2c2d63218c6267e12bf5..a348927afe0bb72e412c0483114cb3b00cc60063 100644 (file)
 @if ($crud->checkIfFieldIsFirstOfItsType($field))
     @push('crud_fields_scripts')
         <script>
+
+            function parseData(data) {
+                if (data.alert) {
+                    if(data.alert.icon===undefined){
+                        data.alert.icon='error'
+                    }
+                    // Show an alert with the result
+                    Swal.fire({
+                        title: data.alert.title,
+                        html: data.alert.message,
+                        icon: data.alert.icon,
+                        buttons: false,
+                    });
+                }
+                if (data.confirm) {
+                    if(data.confirm.icon===undefined){
+                        data.confirm.icon='warning'
+                    }
+
+                    Swal.fire({
+                        title: data.confirm.title,
+                        html: data.confirm.message,
+                        icon: data.confirm.icon,
+                        showCloseButton: true,
+                        showCancelButton: true,
+                        focusConfirm: false,
+                        focusCancel: true,
+                        dangerMode: true,
+                    }).then((value) => {
+                        if (value.isConfirmed) {
+                            $.ajax({
+                                url: data.confirm.confirm_action,
+                                success: function (result) {
+                                    parseData(result);
+                                },
+                                error: function (result) {
+                                    parseData(result);
+                                }
+                            });
+                        }
+                    });
+                }
+            }
+
             $(function () {
                 $('{!! $field['trigger'] !!}').on('click', function () {
                     $("#{!! $id !!}").find('input[type="file"]').get(0).click();
@@ -24,7 +68,7 @@
                     var f = $(form).ajaxSubmit({dataType: 'json'});
                     var xhr = f.data('jqxhr');
                     xhr.done(function (data) {
-                        console.log(data);
+                        parseData(data);
                     });
                 });
             });