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

[5.x] Query Scopes config option: show available query scopes in dropdown #9933

Merged
merged 7 commits into from May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/js/components/fieldtypes/TagsFieldtype.vue
Expand Up @@ -4,6 +4,7 @@
:name="name"
:clearable="config.clearable"
:close-on-select="false"
:options="config.options"
:disabled="config.disabled || isReadOnly"
:multiple="true"
:placeholder="__(config.placeholder)"
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/fieldtypes.php
Expand Up @@ -159,6 +159,7 @@
'table.title' => 'Table',
'taggable.title' => 'Taggable',
'taggable.config.placeholder' => 'Type and press ↩ Enter',
'taggable.config.options' => 'Provide pre-defined tags that can be selected.',
'taxonomies.title' => 'Taxonomies',
'template.config.blueprint' => 'Adds a "map to blueprint" option. Learn more in the [documentation](https://statamic.dev/views#inferring-templates-from-entry-blueprints).',
'template.config.folder' => 'Only show templates in this folder.',
Expand Down
7 changes: 7 additions & 0 deletions src/Fieldtypes/Assets/Assets.php
Expand Up @@ -8,9 +8,11 @@
use Statamic\Facades\Asset;
use Statamic\Facades\AssetContainer;
use Statamic\Facades\GraphQL;
use Statamic\Facades\Scope;
use Statamic\Fields\Fieldtype;
use Statamic\GraphQL\Types\AssetInterface;
use Statamic\Http\Resources\CP\Assets\Asset as AssetResource;
use Statamic\Query\Scopes\Filter;
use Statamic\Support\Arr;
use Statamic\Support\Str;

Expand Down Expand Up @@ -96,6 +98,11 @@ protected function configFieldItems(): array
'display' => __('Query Scopes'),
'instructions' => __('statamic::fieldtypes.assets.config.query_scopes'),
'type' => 'taggable',
'options' => Scope::all()
->reject(fn ($scope) => $scope instanceof Filter)
->map->handle()
->values()
->all(),
],
],
],
Expand Down
6 changes: 6 additions & 0 deletions src/Fieldtypes/Entries.php
Expand Up @@ -18,6 +18,7 @@
use Statamic\Http\Resources\CP\Entries\Entries as EntriesResource;
use Statamic\Http\Resources\CP\Entries\Entry as EntryResource;
use Statamic\Query\OrderedQueryBuilder;
use Statamic\Query\Scopes\Filter;
use Statamic\Query\Scopes\Filters\Concerns\QueriesFilters;
use Statamic\Query\Scopes\Filters\Fields\Entries as EntriesFilter;
use Statamic\Query\StatusQueryBuilder;
Expand Down Expand Up @@ -105,6 +106,11 @@ protected function configFieldItems(): array
'display' => __('Query Scopes'),
'instructions' => __('statamic::fieldtypes.entries.config.query_scopes'),
'type' => 'taggable',
'options' => Scope::all()
->reject(fn ($scope) => $scope instanceof Filter)
->map->handle()
->values()
->all(),
],
],
],
Expand Down
13 changes: 13 additions & 0 deletions src/Fieldtypes/Taggable.php
Expand Up @@ -20,6 +20,19 @@ protected function configFieldItems(): array
'type' => 'text',
'default' => __('statamic::fieldtypes.taggable.config.placeholder'),
],
'options' => [
'display' => __('Options'),
'instructions' => __('statamic::fieldtypes.taggable.config.options'),
'type' => 'list',
'add_button' => __('Add Option'),
],
];
}

public function preload()
{
return [
'options' => $this->config('options', []),
];
}

Expand Down
7 changes: 7 additions & 0 deletions src/Fieldtypes/Terms.php
Expand Up @@ -13,13 +13,15 @@
use Statamic\Facades;
use Statamic\Facades\Blink;
use Statamic\Facades\GraphQL;
use Statamic\Facades\Scope;
use Statamic\Facades\Site;
use Statamic\Facades\Taxonomy;
use Statamic\Facades\Term;
use Statamic\Facades\User;
use Statamic\GraphQL\Types\TermInterface;
use Statamic\Http\Resources\CP\Taxonomies\Terms as TermsResource;
use Statamic\Query\OrderedQueryBuilder;
use Statamic\Query\Scopes\Filter;
use Statamic\Query\Scopes\Filters\Fields\Terms as TermsFilter;
use Statamic\Support\Arr;
use Statamic\Support\Str;
Expand Down Expand Up @@ -95,6 +97,11 @@ protected function configFieldItems(): array
'display' => __('Query Scopes'),
'instructions' => __('statamic::fieldtypes.terms.config.query_scopes'),
'type' => 'taggable',
'options' => Scope::all()
->reject(fn ($scope) => $scope instanceof Filter)
->map->handle()
->values()
->all(),
],
],
],
Expand Down
7 changes: 7 additions & 0 deletions src/Fieldtypes/Users.php
Expand Up @@ -5,10 +5,12 @@
use Illuminate\Support\Collection;
use Statamic\CP\Column;
use Statamic\Facades\GraphQL;
use Statamic\Facades\Scope;
use Statamic\Facades\Search;
use Statamic\Facades\User;
use Statamic\GraphQL\Types\UserType;
use Statamic\Query\OrderedQueryBuilder;
use Statamic\Query\Scopes\Filter;
use Statamic\Query\Scopes\Filters\Fields\User as UserFilter;
use Statamic\Search\Result;
use Statamic\Support\Arr;
Expand Down Expand Up @@ -61,6 +63,11 @@ protected function configFieldItems(): array
'display' => __('Query Scopes'),
'instructions' => __('statamic::fieldtypes.users.config.query_scopes'),
'type' => 'taggable',
'options' => Scope::all()
->reject(fn ($scope) => $scope instanceof Filter)
->map->handle()
->values()
->all(),
],
],
],
Expand Down
7 changes: 7 additions & 0 deletions src/Forms/Fieldtype.php
Expand Up @@ -6,9 +6,11 @@
use Statamic\Data\DataCollection;
use Statamic\Facades;
use Statamic\Facades\GraphQL;
use Statamic\Facades\Scope;
use Statamic\Fieldtypes\Relationship;
use Statamic\GraphQL\Types\FormType;
use Statamic\Query\ItemQueryBuilder;
use Statamic\Query\Scopes\Filter;

class Fieldtype extends Relationship
{
Expand Down Expand Up @@ -47,6 +49,11 @@ protected function configFieldItems(): array
'display' => __('Query Scopes'),
'instructions' => __('statamic::fieldtypes.form.config.query_scopes'),
'type' => 'taggable',
'options' => Scope::all()
->reject(fn ($scope) => $scope instanceof Filter)
->map->handle()
->values()
->all(),
],
];
}
Expand Down