]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5382 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Sep 2022 18:11:43 +0000 (20:11 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Sep 2022 18:11:43 +0000 (20:11 +0200)
app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php
app/Http/Controllers/Admin/Operations/FluidbookQuote/AssignOperation.php
app/Jobs/FluidbookCollectionDownload.php
config/backpack/base.php
public/packages/fluidbook/toolbox/js/contextdownload.js [new file with mode: 0644]
resources/views/fields/fluidbook_composition.blade.php
resources/views/vendor/backpack/crud/buttons/elearningmedia/download.blade.php
resources/views/vendor/backpack/crud/buttons/elearningpackage/download.blade.php
resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php
resources/views/vendor/backpack/crud/buttons/fluidbook_quote/assign.blade.php
resources/views/vendor/backpack/crud/buttons/quiz/download.blade.php

index b4959e9ac13bc3b8d76a24939a27d1e9204243ef..849bc86e25a52cb0c514ee57759f1ea99b7d98bc 100644 (file)
@@ -21,7 +21,7 @@ trait DownloadOperation
 
     protected function download($id, $action)
     {
-        FluidbookCollectionDownload::dispatch(FluidbookCollection::find($id), $action, backpack_user())->onQueue('download');;
+        FluidbookCollectionDownload::dispatch(FluidbookCollection::find($id), $action, backpack_user())->onQueue('download');
         Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
         return redirect(backpack_url('fluidbook-collection'));
     }
index 517a6cec40e40e4a8f08beba3ece39643600861d..2bdd266b0d22c93bb27349787ead008c59061d76 100644 (file)
@@ -7,13 +7,15 @@ use App\Mail\FluidbookQuoteReceived;
 use App\Models\FluidbookQuote;
 use App\Models\User;
 use Illuminate\Support\Facades\Mail;
+use Illuminate\Support\Facades\Redirect;
 use Illuminate\Support\Facades\Route;
+use Prologue\Alerts\Facades\Alert;
 
 trait AssignOperation
 {
     protected function setupAssignRoutes($segment, $routeName, $controller)
     {
-        Route::match(['post'], $segment . '/{id}/assign', $controller . '@assign');
+        Route::match(['get'], $segment . '/{id}/assign/{reseller}', $controller . '@assign');
     }
 
     protected function setupAssignDefaults()
@@ -21,10 +23,10 @@ trait AssignOperation
         $this->crud->addButtonFromView('line', 'assign', 'fluidbook_quote.assign', 'end');
     }
 
-    protected function assign($id)
+    protected function assign($id, $reseller)
     {
         $quote = FluidbookQuote::where('id', $id)->first();
-        $quote->reseller = request()->get('reseller');
+        $quote->reseller = $reseller;
         $quote->status = 1;
         $quote->admin = backpack_user()->id;
         $quote->save();
@@ -34,5 +36,7 @@ trait AssignOperation
             $quoteMail->setQuote($quote);
             Mail::send($quoteMail);
         }
+        Alert::add('success', __('La demande de devis a été attribuée'))->flash();
+        return Redirect::to(session('_previous', ['url' => backpack_url('fluidbook-quote')])['url']);
     }
 }
index 2cbb0cccd6807bb0f624bae21434924c3e8ce700..b027f3a9b85a6a4cd7ede0bf8a50135f6ee69dd9 100644 (file)
@@ -123,7 +123,7 @@ class FluidbookCollectionDownload extends DownloadBase
                 $manifest = $path . '/' . $lang . '/imsmanifest.xml';
                 if ($lang === $default) {
                     rename($manifest, $manifestFile);
-                } else {
+                } else if (file_exists($manifest)) {
                     unlink($manifest);
                 }
             }
index c6441b97b8a53106e191b18421523e60ba7572e3..bca61281b99d09151b9b433e1ebae930557bdfab 100644 (file)
@@ -48,6 +48,8 @@ return [
         'packages/featherlight/featherlight.gallery.min.css',
         'packages/fluidbook/toolbox/css/style.css',
 
+        'https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.css',
+
         // Here's what's inside the bundle:
         // 'packages/@digitallyhappy/backstrap/css/style.min.css',
         // 'packages/animate.css/animate.min.css',
@@ -129,8 +131,11 @@ return [
         'packages/featherlight/featherlight.min.js',
         'packages/featherlight/featherlight.gallery.min.js',
         'packages/fluidbook/toolbox/js/bundle.js',
+        'packages/fluidbook/toolbox/js/contextdownload.js',
 
         'https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js',
+        "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js",
+        "https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js",
 
         // examples (everything inside the bundle, loaded from CDN)
         // 'https://code.jquery.com/jquery-3.4.1.min.js',
diff --git a/public/packages/fluidbook/toolbox/js/contextdownload.js b/public/packages/fluidbook/toolbox/js/contextdownload.js
new file mode 100644 (file)
index 0000000..8a09ab9
--- /dev/null
@@ -0,0 +1,56 @@
+$(function () {
+    $.contextMenu({
+        selector: '[data-context-actions]', trigger: 'left', build: function ($trigger, e) {
+            var route = $($trigger).data('context-route');
+            var id = $($trigger).data('context-id');
+            var actions = $($trigger).data('context-actions');
+            var items = {};
+            var confirm = $($trigger).data('context-confirm');
+            $.each(actions, function (key, name) {
+                items[key] = {name: name};
+            });
+
+            function replaceVariables(template, action) {
+                return template.replace(/\$id/g, id).replace(/\$action/g, action);
+            }
+
+            return {
+                callback: function (key, options) {
+                    var url = replaceVariables(route, key);
+                    var ok = function () {
+                        window.location = url;
+                        return true;
+                    }
+                    if (confirm === null) {
+                        return ok();
+                    }
+                    swal({
+                        title: confirm.title,
+                        text: replaceVariables(confirm.text, actions[key]),
+                        icon: "info",
+                        buttons: {
+                            cancel: {
+                                text: confirm.cancel,
+                                value: null,
+                                visible: true,
+                                className: "bg-secondary",
+                                closeModal: true,
+                            },
+                            delete: {
+                                text: confirm.confirm,
+                                value: true,
+                                visible: true,
+                                className: "bg-success",
+                            }
+                        },
+                    }).then((value) => {
+                        if (value) {
+                            ok();
+                        }
+                    });
+
+                }, items: items
+            };
+        }
+    });
+});
index 5f3bc6be600f4f141278b0ef3755f18962f9e1c5..e67bf3326c1b09217117b18e3e649b86afb770a5 100644 (file)
         <script src="https://cdnjs.cloudflare.com/ajax/libs/keypress/2.1.5/keypress.min.js"
                 integrity="sha512-JjqUcblrwIZTQBPL/azOhVHwq5uaeXkKzq7da3JZEP14Zg926vZZVhRhBBi+L2pWYquZ6r5P8OZYDYgOChtkOw=="
                 crossorigin="anonymous" referrerpolicy="no-referrer"></script>
-        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js"
-                integrity="sha512-kvg/Lknti7OoAw0GqMBP8B+7cGHvp4M9O9V6nAYG91FZVDMW3Xkkq5qrdMhrXiawahqU7IZ5CNsY/wWy1PpGTQ=="
-                crossorigin="anonymous" referrerpolicy="no-referrer"></script>
-        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js"
-                integrity="sha512-878jmOO2JNhN+hi1+jVWRBv1yNB7sVFanp2gA1bG++XFKNj4camtC1IyNi/VQEhM2tIbne9tpXD4xaPC4i4Wtg=="
-                crossorigin="anonymous" referrerpolicy="no-referrer"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
     @endpush
 
index ec4743b37e79c00661e428f78ef0bbc696836192..bcec3179089c19301ddc5534c51660594fda60a1 100644 (file)
@@ -1,51 +1,9 @@
-@once
-    @php
-        $showjs=false;
-        if($crud->getValue('seenExportJS')===null){
-        $showjs =true;
-        $crud->setValue('seenExportJS',true);
-        }
-    @endphp
-    @if($showjs)
-        <style>
-            a.exportelearningmedia {
-                position: relative;
-            }
-
-            a.exportelearningmedia select {
-                opacity: 0;
-                width: 100%;
-                height: 100%;
-                position: absolute;
-                top: 0;
-                left: 0;
-                cursor: pointer;
-            }
-        </style>
-        <script>
-            jQuery(document).ready(function ($) {
-                $('a.exportelearningmedia').on('click', function () {
-                    return false;
-                });
-                $('a.exportelearningmedia select').on('change', function () {
-                    var val = $(this).val();
-                    if (val <= 0 || val == null || val == 'null') {
-                        return;
-                    }
-                    var id = $(this).data('id');
-                    window.location = $(this).data('route') + "/" + id + "/download/" + val;
-                });
-            });
-        </script>
-    @endif
-@endonce
-
 <a class="btn btn-sm btn-link exportelearningmedia" href="#"
    data-toggle="tooltip"
-   title="{{__('Exporter le media')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
-    <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
-        <option value="" selected style="display: none">--</option>
-        <option value="download">{{__('Télécharger')}}</option>
-        <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
-    </select>
+   title="{{__('Exporter le media')}}"
+   data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+   data-context-route="{{$crud->route}}/$id/download/$action"
+   data-context-id="{{$entry->getKey()}}"
+>
+    <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
 </a>
index a2c17d13d279c2c3fd1215aff821f81f8bc0ef4a..9f72b511b35e4b0e97dab7e56fefc406d6b0a4d3 100644 (file)
@@ -1,51 +1,9 @@
-@once
-    @php
-        $showjs=false;
-        if($crud->getValue('seenExportJS')===null){
-        $showjs =true;
-        $crud->setValue('seenExportJS',true);
-        }
-    @endphp
-    @if($showjs)
-        <style>
-            a.exportelearningpackage {
-                position: relative;
-            }
-
-            a.exportelearningpackage select {
-                opacity: 0;
-                width: 100%;
-                height: 100%;
-                position: absolute;
-                top: 0;
-                left: 0;
-                cursor: pointer;
-            }
-        </style>
-        <script>
-            jQuery(document).ready(function ($) {
-                $('a.exportelearningpackage').on('click', function () {
-                    return false;
-                });
-                $('a.exportelearningpackage select').on('change', function () {
-                    var val = $(this).val();
-                    if (val <= 0 || val == null || val == 'null') {
-                        return;
-                    }
-                    var id = $(this).data('id');
-                    window.location = $(this).data('route') + "/" + id + "/download/" + val;
-                });
-            });
-        </script>
-    @endif
-@endonce
-
 <a class="btn btn-sm btn-link exportelearningpackage" href="#"
    data-toggle="tooltip"
-   title="{{__('Exporter le media')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
-    <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
-        <option value="" selected style="display: none">--</option>
-        <option value="download">{{__('Télécharger')}}</option>
-        <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
-    </select>
+   title="{{__('Exporter le package')}}"
+   data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+   data-context-route="{{$crud->route}}/$id/download/$action"
+   data-context-id="{{$entry->getKey()}}"
+>
+    <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
 </a>
index 5e94a06e023110f2992e950c5feeadaab643f26a..4b6b85208da47da1ef2cfdd715dfd053aa599ac3 100644 (file)
@@ -1,54 +1,15 @@
-@once
 @php
-$showjs=false;
-if($crud->getValue('seenExportJS')===null){
-$showjs =true;
-$crud->setValue('seenExportJS',true);
-}
-@endphp
-@if($showjs)
-<style>
-    a.exportcollection {
-        position: relative;
-    }
-
-    a.exportcollection select {
-        opacity: 0;
-        width: 100%;
-        height: 100%;
-        position: absolute;
-        top: 0;
-        left: 0;
-        cursor: pointer;
+    $actions=['download'=>__('Télécharger')];
+    if($entry->type==='scorm_multilang'){
+        $actions['scormcloud']=__('Tester sur Scorm Cloud');
     }
-</style>
-<script>
-    jQuery(document).ready(function ($) {
-        $('a.exportcollection').on('click', function () {
-            return false;
-        });
-        $('a.exportcollection select').on('change', function () {
-            var val = $(this).val();
-            if (val <= 0 || val == null || val == 'null') {
-                return;
-            }
-            var id = $(this).data('id');
-            window.location = $(this).data('route') + "/" + id + "/download/" + val;
-        });
-    });
-</script>
-@endif
-@endonce
-
+@endphp
 <a class="btn btn-sm btn-link exportcollection" href="#"
    data-toggle="tooltip"
-   title="{{__('Exporter la collection')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
-    <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
-        <option value="" selected style="display: none">--</option>
-        <option value="download">{{__('Télécharger')}}</option>
-        @if($entry->type==='scorm_multilang')
-        <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
-        @endif
-    </select>
+   title="{{__('Exporter la collection')}}"
+   data-context-actions="{{json_encode($actions)}}"
+   data-context-route="{{$crud->route}}/$id/download/$action"
+   data-context-id="{{$entry->getKey()}}"
+>
+    <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
 </a>
-
index 95bfce8aaf48eccb7d4e1bf844d9a5d87d7ee4b3..07d3d8114638de2890955e45d347d76b2bc22871 100644 (file)
@@ -1,83 +1,16 @@
-@once
-    @php
-        $showjs=false;
-        if($crud->getValue('seenAssignJS')===null){
-           $showjs =true;
-           $crud->setValue('seenAssignJS',true);
-        }
-    @endphp
-    @if($showjs)
-        <style>
-            a.assignto {
-                position: relative;
-            }
-
-            select.assign {
-                opacity: 0;
-                width: 100%;
-                height: 100%;
-                position: absolute;
-                top: 0;
-                left: 0;
-                cursor: pointer;
-            }
-        </style>
-        <script>
-            jQuery(document).ready(function ($) {
-                $('select.assign').on('change', function () {
-                    var val = $(this).val();
-                    if (val <= 0 || val == null || val == 'null') {
-                        return;
-                    }
-                    var option = $(this).find('option[value="' + val + '"]').text();
-                    var id = $(this).data('id');
-                    swal({
-                        title: "{!!__("Confier la demande de devis")!!}",
-                        text: "{!!__("Vous avez choisi l'option « :option »",['option'=>'"+ option +"'])!!}",
-                        icon: "info",
-                        buttons: {
-                            cancel: {
-                                text: "{!!__('Annuler')!!}",
-                                value: null,
-                                visible: true,
-                                className: "bg-secondary",
-                                closeModal: true,
-                            },
-                            delete: {
-                                text: "{!!__('Confirmer')!!}",
-                                value: true,
-                                visible: true,
-                                className: "bg-success",
-                            }
-                        },
-                    }).then((value) => {
-                        if (value) {
-                            $.ajax({
-                                url: '/fluidbook-quote/' + id + '/assign',
-                                type: 'POST',
-                                data: {reseller: val},
-                                success: function (result) {
-                                    window.location = '';
-                                }
-                            });
-                        }
-                    });
-
-                });
-            });
-        </script>
-    @endif
-@endonce
-
 @if($entry->status==0)
-    <a class="btn btn-sm btn-link assignto" nohref data-toggle="tooltip"
-       title="Assign to"><i class="la la-user-check"></i> {{__('Confier')}}
-        <select class="assign" data-id="{{$entry->getKey()}}">
-            <option value="null">-</option>
-            <option value="{{backpack_user()->id}}">{{__('Je vais traiter la demander')}}</option>
-{{--            <option value="5256">{{__('Confier à :reseller',['reseller'=>'Mallaury'])}}</option>--}}
-            <option value="94">{{__('Confier à :reseller',['reseller'=>'Kadreo'])}}</option>
-        </select>
+    <a class="btn btn-sm btn-link assignto" href="#" data-toggle="tooltip"
+       data-context-actions="{{json_encode([backpack_user()->id=>__('Je vais traiter la demander'),'94'=>__('Confier à :reseller',['reseller'=>'Kadreo'])])}}"
+       data-context-route="{{$crud->route}}/$id/assign/$action"
+       data-context-id="{{$entry->getKey()}}"
+       data-context-confirm="{{json_encode(
+        [
+            'title'=>__('Confier la demande de devis'),
+            'text'=>__("Vous avez choisi l'option « :option »",['option'=>'$action']),
+            'confirm'=>__('Confirmer'),
+            'cancel'=>__('Annuler')
+            ]
+            )}}"
+       title="{{__('Confier la demande à')}}"><i class="la la-user-check"></i> {{__('Confier')}}
     </a>
-
 @endif
index 91606b1e591fa4bf0a12ebf873be58257b66dd1a..ee2ccdc0387e7e82629c72fb269f2701d5b54aa5 100644 (file)
@@ -1,51 +1,9 @@
-@once
-    @php
-        $showjs=false;
-        if($crud->getValue('seenExportJS')===null){
-        $showjs =true;
-        $crud->setValue('seenExportJS',true);
-        }
-    @endphp
-    @if($showjs)
-        <style>
-            a.exportquiz {
-                position: relative;
-            }
-
-            a.exportquiz select {
-                opacity: 0;
-                width: 100%;
-                height: 100%;
-                position: absolute;
-                top: 0;
-                left: 0;
-                cursor: pointer;
-            }
-        </style>
-        <script>
-            jQuery(document).ready(function ($) {
-                $('a.exportquiz').on('click', function () {
-                    return false;
-                });
-                $('a.exportquiz select').on('change', function () {
-                    var val = $(this).val();
-                    if (val <= 0 || val == null || val == 'null') {
-                        return;
-                    }
-                    var id = $(this).data('id');
-                    window.location = $(this).data('route') + "/" + id + "/download/" + val;
-                });
-            });
-        </script>
-    @endif
-@endonce
-
 <a class="btn btn-sm btn-link exportquiz" href="#"
    data-toggle="tooltip"
-   title="{{__('Exporter le quiz')}}"><i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
-    <select data-route="{{$crud->route}}" data-id="{{$entry->getKey()}}">
-        <option value="" selected style="display: none">--</option>
-        <option value="download">{{__('Télécharger')}}</option>
-        <option value="scormcloud">{{__('Tester sur Scorm Cloud')}}</option>
-    </select>
+   title="{{__('Exporter le quiz')}}"
+   data-context-actions="{{json_encode(['download'=>__('Télécharger'),'scormcloud'=>__('Tester sur Scorm Cloud')])}}"
+   data-context-route="{{$crud->route}}/$id/download/$action"
+   data-context-id="{{$entry->getKey()}}"
+>
+    <i class="la la-arrow-circle-down"></i> {{__('Exporter')}}
 </a>