]> _ Git - odl.git/commitdiff
wip #5022 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Jan 2022 20:21:48 +0000 (21:21 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Jan 2022 20:21:48 +0000 (21:21 +0100)
app/Http/Controllers/FrontController.php
resources/views/components/link.blade.php
resources/views/layouts/app.blade.php

index 84ded06c3010f41bdb52f024f21c1bdb3d40408a..58033d135d76d68d85605fc00e2ad0c5fd09ef84 100644 (file)
@@ -66,24 +66,29 @@ class FrontController extends Controller
     {
         $res = [];
 
+        foreach (Menu::all() as $item) {
+            $res[] = array_merge(['title' => $item->title], self::getLinkData($item->link));
+        }
+        return $res;
+    }
+
+    public static function getLinkData($link)
+    {
         $map = ['home' => '/accueil.html',
             'resources' => '/ressources.html',
             'medialibrary' => '/mediatheque.html',
             'fluidbook' => '/coeur/index.html'];
 
-        foreach (Menu::all() as $item) {
-            $link = ['title' => $item->title];
-            if (str_starts_with($item->link, 'asset_')) {
-                $assetId = substr($item->link, 6);
-                /** @var Asset $asset */
-                $asset = Asset::find($assetId);
-                $link['type'] = $asset->type;
-                $link['url'] = $asset->getFirstMediaUrl($asset->file_upload);
-            } else {
-                $link['type'] = 'page';
-                $link['url'] = $map[$item->link] ?? $item->link;
-            }
-            $res[] = $link;
+        $res = [];
+        if (str_starts_with($link, 'asset_')) {
+            $assetId = substr($link, 6);
+            /** @var Asset $asset */
+            $asset = Asset::find($assetId);
+            $res['type'] = $asset->type;
+            $res['url'] = $asset->getFirstMediaUrl($asset->file_upload);
+        } else {
+            $res['type'] = 'page';
+            $res['url'] = isset($map[$link]) ? '/front' . $map[$link] : $link;
         }
         return $res;
     }
index ce1b5b05a6f5724ad5776fda2860b73390d85a5f..dc8ed75fd2b0f3160692c297e90db77642de3e97 100644 (file)
@@ -3,11 +3,14 @@
     use Illuminate\Support\Str;
 
     if (!Str::startsWith($href, 'http') && !Str::startsWith($href, '/tools/')) {
-        $map=['home'=>'accueil.html','resources'=>'/ressources.html','medialibrary'=>'/mediatheque.html'];
-        if(isset($map[$href])){
-            $href=$map[$href];
+        $linkData=\App\Http\Controllers\FrontController::getLinkData($href);
+
+        $href=$linkData['url'];
+        if($linkData['type']==='pdf'){
+            $attributes["@click.prevent"]='openPDF($el.attributes.href.value)';
+        }else if($linkData['type']=='video'){
+            $attributes['@click.prevent']='openPDF($el.attributes.href.value)';
         }
-        $href = '/front' . $href; // Prefix URLs for frontend preview
     }
 @endphp
 
index f44479512bc34ff3b5d732a12bfecbc1aa2b8016..745fac66ad9856a4e928be70c7e8c3a782ab2f82 100644 (file)
 
 
         {{-- MENU OVERLAY --}}
-        <div x-data="resources()" class="overlay menu-overlay
+        <div class="overlay menu-overlay
                 bg-blue text-white
                 z-30"
              x-show="menuOpen"