]> _ Git - odl.git/commitdiff
wip #4914 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jan 2022 09:53:12 +0000 (10:53 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jan 2022 09:53:12 +0000 (10:53 +0100)
app/Http/Controllers/FrontController.php
app/Models/Asset.php
resources/views/components/media-library/filter-interface.blade.php
resources/views/components/media-library/index.blade.php
resources/views/front/media-library.blade.php

index e644bfec19d03a33eeb4c65f85f8ac0cfdec941f..a531ee82406d235c745b2a9e65ee878666bcf06b 100644 (file)
@@ -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();
     }
 }
index 02d981b06ba3dfb62f83a449938e88bcb136cf1c..e3f68660e0c6e7e7d51c2216c8b128052d075391 100644 (file)
@@ -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]);
     }
 
index 2522931f77ba66153b13cde6b5efee711763f339..cfd52241d02f977d815143388fadfccaf7bb7910 100644 (file)
@@ -62,7 +62,7 @@
                                          py-2.5 px-5 rounded-full border
                                          peer-checked:bg-white peer-checked:text-black
                                          transition">
-                                    {{ $theme }}
+                                    {{ $theme['name'] }}
                                 </span>
                         </label>
                     @endforeach
index 79a332fb4a66c5509ddef843df4ecf66aaa5b32d..cfaac42b378b7bc73298e4a578daad1f0e0cee67 100644 (file)
@@ -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'] }}"
             >
                 <div class="media-item-image relative bg-cover bg-no-repeat rounded-md pb-[56.25%]" style="background-image:url({{ $item['image'] }})">
 
@@ -85,8 +85,8 @@
                     </x-duration>
                 </div>
                 {{-- THEME LABEL --}}
-                <div class="mt-2.5 font-secondary font-medium text-xs leading-none" style="color:{{ $item['theme']['color'] }}">
-                    {{ $item['theme']['title'] }}
+                <div class="mt-2.5 font-secondary font-medium text-xs leading-none" style="color:{{ $theme['color'] }}">
+                    {{ $theme['name'] }}
                 </div>
                 {{-- Set min height of 2 lines so intial float layout is less likely to have misplaced blocks --}}
                 <div class="mt-1.5 font-semibold leading-snug min-h-[2.75em]">
index fc9f8bec2f72ab74138d64006e39bba72bd64a2c..c3f4a9884ae1e464b6fa1424b283b4e7cbea7d60 100644 (file)
@@ -3,6 +3,8 @@
 @section('content')
 
     @php
+
+
         // TEMPORARY DATA MOCKUP
         $media = [
             [
             '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
 
     <div class="overflow-hidden py-2">{{-- vertical padding so accents don't get cropped --}}