From 567c8a544c1a3a090bf7ac805195070c0a753826 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 | 90 ++++++------------- 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/app/Http/Controllers/Twill/ArtworkController.php b/app/Http/Controllers/Twill/ArtworkController.php index c90b57790..b0479cbec 100644 --- a/app/Http/Controllers/Twill/ArtworkController.php +++ b/app/Http/Controllers/Twill/ArtworkController.php @@ -2,69 +2,37 @@ 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; +use Illuminate\Http\JsonResponse; - protected $browserColumns = [ - 'fullTitle' => [ - 'title' => 'Title', - 'field' => 'fullTitle', - ], - ]; - - /** - * Relations to eager load for the form view - */ - protected $formWith = []; +class ArtworkController extends BaseApiController +{ + public function setUpController(): void + { + parent::setUpController(); + $this->enableAugmentedModel(); + $this->enableShowImage(); + $this->setTitleColumnKey('fullTitle'); + $this->setModuleName('artworks'); + } - protected function indexData($request) + protected function additionalIndexTableColumns(): TableColumns { - return []; + $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 formData($request) @@ -80,7 +48,7 @@ protected function formData($request) ]; } - public function browser(): \Illuminate\Http\JsonResponse + public function browser(): JsonResponse { // Allow to filter by IDS when listing artworks. return response()->json($this->getBrowserData(['id' => request('artwork_ids')]));