Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create index tables using the Twill table builder #665

Draft
wants to merge 4 commits into
base: feature/twill-upgrade
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Helpers/CollectionHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class CollectionHelpers
*/
public static function collectApi($value = null)
{
return new \App\Libraries\Api\Models\ApiCollection($value);
return new \Aic\Hub\Foundation\Library\Api\Models\ApiCollection($value);
}
}
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
Loading
Loading