Skip to content

Commit

Permalink
Artwork [WEB-2982]
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgarwood committed Jan 21, 2025
1 parent fd5e715 commit 567c8a5
Showing 1 changed file with 29 additions and 61 deletions.
90 changes: 29 additions & 61 deletions app/Http/Controllers/Twill/ArtworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')]));
Expand Down

0 comments on commit 567c8a5

Please sign in to comment.