]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6527 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 30 Nov 2023 15:10:42 +0000 (16:10 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 30 Nov 2023 15:10:42 +0000 (16:10 +0100)
app/Fluidbook/Compiler/Compiler.php
resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php

index 3551bbb753ab70bba7f19c7426495b3834b374f7..6b9401f5d35738cf2623917b7570cd9923304d25 100644 (file)
@@ -2437,7 +2437,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
 
     public static function getSourcesPath($version, $dir = null)
     {
-        $res = self::getFluidbookPlayerBaseDirectory();
+        $res = self::getPlayerBaseDirectory();
         if (null !== $dir) {
             $res .= $dir . '/';
         }
index 722edb899f7f076f1dedf664853c0848e1f36605..4e09d955c10f9e742eedc9a494cc98af1f334741 100644 (file)
@@ -8,8 +8,9 @@
 @endphp
 @if(isset($saveAction['active']) && !is_null($saveAction['active']['value']))
     <div id="saveActions" class="form-group">
-        @if($crud->entry->getTable() === "fluidbook_external_install_server")
-            <a id='verifyconnection' class='btn btn-primary mr-3' href='verifyconnection'>{{ __('Tester la connexion') }}</a>
+        @if($crud->entry && $crud->entry instanceof \App\Models\FluidbookExternalInstallServer)
+            <a id='verifyconnection' class='btn btn-primary mr-3'
+               href='verifyconnection'>{{ __('Tester la connexion') }}</a>
         @endif
         <input type="hidden" name="_save_action" value="{{ $saveAction['active']['value'] }}">
         @if(!empty($saveAction['options']))
 
                 <div class="btn-group" role="group">
                     @if(!empty($saveAction['options']))
-                <button id="bpSaveButtonsGroup" type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span><span class="sr-only">&#x25BC;</span></button>
-                <div class="dropdown-menu" aria-labelledby="bpSaveButtonsGroup">
+                        <button id="bpSaveButtonsGroup" type="button" class="btn btn-success dropdown-toggle"
+                                data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span
+                                class="caret"></span><span class="sr-only">&#x25BC;</span></button>
+                        <div class="dropdown-menu" aria-labelledby="bpSaveButtonsGroup">
                             @foreach( $saveAction['options'] as $value => $label)
-                    <button type="button" class="dropdown-item" data-value="{{ $value }}">{{$label}}</button>
+                                <button type="button" class="dropdown-item"
+                                        data-value="{{ $value }}">{{$label}}</button>
                             @endforeach
                         </div>
 
         @endif
 
         @if(!$crud->hasOperationSetting('showCancelButton') || $crud->getOperationSetting('showCancelButton') == true)
-            <a href="{{ $crud->hasAccess('list') ? url($crud->route) : url()->previous() }}" class="btn btn-default"><span class="la la-ban"></span> &nbsp;{{ trans('backpack::crud.cancel') }}</a>
+            <a href="{{ $crud->hasAccess('list') ? url($crud->route) : url()->previous() }}"
+               class="btn btn-default"><span class="la la-ban"></span> &nbsp;{{ trans('backpack::crud.cancel') }}</a>
         @endif
 
         @if ($crud->get('update.showDeleteButton') && $crud->get('delete.configuration') && $crud->hasAccess('delete'))
-            <button onclick="confirmAndDeleteEntry()" type="button" class="btn btn-danger float-right"><i class="la la-trash-alt"></i> {{ trans('backpack::crud.delete') }}</button>
+            <button onclick="confirmAndDeleteEntry()" type="button" class="btn btn-danger float-right"><i
+                    class="la la-trash-alt"></i> {{ trans('backpack::crud.delete') }}</button>
         @endif
     </div>
 @endif
     @endpush
 @endif
 @push('after_scripts')
-<script>
-
-    // this function checks if form is valid.
-    function checkFormValidity(form) {
-        // the condition checks if `checkValidity` is defined in the form (browser compatibility)
-        if (form[0].checkValidity) {
-            return form[0].checkValidity();
-        }
-        return false;
-    }
+    <script>
 
-    // this function checks if any of the inputs has errors and report them on page.
-    // we use it to report the errors after form validation fails and making the error fields visible
-    function reportValidity(form) {
-        // the condition checks if `reportValidity` is defined in the form (browser compatibility)
-        if (form[0].reportValidity) {
-            // hide the save actions drop down if open
-            $('#saveActions').find('.dropdown-menu').removeClass('show');
-            // validate and display form errors
-            form[0].reportValidity();
+        // this function checks if form is valid.
+        function checkFormValidity(form) {
+            // the condition checks if `checkValidity` is defined in the form (browser compatibility)
+            if (form[0].checkValidity) {
+                return form[0].checkValidity();
+            }
+            return false;
         }
-    }
 
-    function changeTabIfNeededAndDisplayErrors(form) {
-        // we get the first erroed field
-        var $firstErrorField = form.find(":invalid").first();
-        // we find the closest tab
-        var $closestTab = $($firstErrorField).closest('.tab-pane');
-        // if we found the tab we will change to that tab before reporting validity of form
-        if($closestTab.length) {
-            var id = $closestTab.attr('id');
-            // switch tabs
-            $('.nav a[href="#' + id + '"]').tab('show');
+        // this function checks if any of the inputs has errors and report them on page.
+        // we use it to report the errors after form validation fails and making the error fields visible
+        function reportValidity(form) {
+            // the condition checks if `reportValidity` is defined in the form (browser compatibility)
+            if (form[0].reportValidity) {
+                // hide the save actions drop down if open
+                $('#saveActions').find('.dropdown-menu').removeClass('show');
+                // validate and display form errors
+                form[0].reportValidity();
+            }
         }
-        reportValidity(form);
-    }
 
-    // make all submit buttons trigger HTML5 validation
-    jQuery(document).ready(function($) {
-
-        var selector = $('#bpSaveButtonsGroup').next();
-        var form = $(selector).closest('form');
-        var saveActionField = $('[name="_save_action"]');
-        var $defaultSubmitButton = $(form).find(':submit');
-        // this is the main submit button, the default save action.
-        $($defaultSubmitButton).on('click', function(e) {
-            e.preventDefault();
-            $saveAction = $(this).children('span').eq(1);
-            // if form is valid just submit it
-            if(checkFormValidity(form)) {
-                saveActionField.val( $saveAction.attr('data-value') );
-                form[0].requestSubmit();
-            }else{
-                // navigate to the tab where the first error happens
-                changeTabIfNeededAndDisplayErrors(form);
+        function changeTabIfNeededAndDisplayErrors(form) {
+            // we get the first erroed field
+            var $firstErrorField = form.find(":invalid").first();
+            // we find the closest tab
+            var $closestTab = $($firstErrorField).closest('.tab-pane');
+            // if we found the tab we will change to that tab before reporting validity of form
+            if ($closestTab.length) {
+                var id = $closestTab.attr('id');
+                // switch tabs
+                $('.nav a[href="#' + id + '"]').tab('show');
             }
-        });
+            reportValidity(form);
+        }
 
-        //this is for the anchors AKA other non-default save actions.
-        $(selector).find('button').each(function() {
-            $(this).click(function(e) {
-                //we check if form is valid
+        // make all submit buttons trigger HTML5 validation
+        jQuery(document).ready(function ($) {
+
+            var selector = $('#bpSaveButtonsGroup').next();
+            var form = $(selector).closest('form');
+            var saveActionField = $('[name="_save_action"]');
+            var $defaultSubmitButton = $(form).find(':submit');
+            // this is the main submit button, the default save action.
+            $($defaultSubmitButton).on('click', function (e) {
+                e.preventDefault();
+                $saveAction = $(this).children('span').eq(1);
+                // if form is valid just submit it
                 if (checkFormValidity(form)) {
-                    //if everything is validated we proceed with the submission
-                    var saveAction = $(this).data('value');
-                    saveActionField.val( saveAction );
+                    saveActionField.val($saveAction.attr('data-value'));
                     form[0].requestSubmit();
-                }else{
+                } else {
                     // navigate to the tab where the first error happens
                     changeTabIfNeededAndDisplayErrors(form);
                 }
-                e.stopPropagation();
+            });
+
+            //this is for the anchors AKA other non-default save actions.
+            $(selector).find('button').each(function () {
+                $(this).click(function (e) {
+                    //we check if form is valid
+                    if (checkFormValidity(form)) {
+                        //if everything is validated we proceed with the submission
+                        var saveAction = $(this).data('value');
+                        saveActionField.val(saveAction);
+                        form[0].requestSubmit();
+                    } else {
+                        // navigate to the tab where the first error happens
+                        changeTabIfNeededAndDisplayErrors(form);
+                    }
+                    e.stopPropagation();
+                });
             });
         });
-    });
 
-</script>
+    </script>
 
-@if ($crud->get('update.showDeleteButton') && $crud->get('delete.configuration') && $crud->hasAccess('delete'))
-    <script>
-        function confirmAndDeleteEntry() {
-            // Ask for confirmation before deleting an item
-            swal({
-                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: '{{ url($crud->route.'/'.$entry->getKey()) }}',
-                        type: 'DELETE',
-                        success: function(result) {
-                            if (result !== '1') {
-                                // 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) {
-                                        var type = entry[0];
-                                        entry[1].forEach(function(message, i) {
-                                            new Noty({
-                                                type: type,
-                                                text: message
-                                            }).show();
+    @if ($crud->get('update.showDeleteButton') && $crud->get('delete.configuration') && $crud->hasAccess('delete'))
+        <script>
+            function confirmAndDeleteEntry() {
+                // Ask for confirmation before deleting an item
+                swal({
+                    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: '{{ url($crud->route.'/'.$entry->getKey()) }}',
+                            type: 'DELETE',
+                            success: function (result) {
+                                if (result !== '1') {
+                                    // 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) {
+                                            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,
-                                    });
+                                    } 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,
+                                        });
+                                    }
                                 }
+                                // All is good, show a success message!
+                                swal({
+                                    title: "{!! trans('backpack::crud.delete_confirmation_title') !!}",
+                                    text: "{!! trans('backpack::crud.delete_confirmation_message') !!}",
+                                    icon: "success",
+                                    buttons: false,
+                                    closeOnClickOutside: false,
+                                    closeOnEsc: false,
+                                });
+
+                                // Redirect in 1 sec so that admins get to see the success message
+                                setTimeout(function () {
+                                    window.location.href = '{{ is_bool($crud->get('update.showDeleteButton')) ? url($crud->route) : (string) $crud->get('update.showDeleteButton') }}';
+                                }, 1000);
+                            },
+                            error: function () {
+                                // 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,
+                                });
                             }
-                            // All is good, show a success message!
-                            swal({
-                                title: "{!! trans('backpack::crud.delete_confirmation_title') !!}",
-                                text: "{!! trans('backpack::crud.delete_confirmation_message') !!}",
-                                icon: "success",
-                                buttons: false,
-                                closeOnClickOutside: false,
-                                closeOnEsc: false,
-                            });
-
-                            // Redirect in 1 sec so that admins get to see the success message
-                            setTimeout(function () {
-                                window.location.href = '{{ is_bool($crud->get('update.showDeleteButton')) ? url($crud->route) : (string) $crud->get('update.showDeleteButton') }}';
-                            }, 1000);
-                        },
-                        error: function() {
-                            // 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,
-                            });
-                        }
-                    });
-                }
-            });
-        }
-    </script>
-@endif
+                        });
+                    }
+                });
+            }
+        </script>
+    @endif
 @endpush