From: Vincent Vanwaelscappel Date: Thu, 1 Sep 2022 18:11:43 +0000 (+0200) Subject: wait #5382 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=65b5bd2e55dc9b9351959941712ca41a245f2b40;p=fluidbook-toolbox.git wait #5382 @2 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php index b4959e9ac..849bc86e2 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php @@ -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')); } diff --git a/app/Http/Controllers/Admin/Operations/FluidbookQuote/AssignOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookQuote/AssignOperation.php index 517a6cec4..2bdd266b0 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookQuote/AssignOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookQuote/AssignOperation.php @@ -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']); } } diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index 2cbb0cccd..b027f3a9b 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -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); } } diff --git a/config/backpack/base.php b/config/backpack/base.php index c6441b97b..bca61281b 100644 --- a/config/backpack/base.php +++ b/config/backpack/base.php @@ -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 index 000000000..8a09ab9be --- /dev/null +++ b/public/packages/fluidbook/toolbox/js/contextdownload.js @@ -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 + }; + } + }); +}); diff --git a/resources/views/fields/fluidbook_composition.blade.php b/resources/views/fields/fluidbook_composition.blade.php index 5f3bc6be6..e67bf3326 100644 --- a/resources/views/fields/fluidbook_composition.blade.php +++ b/resources/views/fields/fluidbook_composition.blade.php @@ -667,12 +667,6 @@ - - @endpush diff --git a/resources/views/vendor/backpack/crud/buttons/elearningmedia/download.blade.php b/resources/views/vendor/backpack/crud/buttons/elearningmedia/download.blade.php index ec4743b37..bcec31790 100644 --- a/resources/views/vendor/backpack/crud/buttons/elearningmedia/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/elearningmedia/download.blade.php @@ -1,51 +1,9 @@ -@once - @php - $showjs=false; - if($crud->getValue('seenExportJS')===null){ - $showjs =true; - $crud->setValue('seenExportJS',true); - } - @endphp - @if($showjs) - - - @endif -@endonce - {{__('Exporter')}} - + 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()}}" +> + {{__('Exporter')}} diff --git a/resources/views/vendor/backpack/crud/buttons/elearningpackage/download.blade.php b/resources/views/vendor/backpack/crud/buttons/elearningpackage/download.blade.php index a2c17d13d..9f72b511b 100644 --- a/resources/views/vendor/backpack/crud/buttons/elearningpackage/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/elearningpackage/download.blade.php @@ -1,51 +1,9 @@ -@once - @php - $showjs=false; - if($crud->getValue('seenExportJS')===null){ - $showjs =true; - $crud->setValue('seenExportJS',true); - } - @endphp - @if($showjs) - - - @endif -@endonce - {{__('Exporter')}} - + 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()}}" +> + {{__('Exporter')}} diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php index 5e94a06e0..4b6b85208 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php @@ -1,54 +1,15 @@ -@once @php -$showjs=false; -if($crud->getValue('seenExportJS')===null){ -$showjs =true; -$crud->setValue('seenExportJS',true); -} -@endphp -@if($showjs) - - -@endif -@endonce - +@endphp {{__('Exporter')}} - + title="{{__('Exporter la collection')}}" + data-context-actions="{{json_encode($actions)}}" + data-context-route="{{$crud->route}}/$id/download/$action" + data-context-id="{{$entry->getKey()}}" +> + {{__('Exporter')}} - diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_quote/assign.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_quote/assign.blade.php index 95bfce8aa..07d3d8114 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_quote/assign.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_quote/assign.blade.php @@ -1,83 +1,16 @@ -@once - @php - $showjs=false; - if($crud->getValue('seenAssignJS')===null){ - $showjs =true; - $crud->setValue('seenAssignJS',true); - } - @endphp - @if($showjs) - - - @endif -@endonce - @if($entry->status==0) - {{__('Confier')}} - + '$action']), + 'confirm'=>__('Confirmer'), + 'cancel'=>__('Annuler') + ] + )}}" + title="{{__('Confier la demande à')}}"> {{__('Confier')}} - @endif diff --git a/resources/views/vendor/backpack/crud/buttons/quiz/download.blade.php b/resources/views/vendor/backpack/crud/buttons/quiz/download.blade.php index 91606b1e5..ee2ccdc03 100644 --- a/resources/views/vendor/backpack/crud/buttons/quiz/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/quiz/download.blade.php @@ -1,51 +1,9 @@ -@once - @php - $showjs=false; - if($crud->getValue('seenExportJS')===null){ - $showjs =true; - $crud->setValue('seenExportJS',true); - } - @endphp - @if($showjs) - - - @endif -@endonce - {{__('Exporter')}} - + 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()}}" +> + {{__('Exporter')}}