Skip to content

Commit

Permalink
[4.x] Entries Fieldtype: Use columns from preferences (#8900)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Nov 7, 2023
1 parent 327a1ea commit a9b71e4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Fieldtypes/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Collection as SupportCollection;
use Statamic\Contracts\Data\Localization;
use Statamic\Contracts\Entries\Entry as EntryContract;
use Statamic\CP\Column;
use Statamic\Exceptions\CollectionNotFoundException;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;
Expand Down Expand Up @@ -375,6 +376,22 @@ public function toGqlType()

public function getColumns()
{
if (count($this->getConfiguredCollections()) === 1) {
$columns = $this->getBlueprint()->columns();

$status = Column::make('status')
->listable(true)
->visible(true)
->defaultVisibility(true)
->sortable(false);

$columns->put('status', $status);

$columns->setPreferred("collections.{$this->getConfiguredCollections()[0]}.columns");

return $columns->rejectUnlisted()->values();
}

return $this->getBlueprint()->columns()->values()->all();
}

Expand Down

0 comments on commit a9b71e4

Please sign in to comment.