From 798a523dd53d2cce62178fa180dc0fdce807f792 Mon Sep 17 00:00:00 2001 From: Zach Garwood Date: Tue, 21 Jan 2025 10:57:26 -0600 Subject: [PATCH] Artwork [WEB-2982] --- .../Controllers/Twill/ArtworkController.php | 79 ++++++++----------- 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/app/Http/Controllers/Twill/ArtworkController.php b/app/Http/Controllers/Twill/ArtworkController.php index c90b57790..3e9601557 100644 --- a/app/Http/Controllers/Twill/ArtworkController.php +++ b/app/Http/Controllers/Twill/ArtworkController.php @@ -2,54 +2,11 @@ namespace App\Http\Controllers\Twill; -class ArtworkController extends \App\Http\Controllers\Twill\BaseApiController -{ - protected $moduleName = 'artworks'; - protected $hasAugmentedModel = true; - - protected $indexOptions = [ - 'publish' => false, - 'bulkPublish' => false, - 'feature' => false, - 'bulkFeature' => false, - 'restore' => false, - 'bulkRestore' => false, - 'bulkDelete' => false, - 'reorder' => false, - 'permalink' => true, - ]; - - protected $indexColumns = [ - 'image' => [ - 'thumb' => true, - 'present' => true, - 'presenter' => 'imageThumb', - 'variant' => [ - 'role' => 'hero', - 'crop' => 'default', - ], - ], - 'fullTitle' => [ - 'title' => 'Title', - 'field' => 'fullTitle', - ], - 'main_reference_number' => [ - 'title' => 'Reference number', - 'field' => 'main_reference_number', - ], - 'augmented' => [ - 'title' => 'Augmented?', - 'field' => 'augmented', - 'present' => true, - ], - 'artist_display' => [ - 'title' => 'Artist', - 'field' => 'artist_display', - ], - ]; - - protected $titleColumnKey = 'fullTitle'; +use A17\Twill\Services\Listings\Columns\Text; +use A17\Twill\Services\Listings\TableColumns; +class ArtworkController extends BaseApiController +{ protected $browserColumns = [ 'fullTitle' => [ 'title' => 'Title', @@ -62,6 +19,34 @@ class ArtworkController extends \App\Http\Controllers\Twill\BaseApiController */ protected $formWith = []; + public function setUpController(): void + { + parent::setUpController(); + $this->enableAugmentedModel(); + $this->enableShowImage(); + $this->setTitleColumnKey('fullTitle'); + $this->setModuleName('artworks'); + } + + protected function additionalIndexTableColumns(): TableColumns + { + $columns = TableColumns::make(); + $columns->add( + Text::make() + ->title('Reference number') + ->field('main_reference_number') + ->optional() + ); + $columns->add( + Text::make() + ->title('Artist') + ->field('artist_display') + ->optional() + ); + return $columns; + } + + protected function indexData($request) { return [];