From: Vincent Vanwaelscappel Date: Tue, 4 Jan 2022 09:53:12 +0000 (+0100) Subject: wip #4914 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=eade702e42f5ff976e3ef23e309e77ed9dab9469;p=odl.git wip #4914 @0.75 --- diff --git a/app/Http/Controllers/FrontController.php b/app/Http/Controllers/FrontController.php index e644bfe..a531ee8 100644 --- a/app/Http/Controllers/FrontController.php +++ b/app/Http/Controllers/FrontController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\Asset; +use App\Models\AssetTheme; use App\Models\Publication; use App\Models\Resource; use Cubist\Backpack\Magic\PageData; @@ -67,12 +69,11 @@ class FrontController extends Controller protected function _getMediaLibraryFromCMS() { - return []; + return ['themes' => PageData::fromEntities(AssetTheme::all()), 'assets' => PageData::fromEntities(Asset::whereNotNull('theme')->get())]; } protected function _getResourcesFromCMS() { - $res = Resource::find('1')->getPageData(); - return $res; + return Resource::find('1')->getPageData(); } } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 02d981b..e3f6866 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -46,7 +46,8 @@ class Asset extends CubistMagicAbstractModel 'column' => true, ]); $this->addField('file_upload', Files::class, 'Fichier', ['maxFiles' => 100]); - $this->addField('theme', SelectFromModel::class, 'Thème', ['optionsmodel' => AssetTheme::class, 'allows_null' => true, 'column' => true]); + $this->addField('file_thumb', Files::class, 'Miniature', ['when' => ['type' => ['audio', 'video']], 'hint' => 'Image utilisée sur la page "Médiathèque"']); + $this->addField('theme', SelectFromModel::class, 'Thème', ['when' => ['type' => ['audio', 'video']], 'optionsmodel' => AssetTheme::class, 'allows_null' => true, 'column' => true, 'hint' => 'Choisir un thème pour ajouter à la page "Médiathèque"']); $this->addField('keywords', Tags::class, 'Mots-clé', ['column' => true]); } diff --git a/resources/views/components/media-library/filter-interface.blade.php b/resources/views/components/media-library/filter-interface.blade.php index 2522931..cfd5224 100644 --- a/resources/views/components/media-library/filter-interface.blade.php +++ b/resources/views/components/media-library/filter-interface.blade.php @@ -62,7 +62,7 @@ py-2.5 px-5 rounded-full border peer-checked:bg-white peer-checked:text-black transition"> - {{ $theme }} + {{ $theme['name'] }} @endforeach diff --git a/resources/views/components/media-library/index.blade.php b/resources/views/components/media-library/index.blade.php index 79a332f..cfaac42 100644 --- a/resources/views/components/media-library/index.blade.php +++ b/resources/views/components/media-library/index.blade.php @@ -31,6 +31,7 @@ @foreach ($media as $item) @php + $theme=$themes[$item['theme']]; $player_data = [ 'ID' => $item['id'], 'player' => [ @@ -38,7 +39,6 @@ 'sources' => [ [ 'src' => $item['file'], - 'type' => $item['mime_type'], ] ] ], @@ -55,7 +55,7 @@ {{-- Width is 25% minus the gutters (2 * 0.625rem that comes from mx-2.5) --}} float-left w-[calc(100%/2-1.25rem)] md:w-[calc(100%/3-1.25rem)] lg:w-[calc(100%/4-1.25rem)] mx-2.5 mb-16 media-{{ $item['type'] }} - theme-{{ $item['theme']['id'] }}" + theme-{{ $item['theme'] }}" >
@@ -85,8 +85,8 @@
{{-- THEME LABEL --}} -
- {{ $item['theme']['title'] }} +
+ {{ $theme['name'] }}
{{-- Set min height of 2 lines so intial float layout is less likely to have misplaced blocks --}}
diff --git a/resources/views/front/media-library.blade.php b/resources/views/front/media-library.blade.php index fc9f8be..c3f4a98 100644 --- a/resources/views/front/media-library.blade.php +++ b/resources/views/front/media-library.blade.php @@ -3,6 +3,8 @@ @section('content') @php + + // TEMPORARY DATA MOCKUP $media = [ [ @@ -96,16 +98,29 @@ 'audio' => 'Podcast', ]; - $themes = [ - '1' => "Gouvernance", - '5' => "Responsabilité sociétale et environnementale", - '2' => "Communication", - '6' => "Recherche et innovation", - '3' => "Organisation", - '7' => "Qualité de service à l'usager", - '4' => "Système d'information", - '8' => "Conditions techniques", - ]; + $theme_order=[1,5,2,6,3,7,4,8,9,10,11,12,13,14,15,16]; + + $themes=[]; + foreach ($theme_order as $id){ + if(isset($medialibrary['themes'][$id])){ + $themes[$id]=$medialibrary['themes'][$id]; + } + } + + $media=[]; + + + foreach ($medialibrary['assets'] as $a) { + $media[$a['id']]=[ + 'id'=>$a->get('id'), + 'type'=>$a->get('type'), + 'theme'=>$a->get('theme'), + 'title'=>$a->get('title'), + 'file'=>$a->getImageURLbyCollection($a->get('file_upload')), + 'image'=>$a->getImageURLbyCollection($a->get('file_thumb')), + 'duration'=>45, + ]; + } @endphp
{{-- vertical padding so accents don't get cropped --}}