File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
resources/js/components/fieldtypes/assets Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 22
33 <div class =" text-2xs flex" >
44 <a
5- v-for =" asset in value"
5+ v-for =" asset in value.assets.slice(0, value.total > 6 ? 5 : 6) "
66 :key =" asset.id"
77 :href =" asset.url"
88 target =" _blank"
99 >
1010 <asset-thumbnail :asset =" asset" class =" h-8 max-w-3xs -my-1" />
1111 </a >
12+ <span
13+ v-if =" value.total > 6"
14+ 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"
15+ >
16+ +&thinsp ; {{ value.total - 5 }}
17+ </span >
1218 </div >
1319
1420</template >
Original file line number Diff line number Diff line change @@ -345,7 +345,16 @@ public function fieldRules()
345345
346346 public function preProcessIndex ($ data )
347347 {
348- return $ this ->getItemsForPreProcessIndex ($ data )->map (function ($ asset ) {
348+ $ total = $ data === null
349+ ? 0
350+ : ($ this ->config ('max_files ' ) === 1 ? 1 : count ($ data ));
351+
352+ // Since we only want to display a handful of thumbnails, we'll slice it up here so we don't perform more
353+ // augmentation overhead than necessary. e.g. 5 thumbs then +remainder. If the remainder is 1, we may
354+ // as well show all 6 since the +1 would almost take up the same amount of space.
355+ $ data = collect ($ data )->take (6 )->all ();
356+
357+ $ assets = $ this ->getItemsForPreProcessIndex ($ data )->map (function ($ asset ) {
349358 $ arr = [
350359 'id ' => $ asset ->id (),
351360 'is_image ' => $ isImage = $ asset ->isImage (),
@@ -363,6 +372,8 @@ public function preProcessIndex($data)
363372
364373 return $ arr ;
365374 });
375+
376+ return compact ('total ' , 'assets ' );
366377 }
367378
368379 protected function getItemsForPreProcessIndex ($ values ): Collection
You can’t perform that action at this time.
0 commit comments