|
6 | 6 | use Statamic\Contracts\Structures\Nav as NavContract; |
7 | 7 | use Statamic\Facades\Blueprint; |
8 | 8 | use Statamic\Facades\Nav; |
| 9 | +use Statamic\Facades\Scope; |
9 | 10 | use Statamic\Facades\Site; |
10 | 11 | use Statamic\Facades\User; |
11 | 12 | use Statamic\Http\Controllers\CP\CpController; |
| 13 | +use Statamic\Query\Scopes\Filter; |
12 | 14 | use Statamic\Rules\Handle; |
13 | 15 | use Statamic\Support\Arr; |
14 | 16 |
|
@@ -46,6 +48,7 @@ public function edit($nav) |
46 | 48 | 'title' => $nav->title(), |
47 | 49 | 'handle' => $nav->handle(), |
48 | 50 | 'collections' => $nav->collections()->map->handle()->all(), |
| 51 | + 'collections_query_scopes' => $nav->collectionsQueryScopes(), |
49 | 52 | 'root' => $nav->expectsRoot(), |
50 | 53 | 'sites' => $nav->trees()->keys()->all(), |
51 | 54 | 'max_depth' => $nav->maxDepth(), |
@@ -86,6 +89,7 @@ public function show(Request $request, $nav) |
86 | 89 | 'nav' => $nav, |
87 | 90 | 'expectsRoot' => $nav->expectsRoot(), |
88 | 91 | 'collections' => $nav->collections()->map->handle()->all(), |
| 92 | + 'collections_query_scopes' => $nav->collectionsQueryScopes(), |
89 | 93 | 'sites' => $this->getAuthorizedTreesForNav($nav)->map(function ($tree) { |
90 | 94 | return [ |
91 | 95 | 'handle' => $tree->locale(), |
@@ -120,6 +124,7 @@ public function update(Request $request, $nav) |
120 | 124 | ->title($values['title']) |
121 | 125 | ->expectsRoot($values['root']) |
122 | 126 | ->collections($values['collections']) |
| 127 | + ->collectionsQueryScopes(Arr::get($values, 'collections_query_scopes', [])) |
123 | 128 | ->maxDepth($values['max_depth']); |
124 | 129 |
|
125 | 130 | $existingSites = $nav->trees()->keys()->all(); |
@@ -212,6 +217,16 @@ public function editFormBlueprint($nav) |
212 | 217 | 'type' => 'collections', |
213 | 218 | 'mode' => 'select', |
214 | 219 | ], |
| 220 | + 'collections_query_scopes' => [ |
| 221 | + 'display' => __('Query Scopes'), |
| 222 | + 'instructions' => __('statamic::fieldtypes.entries.config.query_scopes'), |
| 223 | + 'type' => 'taggable', |
| 224 | + 'options' => Scope::all() |
| 225 | + ->reject(fn ($scope) => $scope instanceof Filter) |
| 226 | + ->map->handle() |
| 227 | + ->values() |
| 228 | + ->all(), |
| 229 | + ], |
215 | 230 | 'root' => [ |
216 | 231 | 'display' => __('Expect a root page'), |
217 | 232 | 'instructions' => __('statamic::messages.expect_root_instructions'), |
|
0 commit comments