File tree Expand file tree Collapse file tree
resources/js/components/fieldtypes/assets Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<template >
2- <div class =" flex text-2xs" >
3- <a v-for =" asset in value" :key =" asset.id" :href =" asset.url" target =" _blank" >
2+ <div class =" flex text-2xs gap-2 " >
3+ <a v-for =" asset in value.assets.splice(0, 5) " :key =" asset.id" :href =" asset.url" target =" _blank" >
44 <asset-thumbnail :asset =" asset" class =" -my-1 h-8 max-w-3xs" />
55 </a >
6+ <span
7+ v-if =" value.total > 6"
8+ class =" -my-1 flex h-8 min-w-8 items-center justify-center px-1.5 font-mono text-gray-600 dark:text-gray-400"
9+ >
10+ +&thinsp ; {{ value.total - 5 }}
11+ </span >
612 </div >
713</template >
814
Original file line number Diff line number Diff line change @@ -438,7 +438,16 @@ public function fieldRules()
438438
439439 public function preProcessIndex ($ data )
440440 {
441- return $ this ->getItemsForPreProcessIndex ($ data )->map (function ($ asset ) {
441+ $ total = $ data === null
442+ ? 0
443+ : ($ this ->config ('max_files ' ) === 1 ? 1 : count ($ data ));
444+
445+ // Since we only want to display a handful of thumbnails, we'll slice it up here so we don't perform more
446+ // augmentation overhead than necessary. e.g. 5 thumbs then +remainder. If the remainder is 1, we may
447+ // as well show all 6 since the +1 would almost take up the same amount of space.
448+ $ data = collect ($ data )->take (6 )->all ();
449+
450+ $ assets = $ this ->getItemsForPreProcessIndex ($ data )->map (function ($ asset ) {
442451 $ arr = [
443452 'id ' => $ asset ->id (),
444453 'is_image ' => $ isImage = $ asset ->isImage (),
@@ -456,6 +465,8 @@ public function preProcessIndex($data)
456465
457466 return $ arr ;
458467 });
468+
469+ return compact ('total ' , 'assets ' );
459470 }
460471
461472 protected function getItemsForPreProcessIndex ($ values ): Collection
You can’t perform that action at this time.
0 commit comments