]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6109 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jul 2023 19:15:08 +0000 (21:15 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jul 2023 19:15:08 +0000 (21:15 +0200)
.docker/syncprodtodev.exclude
.docker/syncprodtodev.sh
app/Fields/FluidbookProjectManager.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/FluidbookPublication/EditOperation.php
app/Models/FluidbookPublication.php
app/Models/User.php
public/packages/fluidbook/toolbox/js/contextdownload.js
resources/views/columns/fluidbook_project_manager.blade.php [new file with mode: 0644]
resources/views/columns/fluidbook_status.blade.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php

index 6b1f38a77579bab2bd499e633689b6e39f591b59..3583598abdbd50ad6313e9edb760f523f2d234bd 100644 (file)
@@ -2,8 +2,13 @@ fluidbookpublication/packager
 fluidbookpublication/final
 fluidbookpublication/seo
 fluidbookpublication/pdf
+fluidbookcollection/final
 collection/final
 elearningpackage/final
 elearningmedia/final
 quiz/final
 debugbar
+app/public/elearningmedia
+app/public/elearningpackage
+app/public/fluidbookcollection
+app/public/quiz
index c647e85eb71815157c34e51e41aba69e11061c18..ee3cd2bb2a6df1e8a267b80fe9f3cd9dfb64cc81 100644 (file)
@@ -4,9 +4,12 @@ rsync -avz --delete --exclude-from /home/toolbox/dev/.docker/syncprodtodev.exclu
 rsync -avz --delete --exclude-from /home/toolbox/dev/.docker/syncprodtodev.exclude --delete-excluded /data/toolbox/storage/ /data/toolbox/dev/storage/
 # Sync database
 docker stop fluidbook-toolbox-dev-mariadb
+rm -rf /docker/fluidbook-toolbox-dev/database/data/*
 rsync -avz /docker/fluidbook-toolbox/database/data/ /docker/fluidbook-toolbox-dev/database/data/
 docker stop fluidbook-toolbox-mariadb
 rsync -avz /docker/fluidbook-toolbox/database/data/ /docker/fluidbook-toolbox-dev/database/data/
+sleep 1
+rsync -avz /docker/fluidbook-toolbox/database/data/ /docker/fluidbook-toolbox-dev/database/data/
 docker start fluidbook-toolbox-mariadb
 # Update and restart dev containers
 /docker/fluidbook-toolbox-dev/update
diff --git a/app/Fields/FluidbookProjectManager.php b/app/Fields/FluidbookProjectManager.php
new file mode 100644 (file)
index 0000000..b56cf31
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Fields;
+
+class FluidbookProjectManager extends CubedesignersTeamMember
+{
+    protected $_columnType = 'fluidbook_project_manager';
+    protected $_columnViewNamespace = 'columns';
+
+    public function _postSetAttributes()
+    {
+        parent::_postSetAttributes();
+        $this->setAttribute('optionsmodel_scope', 'currentTeam');
+    }
+}
index b54acc20ff4a669377b2765928ff53fb542b75af..284ce2b358a08f8eb63b8cfcb666dcb498e6d350 100644 (file)
@@ -11,6 +11,7 @@ trait EditOperation
     protected function setupEditRoutes($segment, $routeName, $controller)
     {
         Route::match(['get'], $segment . '/{id}/changestatus/{status}', $controller . '@changeStatus');
+        Route::match(['get'], $segment . '/{id}/changeprojectmanager/{status}', $controller . '@changeProjectManager');
     }
 
     protected function changeStatus($fluidbook_id, $newStatus)
@@ -22,7 +23,7 @@ trait EditOperation
             abort(401);
         }
         $fluidbook = FluidbookPublication::find($fluidbook_id);
-        if (!$fluidbook) {
+        if (!$fluidbook || !$fluidbook->allowsEdit()) {
             abort(404);
         }
         if ($fluidbook->status != $newStatus) {
@@ -32,4 +33,24 @@ trait EditOperation
         Alert::add('success', __('Status de la publication modifié'))->flash();
         return redirect(backpack_url('fluidbook-publication'));
     }
+
+    protected function changeProjectManager($fluidbook_id, $user)
+    {
+        if (!can('fluidbook-publication:admin')) {
+            abort(401);
+        }
+        if (!FluidbookPublication::hasPermission($fluidbook_id)) {
+            abort(401);
+        }
+        $fluidbook = FluidbookPublication::find($fluidbook_id);
+        if (!$fluidbook || !$fluidbook->allowsEdit()) {
+            abort(404);
+        }
+        if ($fluidbook->project_manager != $user) {
+            $fluidbook->project_manager = $user;
+            $fluidbook->save();
+        }
+        Alert::add('success', __('Chef de projet de la publication modifié'))->flash();
+        return redirect(backpack_url('fluidbook-publication'));
+    }
 }
index 13ecd965c21a4ae77164026e6f0b0d8379856f2b..17d39d45389fcde00426891cb546d742d3d97724 100644 (file)
@@ -4,11 +4,13 @@
 namespace App\Models;
 
 use App\Console\Commands\WorkshopMigration;
+use App\Fields\CubedesignersTeamMember;
 use App\Fields\FluidbookChapters;
 use App\Fields\FluidbookComposition;
 use App\Fields\FluidbookID;
 use App\Fields\FluidbookIDOptionnal;
 use App\Fields\FluidbookLocale;
+use App\Fields\FluidbookProjectManager;
 use App\Fields\FluidbookStatus;
 use App\Fields\FluidbookV3ID;
 use App\Fields\User;
@@ -206,6 +208,13 @@ class FluidbookPublication extends ToolboxSettingsModel
             ]
         );
 
+        $this->addField('project_manager', FluidbookProjectManager::class, __('Chef de projet'), [
+            'column' => true,
+            'filter' => true,
+            'searchLogic' => false,
+            'can' => 'fluidbook-publication:admin',
+        ]);
+
         $this->addField('section_composition', FormBigSection::class, __('Composition'));
         $this->addField('composition_fluidbook', Checkbox::class, __('Utiliser la composition d\'un autre fluidbook'), ['default' => false]);
         $this->addField('composition_fluidbook_id', FluidbookV3ID::class, __('Utiliser la composition d\'un autre fluidbook'), ['excluded_options' => $this->id, 'when' => ['composition_fluidbook' => 1]]);
@@ -908,32 +917,74 @@ class FluidbookPublication extends ToolboxSettingsModel
         return $l10n;
     }
 
-    public function generateThumbnailsPreview($sync = false) {
+    /**
+     * @return mixed
+     */
+    public function getNumbering()
+    {
+        return $this->_getCompositionAttribute('page_numbers');
+    }
+
+    /**
+     * @return array
+     */
+    public function getComposition()
+    {
+        $res = $this->_getCompositionAttribute('composition');
+        return $res;
+    }
+
+    protected function _getCompositionAttribute($name)
+    {
+        if (null === $this->_fluidbookToUseForComposition) {
+            if ($this->composition_fluidbook) {
+                $this->_fluidbookToUseForComposition = FluidbookPublication::withoutGlobalScopes()->find($this->composition_fluidbook_id);
+            } else {
+                $this->_fluidbookToUseForComposition = $this;
+            }
+        }
+        return $this->_fluidbookToUseForComposition->$name;
+    }
+
+
+    public function generateThumbnailsPreview($sync = false)
+    {
         $mobilefirstFluidbookId = $this->mobilefirstFluidbookId;
         $fm = null;
 
         $fn = 'dispatch';
-        if($sync)
+        if ($sync)
             $fn = 'dispatchSync';
 
-        if($mobilefirstFluidbookId) {
+        if ($mobilefirstFluidbookId) {
             $fm = self::find($mobilefirstFluidbookId);
         }
 
-        if($fm) {
-            if($sync) {
-                GenerateDeliveryThumbnailsPreview::$fn($fm,320, 683, 'mobile');
-            }else {
-                dispatch(new GenerateDeliveryThumbnailsPreview($fm,320, 683, 'mobile'))->onQueue('theme');
+        if ($fm) {
+            if ($sync) {
+                GenerateDeliveryThumbnailsPreview::$fn($fm, 320, 683, 'mobile');
+            } else {
+                dispatch(new GenerateDeliveryThumbnailsPreview($fm, 320, 683, 'mobile'))->onQueue('theme');
             }
         }
 
-        if($sync) {
+        if ($sync) {
             GenerateDeliveryThumbnailsPreview::$fn($this, 1920, 1201);
             GenerateDeliveryThumbnailsPreview::$fn($this, 320, 683, 'mobile');
-        }else {
+        } else {
             dispatch(new GenerateDeliveryThumbnailsPreview($this, 1920, 1201))->onQueue('theme');
             dispatch(new GenerateDeliveryThumbnailsPreview($this, 320, 683, 'mobile'))->onQueue('theme');
         }
     }
+
+    public function getProjectManagerEmail()
+    {
+        if (null !== $this->project_manager) {
+            $u = \App\Models\User::withoutGlobalScopes()->find($this->project_manager);
+            if ($u !== null) {
+                return $u->email;
+            }
+        }
+        return false;
+    }
 }
index a121efc32a8bcd7802f2fe058f33bffa77877511..86b22c84ec7dd16a200225ad6a9dff6148fee614 100644 (file)
@@ -15,7 +15,14 @@ class User extends \Cubedesigners\UserDatabase\Models\User
         $query->where('company', 7);
         $query->orderBy('enabled', 'ASC');
         $query->orderBy('id', 'ASC');
+    }
 
+    public function scopeCurrentTeam($query)
+    {
+        $query->where('company', 7);
+        $query->whereNotIn('id', [5963, 7]);
+        $query->where('enabled', 1);
+        $query->orderBy('id', 'ASC');
     }
 
     public function avatar()
index 5114371bd09b0b77e642e02f42efa21dd0252757..fcd9d5e0e5600b515788786f1ceb7c5ffaecb457 100644 (file)
@@ -27,14 +27,14 @@ $(function () {
                     action.disabled = action.disabled || (key == disabledOption);
                     action.isHtmlName = true;
                 }
-                actions[key] = action;
+                actions[key+""] = action;
             });
 
             $.each(actions, function (key, action) {
                 if (action !== sep) {
-                    items[key] = {name: action.label, isHtmlName: action.isHtmlName, disabled: action.disabled,};
+                    items[key+""] = {name: action.label, isHtmlName: action.isHtmlName, disabled: action.disabled,};
                 } else {
-                    items[key] = action;
+                    items[key+""] = action;
                 }
             });
 
diff --git a/resources/views/columns/fluidbook_project_manager.blade.php b/resources/views/columns/fluidbook_project_manager.blade.php
new file mode 100644 (file)
index 0000000..d354e44
--- /dev/null
@@ -0,0 +1,31 @@
+{{-- select_from_array column --}}
+@php
+    $values = data_get($entry, $column['name']);
+    $me=backpack_user()->id;
+    if($me==$values){
+        $v=__('Moi');
+    }else{
+        $v=isset($column['options'][$values])?e($column['options'][$values]):'<i>'.__('Indéfini').'</i>';
+    }
+
+    $options=$column['options'];
+    if(isset($options[$me])){
+        unset($options[$me]);
+        $options=[$me=>'<b>'.__('Moi').'</b>'] + $options;
+    }
+@endphp
+
+@if($entry->allowsEdit())
+    <span data-{{$entry->getOption('name')}}-{{$column['name']}}="{{$values}}">
+    <a href="#"
+       data-toggle="tooltip"
+       data-context-disabled-action="{{$values}}"
+       data-context-actions="{{json_encode($options)}}"
+       data-context-route="{{$crud->route}}/$id/changeprojectmanager/$action"
+       data-context-id="{{$entry->getKey()}}"
+       title="{{__('Attribuer le chef de projet')}}"
+    >{!! $v !!}</a>
+</span>
+@else
+    {!! $v !!}
+@endif
index c8fb53f9a571f555b24c869573635055d0d18dd3..dc03a9c7d0c9fb1f4663d9ad700f4c0992f87884 100644 (file)
@@ -5,7 +5,8 @@
 @endphp
 
 @can('fluidbook-publication:admin')
-    <span data-{{$entry->getOption('name')}}-{{$column['name']}}="{{$values}}">
+    @if($entry->allowsEdit())
+        <span data-{{$entry->getOption('name')}}-{{$column['name']}}="{{$values}}">
     <a href="#"
        data-toggle="tooltip"
        data-context-disabled-action="{{$values}}"
@@ -14,6 +15,9 @@
        data-context-id="{{$entry->getKey()}}"
        title="{{__('Changer le status')}}"
     >{{$v}}</a>
+    @else
+        {{$v}}
+    @endif
 </span>
 @endcan
 @cannot('fluidbook-publication:admin')
index aa876be0d29732028a7ec1e6194d7b81d97d127d..0dfa1ab661656249305272e3c43e12d9cfe43289 100644 (file)
 
 
 
-//    $actions['delivery']=[
-//                'label'=>__('Page de téléchargement'),
-//                'url'=>$base.'/delivery',
-//                ];
-//
-//    $actions['sep_download']='---------';
+    $actions['delivery']=[
+                'label'=>__('Page de téléchargement'),
+                'url'=>$base.'/delivery',
+                ];
+
+    $actions['sep_download']='---------';
     foreach (\App\Models\FluidbookPublication::getDownloadVersions() as $k=>$v) {
         if($k==='scorm'){
             continue;