From f64609d1669edda2fbd950daba6c5fd61c9fbb2d Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 17 Dec 2025 14:34:11 +0100 Subject: [PATCH 1/4] Rename --- docs/guide/testing-with-sharp.md | 6 +- src/Data/Dashboard/DashboardData.php | 2 +- .../EntityList/EntityListQueryParamsData.php | 2 +- .../Fields/EntityListFieldsContainer.php | 28 --------- src/Http/Context/SharpBreadcrumb.php | 4 +- .../Api/ApiDashboardFiltersController.php | 2 +- .../Api/ApiEntityListController.php | 4 +- .../Api/ApiEntityListFiltersController.php | 2 +- .../Api/ApiFilterAutocompleteController.php | 2 +- .../Api/ApiFormAutocompleteController.php | 2 +- .../Api/ApiFormEditorUploadFormController.php | 2 +- .../Api/ApiFormRefreshController.php | 2 +- .../Api/ApiFormUploadThumbnailController.php | 2 +- .../Controllers/Api/ApiSearchController.php | 2 +- .../ApiDashboardCommandController.php | 5 +- .../ApiEntityListEntityCommandController.php | 4 +- .../ApiEntityListEntityStateController.php | 2 +- ...ApiEntityListInstanceCommandController.php | 4 +- ...tityListQuickCreationCommandController.php | 4 +- .../Commands/ApiShowEntityStateController.php | 2 +- .../ApiShowInstanceCommandController.php | 4 +- .../Controllers/Api/DownloadController.php | 2 +- .../Api/Embeds/ApiEmbedsFormController.php | 4 +- src/Http/Controllers/DashboardController.php | 2 +- .../DashboardFiltersController.php | 2 +- src/Http/Controllers/EntityListController.php | 2 +- .../EntityListFiltersController.php | 2 +- src/Http/Controllers/FormController.php | 12 ++-- .../Controllers/GlobalFilterController.php | 4 +- src/Http/Controllers/HomeController.php | 2 +- src/Http/Controllers/ShowController.php | 4 +- src/Http/Controllers/SingleShowController.php | 2 +- src/Http/Middleware/HandleGlobalFilters.php | 16 ++--- src/Utils/Links/LinkToEntityList.php | 2 +- src/Utils/Links/LinkToSingleShowPage.php | 2 +- src/Utils/Testing/SharpAssertions.php | 46 +++++++-------- src/routes/api.php | 58 +++++++++---------- src/routes/web.php | 46 +++++++-------- tests/Http/Api/ApiFilterAutocompleteTest.php | 6 +- .../Api/ApiFormAutocompleteControllerTest.php | 52 ++++++++--------- .../Http/Api/ApiFormRefreshControllerTest.php | 10 ++-- .../ApiFormUploadThumbnailControllerTest.php | 2 +- ...iEntityListEntityCommandControllerTest.php | 44 +++++++------- ...yListEntityWizardCommandControllerTest.php | 14 ++--- ...ntityListInstanceCommandControllerTest.php | 34 +++++------ ...istInstanceWizardCommandControllerTest.php | 18 +++--- ...ListQuickCreationCommandControllerTest.php | 18 +++--- .../ApiShowInstanceCommandControllerTest.php | 12 ++-- tests/Http/Api/DownloadControllerTest.php | 12 ++-- .../Embeds/ApiEmbedsFormControllerTest.php | 18 +++--- .../Auth/ChangePasswordCommandTraitTest.php | 18 +++--- tests/Http/BreadcrumbTest.php | 2 +- tests/Http/Context/SharpContextTest.php | 2 +- tests/Http/FiltersInRequestTest.php | 6 +- tests/Http/GlobalFilterRoutesTest.php | 16 ++--- tests/Pest.php | 2 +- .../Utils/Testing/SharpAssertionsTest.php | 10 ++-- 57 files changed, 281 insertions(+), 310 deletions(-) diff --git a/docs/guide/testing-with-sharp.md b/docs/guide/testing-with-sharp.md index e964c772d..330826f28 100644 --- a/docs/guide/testing-with-sharp.md +++ b/docs/guide/testing-with-sharp.md @@ -118,9 +118,9 @@ it('allows the user to display a leaf form', function () { }); ``` -#### `withSharpGlobalFilterKeys(array|string $filterKeys): self` +#### `withSharpGlobalFilterValues(array|string $filterValues): self` -You can specify the global filter keys to use in the Sharp context. +You can specify the global filter values to use in the Sharp context. ```php it('allows the user to display a leaf form', function () { @@ -129,7 +129,7 @@ it('allows the user to display a leaf form', function () { $this ->loginAsSharpUser($user) - ->withSharpGlobalFilterKeys($tenant->key) + ->withSharpGlobalFilterValues($tenant->id) ->getSharpForm(LeafEntity::class, 16) ->assertOk(); }); diff --git a/src/Data/Dashboard/DashboardData.php b/src/Data/Dashboard/DashboardData.php index 4439de46d..859aebc59 100644 --- a/src/Data/Dashboard/DashboardData.php +++ b/src/Data/Dashboard/DashboardData.php @@ -23,7 +23,7 @@ public function __construct( public FilterValuesData $filterValues, public ?PageAlertData $pageAlert = null, #[LiteralTypeScriptType('{ - [filterKey: string]: string, + [globalFilter: string]: string, }')] public ?array $query = null, ) {} diff --git a/src/Data/EntityList/EntityListQueryParamsData.php b/src/Data/EntityList/EntityListQueryParamsData.php index a935661c6..ee279d759 100644 --- a/src/Data/EntityList/EntityListQueryParamsData.php +++ b/src/Data/EntityList/EntityListQueryParamsData.php @@ -12,7 +12,7 @@ sort?: string, dir?: "asc" | "desc", } & { - [filterKey: string]: string, + [globalFilter: string]: string, }')] /** * @internal diff --git a/src/EntityList/Fields/EntityListFieldsContainer.php b/src/EntityList/Fields/EntityListFieldsContainer.php index 6b31d5221..f363456b3 100644 --- a/src/EntityList/Fields/EntityListFieldsContainer.php +++ b/src/EntityList/Fields/EntityListFieldsContainer.php @@ -18,34 +18,6 @@ final public function addField(IsEntityListField $field): self return $this; } - // final public function addStateField(?Closure $callback = null): self - // { - // $field = tap( - // new EntityListStateField(), - // fn ($field) => $callback ? $callback($field) : null - // ); - // - // $this->fields[] = $field; - // - // return $this; - // } - // - // final public function addFilterField(string $filterKeyOrClassName, ?Closure $callback = null): self - // { - // $filterKey = class_exists($filterKeyOrClassName) - // ? tap(app($filterKeyOrClassName), fn ($filter) => $filter->buildFilterConfig())->getKey() - // : $filterKeyOrClassName; - // - // $field = tap( - // new EntityListFilterField($filterKey), - // fn ($field) => $callback ? $callback($field) : null - // ); - // - // $this->fields[] = $field; - // - // return $this; - // } - public function setWidthOfField(string $fieldKey, ?int $width, int|bool|null $widthOnSmallScreens): self { if ($width !== null && ($field = collect($this->fields)->firstWhere('key', $fieldKey))) { diff --git a/src/Http/Context/SharpBreadcrumb.php b/src/Http/Context/SharpBreadcrumb.php index b674a2053..2019da910 100644 --- a/src/Http/Context/SharpBreadcrumb.php +++ b/src/Http/Context/SharpBreadcrumb.php @@ -315,12 +315,12 @@ protected function getSegmentsFromRequest(): Collection return collect(explode('/', parse_url($urlToParse)['path'])) ->filter(fn (string $segment) => strlen(trim($segment))) - // Have to skip /sharp/{filterKey} + // Have to skip /sharp/{globalFilter} ->skip(2) ->values(); } - // Have to skip /sharp/{filterKey} + // Have to skip /sharp/{globalFilter} return collect(request()->segments())->skip(2)->values(); } diff --git a/src/Http/Controllers/Api/ApiDashboardFiltersController.php b/src/Http/Controllers/Api/ApiDashboardFiltersController.php index 89dfbf033..b20a72708 100644 --- a/src/Http/Controllers/Api/ApiDashboardFiltersController.php +++ b/src/Http/Controllers/Api/ApiDashboardFiltersController.php @@ -4,7 +4,7 @@ class ApiDashboardFiltersController extends ApiController { - public function store(string $filterKey, string $dashboardKey) + public function store(string $globalFilter, string $dashboardKey) { $this->authorizationManager->check('entity', $dashboardKey); diff --git a/src/Http/Controllers/Api/ApiEntityListController.php b/src/Http/Controllers/Api/ApiEntityListController.php index f24d36f45..0311da9e7 100644 --- a/src/Http/Controllers/Api/ApiEntityListController.php +++ b/src/Http/Controllers/Api/ApiEntityListController.php @@ -11,7 +11,7 @@ class ApiEntityListController extends ApiController /** * Reorder instances. */ - public function update(string $filterKey, string $entityKey) + public function update(string $globalFilter, string $entityKey) { $this->authorizationManager->check('entity', $entityKey); @@ -28,7 +28,7 @@ public function update(string $filterKey, string $entityKey) /** * Delete an instance. */ - public function delete(string $filterKey, string $entityKey, string $instanceId) + public function delete(string $globalFilter, string $entityKey, string $instanceId) { $this->authorizationManager->check('delete', $entityKey, $instanceId); diff --git a/src/Http/Controllers/Api/ApiEntityListFiltersController.php b/src/Http/Controllers/Api/ApiEntityListFiltersController.php index f063928fb..154eeb142 100644 --- a/src/Http/Controllers/Api/ApiEntityListFiltersController.php +++ b/src/Http/Controllers/Api/ApiEntityListFiltersController.php @@ -4,7 +4,7 @@ class ApiEntityListFiltersController extends ApiController { - public function store(string $filterKey, string $entityKey) + public function store(string $globalFilter, string $entityKey) { $this->authorizationManager->check('entity', $entityKey); diff --git a/src/Http/Controllers/Api/ApiFilterAutocompleteController.php b/src/Http/Controllers/Api/ApiFilterAutocompleteController.php index aeccaea54..29fb2b7b8 100644 --- a/src/Http/Controllers/Api/ApiFilterAutocompleteController.php +++ b/src/Http/Controllers/Api/ApiFilterAutocompleteController.php @@ -8,7 +8,7 @@ class ApiFilterAutocompleteController extends ApiController { - public function index(string $filterKey, EntityKey $entityKey, string $filterHandlerKey): array + public function index(string $globalFilter, EntityKey $entityKey, string $filterHandlerKey): array { $entity = $this->entityManager->entityFor($entityKey); diff --git a/src/Http/Controllers/Api/ApiFormAutocompleteController.php b/src/Http/Controllers/Api/ApiFormAutocompleteController.php index 5bd18c0f0..16faa4856 100644 --- a/src/Http/Controllers/Api/ApiFormAutocompleteController.php +++ b/src/Http/Controllers/Api/ApiFormAutocompleteController.php @@ -13,7 +13,7 @@ class ApiFormAutocompleteController extends ApiController { use HandlesFieldContainer; - public function index(string $filterKey, EntityKey $entityKey, string $autocompleteFieldKey) + public function index(string $globalFilter, EntityKey $entityKey, string $autocompleteFieldKey) { $fieldContainer = $this->getFieldContainer($entityKey); $field = $fieldContainer->findFieldByKey($autocompleteFieldKey); diff --git a/src/Http/Controllers/Api/ApiFormEditorUploadFormController.php b/src/Http/Controllers/Api/ApiFormEditorUploadFormController.php index 04b1d310d..b07ff5efa 100644 --- a/src/Http/Controllers/Api/ApiFormEditorUploadFormController.php +++ b/src/Http/Controllers/Api/ApiFormEditorUploadFormController.php @@ -7,7 +7,7 @@ class ApiFormEditorUploadFormController extends Controller { - public function update(string $filterKey, EditorUploadFormRequest $request, string $entityKey, ?string $instanceId = null) + public function update(string $globalFilter, EditorUploadFormRequest $request, string $entityKey, ?string $instanceId = null) { return response()->json($request->input('data')); } diff --git a/src/Http/Controllers/Api/ApiFormRefreshController.php b/src/Http/Controllers/Api/ApiFormRefreshController.php index 4598546cc..cf907e79b 100644 --- a/src/Http/Controllers/Api/ApiFormRefreshController.php +++ b/src/Http/Controllers/Api/ApiFormRefreshController.php @@ -8,7 +8,7 @@ class ApiFormRefreshController extends ApiController { use HandlesFieldContainer; - public function update(string $filterKey, EntityKey $entityKey) + public function update(string $globalFilter, EntityKey $entityKey) { $fieldContainer = $this->getFieldContainer($entityKey); diff --git a/src/Http/Controllers/Api/ApiFormUploadThumbnailController.php b/src/Http/Controllers/Api/ApiFormUploadThumbnailController.php index 0eadf9c84..c954fc2af 100644 --- a/src/Http/Controllers/Api/ApiFormUploadThumbnailController.php +++ b/src/Http/Controllers/Api/ApiFormUploadThumbnailController.php @@ -13,7 +13,7 @@ class ApiFormUploadThumbnailController extends Controller public function __construct(private readonly SharpAuthorizationManager $authorizationManager) {} // Used to generate large thumbnail for upload crop modal - public function show(string $filterKey, string $entityKey, ?string $instanceId = null) + public function show(string $globalFilter, string $entityKey, ?string $instanceId = null) { $this->authorizationManager->check('view', $entityKey, $instanceId); diff --git a/src/Http/Controllers/Api/ApiSearchController.php b/src/Http/Controllers/Api/ApiSearchController.php index 31334f848..48ccd49ec 100644 --- a/src/Http/Controllers/Api/ApiSearchController.php +++ b/src/Http/Controllers/Api/ApiSearchController.php @@ -8,7 +8,7 @@ class ApiSearchController extends ApiController { - public function index(string $filterKey) + public function index(string $globalFilter) { $searchEngine = sharp()->config()->get('search.engine'); diff --git a/src/Http/Controllers/Api/Commands/ApiDashboardCommandController.php b/src/Http/Controllers/Api/Commands/ApiDashboardCommandController.php index d4a8b567d..4fad2a167 100644 --- a/src/Http/Controllers/Api/Commands/ApiDashboardCommandController.php +++ b/src/Http/Controllers/Api/Commands/ApiDashboardCommandController.php @@ -19,14 +19,13 @@ public function __construct( parent::__construct(); } - public function show(string $filterKey, string $entityKey, string $commandKey) + public function show(string $globalFilter, string $entityKey, string $commandKey) { $dashboard = $this->getDashboardInstance($entityKey); $dashboard->buildDashboardConfig(); $dashboard->initQueryParams(request()->query()); $commandHandler = $this->getDashboardCommandHandler($dashboard, $commandKey); - $formData = $commandHandler->formData() ?: null; return response()->json( CommandFormData::from( @@ -35,7 +34,7 @@ public function show(string $filterKey, string $entityKey, string $commandKey) ); } - public function update(string $filterKey, string $entityKey, string $commandKey) + public function update(string $globalFilter, string $entityKey, string $commandKey) { $dashboard = $this->getDashboardInstance($entityKey); $dashboard->buildDashboardConfig(); diff --git a/src/Http/Controllers/Api/Commands/ApiEntityListEntityCommandController.php b/src/Http/Controllers/Api/Commands/ApiEntityListEntityCommandController.php index 7bd6f1204..1df4bf490 100644 --- a/src/Http/Controllers/Api/Commands/ApiEntityListEntityCommandController.php +++ b/src/Http/Controllers/Api/Commands/ApiEntityListEntityCommandController.php @@ -18,7 +18,7 @@ public function __construct( parent::__construct(); } - public function show(string $filterKey, string $entityKey, string $commandKey) + public function show(string $globalFilter, string $entityKey, string $commandKey) { $list = $this->getListInstance($entityKey); $list->buildListConfig(); @@ -33,7 +33,7 @@ public function show(string $filterKey, string $entityKey, string $commandKey) ); } - public function update(string $filterKey, string $entityKey, string $commandKey) + public function update(string $globalFilter, string $entityKey, string $commandKey) { $list = $this->getListInstance($entityKey); $list->buildListConfig(); diff --git a/src/Http/Controllers/Api/Commands/ApiEntityListEntityStateController.php b/src/Http/Controllers/Api/Commands/ApiEntityListEntityStateController.php index ed5ed0873..586febf0f 100644 --- a/src/Http/Controllers/Api/Commands/ApiEntityListEntityStateController.php +++ b/src/Http/Controllers/Api/Commands/ApiEntityListEntityStateController.php @@ -10,7 +10,7 @@ class ApiEntityListEntityStateController extends ApiController use HandlesCommandResult; use HandlesInstanceCommand; - public function update(string $filterKey, string $entityKey, mixed $instanceId) + public function update(string $globalFilter, string $entityKey, mixed $instanceId) { $list = $this->getListInstance($entityKey); $list->buildListConfig(); diff --git a/src/Http/Controllers/Api/Commands/ApiEntityListInstanceCommandController.php b/src/Http/Controllers/Api/Commands/ApiEntityListInstanceCommandController.php index 870b6b886..c2a1ee716 100644 --- a/src/Http/Controllers/Api/Commands/ApiEntityListInstanceCommandController.php +++ b/src/Http/Controllers/Api/Commands/ApiEntityListInstanceCommandController.php @@ -18,7 +18,7 @@ public function __construct( parent::__construct(); } - public function show(string $filterKey, string $entityKey, string $commandKey, mixed $instanceId) + public function show(string $globalFilter, string $entityKey, string $commandKey, mixed $instanceId) { $list = $this->getListInstance($entityKey); $list->buildListConfig(); @@ -36,7 +36,7 @@ public function show(string $filterKey, string $entityKey, string $commandKey, m /** * Execute the Command. */ - public function update(string $filterKey, string $entityKey, string $commandKey, mixed $instanceId) + public function update(string $globalFilter, string $entityKey, string $commandKey, mixed $instanceId) { $list = $this->getListInstance($entityKey); $list->buildListConfig(); diff --git a/src/Http/Controllers/Api/Commands/ApiEntityListQuickCreationCommandController.php b/src/Http/Controllers/Api/Commands/ApiEntityListQuickCreationCommandController.php index e24358466..9e22ce736 100644 --- a/src/Http/Controllers/Api/Commands/ApiEntityListQuickCreationCommandController.php +++ b/src/Http/Controllers/Api/Commands/ApiEntityListQuickCreationCommandController.php @@ -17,7 +17,7 @@ public function __construct(private readonly SharpUploadManager $uploadManager) parent::__construct(); } - public function create(string $filterKey, EntityKey $entityKey, EntityKey $formEntityKey) + public function create(string $globalFilter, EntityKey $entityKey, EntityKey $formEntityKey) { $entity = $this->entityManager->entityFor($entityKey); @@ -48,7 +48,7 @@ public function create(string $filterKey, EntityKey $entityKey, EntityKey $formE ); } - public function store(string $filterKey, EntityKey $entityKey, EntityKey $formEntityKey) + public function store(string $globalFilter, EntityKey $entityKey, EntityKey $formEntityKey) { $list = $this->entityManager->entityFor($entityKey)->getListOrFail(); $list->buildListConfig(); diff --git a/src/Http/Controllers/Api/Commands/ApiShowEntityStateController.php b/src/Http/Controllers/Api/Commands/ApiShowEntityStateController.php index 882b11339..4be029d53 100644 --- a/src/Http/Controllers/Api/Commands/ApiShowEntityStateController.php +++ b/src/Http/Controllers/Api/Commands/ApiShowEntityStateController.php @@ -11,7 +11,7 @@ class ApiShowEntityStateController extends ApiController use HandlesCommandResult; use HandlesInstanceCommand; - public function update(string $filterKey, string $entityKey, mixed $instanceId = null) + public function update(string $globalFilter, string $entityKey, mixed $instanceId = null) { $showPage = $this->getShowPage($entityKey, $instanceId); $stateHandler = $showPage->entityStateHandler(); diff --git a/src/Http/Controllers/Api/Commands/ApiShowInstanceCommandController.php b/src/Http/Controllers/Api/Commands/ApiShowInstanceCommandController.php index 8a4cd6e72..70daedc5f 100644 --- a/src/Http/Controllers/Api/Commands/ApiShowInstanceCommandController.php +++ b/src/Http/Controllers/Api/Commands/ApiShowInstanceCommandController.php @@ -19,7 +19,7 @@ public function __construct( parent::__construct(); } - public function show(string $filterKey, string $entityKey, string $commandKey, mixed $instanceId = null) + public function show(string $globalFilter, string $entityKey, string $commandKey, mixed $instanceId = null) { $showPage = $this->getShowPage($entityKey, $instanceId); $commandHandler = $this->getInstanceCommandHandler($showPage, $commandKey, $instanceId); @@ -31,7 +31,7 @@ public function show(string $filterKey, string $entityKey, string $commandKey, m ); } - public function update(string $filterKey, string $entityKey, string $commandKey, mixed $instanceId = null) + public function update(string $globalFilter, string $entityKey, string $commandKey, mixed $instanceId = null) { $showPage = $this->getShowPage($entityKey, $instanceId); $commandHandler = $this->getInstanceCommandHandler($showPage, $commandKey, $instanceId); diff --git a/src/Http/Controllers/Api/DownloadController.php b/src/Http/Controllers/Api/DownloadController.php index 72f226c20..f91cc2c9b 100644 --- a/src/Http/Controllers/Api/DownloadController.php +++ b/src/Http/Controllers/Api/DownloadController.php @@ -6,7 +6,7 @@ class DownloadController extends ApiController { - public function show(string $filterKey, string $entityKey, ?string $instanceId = null) + public function show(string $globalFilter, string $entityKey, ?string $instanceId = null) { $this->authorizationManager->check('view', $entityKey, $instanceId); diff --git a/src/Http/Controllers/Api/Embeds/ApiEmbedsFormController.php b/src/Http/Controllers/Api/Embeds/ApiEmbedsFormController.php index 741790966..3b09237c5 100644 --- a/src/Http/Controllers/Api/Embeds/ApiEmbedsFormController.php +++ b/src/Http/Controllers/Api/Embeds/ApiEmbedsFormController.php @@ -12,7 +12,7 @@ class ApiEmbedsFormController extends Controller public function __construct(private readonly SharpAuthorizationManager $authorizationManager) {} - public function show(string $filterKey, string $embedKey, string $entityKey, ?string $instanceId = null) + public function show(string $globalFilter, string $embedKey, string $entityKey, ?string $instanceId = null) { if ($instanceId) { $this->authorizationManager->check('view', $entityKey, $instanceId); @@ -31,7 +31,7 @@ public function show(string $filterKey, string $embedKey, string $entityKey, ?st ]); } - public function update(string $filterKey, string $embedKey, string $entityKey, ?string $instanceId = null) + public function update(string $globalFilter, string $embedKey, string $entityKey, ?string $instanceId = null) { if ($instanceId) { $this->authorizationManager->check('update', $entityKey, $instanceId); diff --git a/src/Http/Controllers/DashboardController.php b/src/Http/Controllers/DashboardController.php index a74ca61de..699fe1bd1 100644 --- a/src/Http/Controllers/DashboardController.php +++ b/src/Http/Controllers/DashboardController.php @@ -9,7 +9,7 @@ class DashboardController extends SharpProtectedController { - public function show(string $filterKey, EntityKey $dashboardKey) + public function show(string $globalFilter, EntityKey $dashboardKey) { $this->authorizationManager->check('entity', $dashboardKey); diff --git a/src/Http/Controllers/DashboardFiltersController.php b/src/Http/Controllers/DashboardFiltersController.php index d84155a27..b7d557667 100644 --- a/src/Http/Controllers/DashboardFiltersController.php +++ b/src/Http/Controllers/DashboardFiltersController.php @@ -4,7 +4,7 @@ class DashboardFiltersController extends SharpProtectedController { - public function store(string $filterKey, string $dashboardKey) + public function store(string $globalFilter, string $dashboardKey) { $this->authorizationManager->check('entity', $dashboardKey); diff --git a/src/Http/Controllers/EntityListController.php b/src/Http/Controllers/EntityListController.php index bdcd1708e..9ef56e90c 100644 --- a/src/Http/Controllers/EntityListController.php +++ b/src/Http/Controllers/EntityListController.php @@ -18,7 +18,7 @@ class EntityListController extends SharpProtectedController use HandlesEntityListItems; use HandlesSharpNotificationsInRequest; - public function show(string $filterKey, EntityKey $entityKey) + public function show(string $globalFilter, EntityKey $entityKey) { $this->authorizationManager->check('entity', $entityKey); diff --git a/src/Http/Controllers/EntityListFiltersController.php b/src/Http/Controllers/EntityListFiltersController.php index 27ff4899b..a0c320eca 100644 --- a/src/Http/Controllers/EntityListFiltersController.php +++ b/src/Http/Controllers/EntityListFiltersController.php @@ -4,7 +4,7 @@ class EntityListFiltersController extends SharpProtectedController { - public function store(string $filterKey, string $entityKey) + public function store(string $globalFilter, string $entityKey) { $this->authorizationManager->check('entity', $entityKey); diff --git a/src/Http/Controllers/FormController.php b/src/Http/Controllers/FormController.php index 3bf2dc1d3..16a6f6a98 100644 --- a/src/Http/Controllers/FormController.php +++ b/src/Http/Controllers/FormController.php @@ -22,7 +22,7 @@ public function __construct( parent::__construct(); } - public function create(string $filterKey, string $parentUri, EntityKey $entityKey) + public function create(string $globalFilter, string $parentUri, EntityKey $entityKey) { $entity = $this->entityManager->entityFor($entityKey); @@ -30,7 +30,7 @@ public function create(string $filterKey, string $parentUri, EntityKey $entityKe if ($form instanceof SharpSingleForm) { // There is no creation in SingleForms - return $this->edit($filterKey, $parentUri, $entityKey); + return $this->edit($globalFilter, $parentUri, $entityKey); } $this->authorizationManager->check('create', $entityKey); @@ -56,7 +56,7 @@ public function create(string $filterKey, string $parentUri, EntityKey $entityKe ]); } - public function edit(string $filterKey, string $parentUri, EntityKey $entityKey, ?string $instanceId = null) + public function edit(string $globalFilter, string $parentUri, EntityKey $entityKey, ?string $instanceId = null) { $entity = $this->entityManager->entityFor($entityKey); @@ -114,7 +114,7 @@ public function edit(string $filterKey, string $parentUri, EntityKey $entityKey, ]); } - public function update(string $filterKey, string $parentUri, EntityKey $entityKey, ?string $instanceId = null) + public function update(string $globalFilter, string $parentUri, EntityKey $entityKey, ?string $instanceId = null) { $this->authorizationManager->check('update', $entityKey, $instanceId); @@ -142,7 +142,7 @@ public function update(string $filterKey, string $parentUri, EntityKey $entityKe return redirect()->to($this->previousUrlWithHighlightedQuery($previousUrl, $entityKey, $instanceId)); } - public function store(string $filterKey, string $parentUri, EntityKey $entityKey) + public function store(string $globalFilter, string $parentUri, EntityKey $entityKey) { $form = $this->entityManager ->entityFor($entityKey) @@ -150,7 +150,7 @@ public function store(string $filterKey, string $parentUri, EntityKey $entityKey if ($form instanceof SharpSingleForm) { // There is no creation in SingleForms - return $this->update($filterKey, $parentUri, $entityKey); + return $this->update($globalFilter, $parentUri, $entityKey); } $this->authorizationManager->check('create', $entityKey); diff --git a/src/Http/Controllers/GlobalFilterController.php b/src/Http/Controllers/GlobalFilterController.php index 8155dd2d2..d2c201e1e 100644 --- a/src/Http/Controllers/GlobalFilterController.php +++ b/src/Http/Controllers/GlobalFilterController.php @@ -7,7 +7,7 @@ class GlobalFilterController extends SharpProtectedController { - public function update(string $filterKey, GlobalFilters $globalFilters): RedirectResponse + public function update(string $globalFilter, GlobalFilters $globalFilters): RedirectResponse { collect(request()->input('filterValues')) ->each(function ($value, $key) use ($globalFilters) { @@ -15,7 +15,7 @@ public function update(string $filterKey, GlobalFilters $globalFilters): Redirec }); return redirect()->route('code16.sharp.home', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), ]); } } diff --git a/src/Http/Controllers/HomeController.php b/src/Http/Controllers/HomeController.php index 0a6e4d3d4..c95685d06 100644 --- a/src/Http/Controllers/HomeController.php +++ b/src/Http/Controllers/HomeController.php @@ -8,7 +8,7 @@ class HomeController extends SharpProtectedController { - public function index(string $filterKey) + public function index(string $globalFilter) { if ($firstEntityUrl = $this->getFirstConfiguredEntityUrl()) { return redirect()->to($firstEntityUrl); diff --git a/src/Http/Controllers/ShowController.php b/src/Http/Controllers/ShowController.php index f9546f3db..e71d9adb1 100644 --- a/src/Http/Controllers/ShowController.php +++ b/src/Http/Controllers/ShowController.php @@ -14,7 +14,7 @@ class ShowController extends SharpProtectedController use HandlesSharpNotificationsInRequest; use PreloadsShowFields; - public function show(string $filterKey, string $parentUri, EntityKey $entityKey, string $instanceId) + public function show(string $globalFilter, string $parentUri, EntityKey $entityKey, string $instanceId) { $this->authorizationManager->check('view', $entityKey, $instanceId); @@ -66,7 +66,7 @@ public function show(string $filterKey, string $parentUri, EntityKey $entityKey, ]); } - public function delete(string $filterKey, string $parentUri, string $entityKey, string $instanceId) + public function delete(string $globalFilter, string $parentUri, string $entityKey, string $instanceId) { $this->authorizationManager->check('delete', $entityKey, $instanceId); diff --git a/src/Http/Controllers/SingleShowController.php b/src/Http/Controllers/SingleShowController.php index 040ce82e9..925aad556 100644 --- a/src/Http/Controllers/SingleShowController.php +++ b/src/Http/Controllers/SingleShowController.php @@ -13,7 +13,7 @@ class SingleShowController extends SharpProtectedController use HandlesSharpNotificationsInRequest; use PreloadsShowFields; - public function show(string $filterKey, EntityKey $entityKey) + public function show(string $globalFilter, EntityKey $entityKey) { $this->authorizationManager->check('view', $entityKey); diff --git a/src/Http/Middleware/HandleGlobalFilters.php b/src/Http/Middleware/HandleGlobalFilters.php index 6d7995d48..59a666753 100644 --- a/src/Http/Middleware/HandleGlobalFilters.php +++ b/src/Http/Middleware/HandleGlobalFilters.php @@ -14,34 +14,34 @@ public function __construct(private GlobalFilters $globalFiltersHandler) {} public function handle(Request $request, Closure $next) { - if ($filterKey = $request->route('filterKey')) { - $filterKeys = explode(GlobalFilters::$valuesUrlSeparator, $filterKey); + if ($globalFilterValue = $request->route('globalFilter')) { + $globalFilterValues = explode(GlobalFilters::$valuesUrlSeparator, $globalFilterValue); if ($this->globalFiltersHandler->isEnabled()) { $globalFilters = $this->globalFiltersHandler->getFilters(); - if (count($filterKeys) !== count($globalFilters)) { + if (count($globalFilterValues) !== count($globalFilters)) { return redirect()->route('code16.sharp.home', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), ]); } collect($globalFilters) ->each(fn (GlobalRequiredFilter $globalFilter, int $index) => $globalFilter - ->setCurrentValue($filterKeys[$index]) + ->setCurrentValue($globalFilterValues[$index]) ); - if (sharp()->context()->globalFilterUrlSegmentValue() !== $filterKey + if (sharp()->context()->globalFilterUrlSegmentValue() !== $globalFilterValue && ! $request->wantsJson() && $request->isMethod('GET') ) { return redirect()->route('code16.sharp.home', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), ]); } } } - URL::defaults(['filterKey' => sharp()->context()->globalFilterUrlSegmentValue()]); + URL::defaults(['globalFilter' => sharp()->context()->globalFilterUrlSegmentValue()]); return $next($request); } diff --git a/src/Utils/Links/LinkToEntityList.php b/src/Utils/Links/LinkToEntityList.php index d70b05061..265fff9c1 100644 --- a/src/Utils/Links/LinkToEntityList.php +++ b/src/Utils/Links/LinkToEntityList.php @@ -55,7 +55,7 @@ public function renderAsUrl(): string return route('code16.sharp.list', array_merge( [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $this->entityKey, ], $this->generateQuerystring(), diff --git a/src/Utils/Links/LinkToSingleShowPage.php b/src/Utils/Links/LinkToSingleShowPage.php index 86f917aba..80d75a7b5 100644 --- a/src/Utils/Links/LinkToSingleShowPage.php +++ b/src/Utils/Links/LinkToSingleShowPage.php @@ -12,7 +12,7 @@ public static function make(string $entityKey): self public function renderAsUrl(): string { return route('code16.sharp.single-show', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $this->entityKey, ]); } diff --git a/src/Utils/Testing/SharpAssertions.php b/src/Utils/Testing/SharpAssertions.php index e75aae392..1e1bf980b 100644 --- a/src/Utils/Testing/SharpAssertions.php +++ b/src/Utils/Testing/SharpAssertions.php @@ -12,7 +12,7 @@ trait SharpAssertions { private BreadcrumbBuilder $breadcrumbBuilder; - private ?string $filterKey = null; + private ?string $globalFilter = null; /** * @deprecated use withSharpBreadcrumb() instead @@ -43,9 +43,9 @@ public function withSharpBreadcrumb(Closure $callback): self return $this; } - public function withSharpGlobalFilterKeys(array|string $filterKeys): self + public function withSharpGlobalFilterValues(array|string $globalFilterValues): self { - $this->filterKey = collect((array) $filterKeys) + $this->globalFilter = collect((array) $globalFilterValues) ->implode(GlobalFilters::$valuesUrlSeparator); return $this; @@ -53,7 +53,7 @@ public function withSharpGlobalFilterKeys(array|string $filterKeys): self public function deleteFromSharpShow(string $entityClassNameOrKey, mixed $instanceId) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -61,7 +61,7 @@ public function deleteFromSharpShow(string $entityClassNameOrKey, mixed $instanc ->delete( route( 'code16.sharp.show.delete', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, 'instanceId' => $instanceId, @@ -72,7 +72,7 @@ public function deleteFromSharpShow(string $entityClassNameOrKey, mixed $instanc public function deleteFromSharpList(string $entityClassNameOrKey, mixed $instanceId) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -85,7 +85,7 @@ public function deleteFromSharpList(string $entityClassNameOrKey, mixed $instanc ) ->delete( route('code16.sharp.api.list.delete', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'entityKey' => $entityKey, 'instanceId' => $instanceId, ]) @@ -94,7 +94,7 @@ public function deleteFromSharpList(string $entityClassNameOrKey, mixed $instanc public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = null) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -104,7 +104,7 @@ public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = n ? route( 'code16.sharp.form.edit', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, 'instanceId' => $instanceId, @@ -113,7 +113,7 @@ public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = n : route( 'code16.sharp.form.create', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, ] @@ -123,7 +123,7 @@ public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = n public function getSharpSingleForm(string $entityClassNameOrKey) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -132,7 +132,7 @@ public function getSharpSingleForm(string $entityClassNameOrKey) route( 'code16.sharp.form.edit', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, ] @@ -142,7 +142,7 @@ public function getSharpSingleForm(string $entityClassNameOrKey) public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array $data) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -150,7 +150,7 @@ public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array ->post( route( 'code16.sharp.form.update', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, 'instanceId' => $instanceId, @@ -162,7 +162,7 @@ public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array public function updateSharpSingleForm(string $entityClassNameOrKey, array $data) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -170,7 +170,7 @@ public function updateSharpSingleForm(string $entityClassNameOrKey, array $data) ->post( route( 'code16.sharp.form.update', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, ] @@ -181,7 +181,7 @@ public function updateSharpSingleForm(string $entityClassNameOrKey, array $data) public function getSharpShow(string $entityClassNameOrKey, $instanceId) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -190,7 +190,7 @@ public function getSharpShow(string $entityClassNameOrKey, $instanceId) route( 'code16.sharp.show.show', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, 'instanceId' => $instanceId, @@ -201,7 +201,7 @@ public function getSharpShow(string $entityClassNameOrKey, $instanceId) public function storeSharpForm(string $entityClassNameOrKey, array $data) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -210,7 +210,7 @@ public function storeSharpForm(string $entityClassNameOrKey, array $data) route( 'code16.sharp.form.store', [ - 'filterKey' => $this->filterKey, + 'globalFilter' => $this->globalFilter, 'parentUri' => $this->breadcrumbBuilder($entityKey)->generateUri(), 'entityKey' => $entityKey, ] @@ -226,7 +226,7 @@ public function callSharpInstanceCommandFromList( array $data = [], ?string $commandStep = null ) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -257,7 +257,7 @@ public function callSharpInstanceCommandFromShow( array $data = [], ?string $commandStep = null ) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); @@ -287,7 +287,7 @@ public function callSharpEntityCommandFromList( array $data = [], ?string $commandStep = null ) { - URL::defaults(['filterKey' => $this->filterKey ?: GlobalFilters::$defaultKey]); + URL::defaults(['globalFilter' => $this->globalFilter ?: GlobalFilters::$defaultKey]); $entityKey = $this->resolveEntityKey($entityClassNameOrKey); diff --git a/src/routes/api.php b/src/routes/api.php index 4a8df9d82..0ccc4e03d 100644 --- a/src/routes/api.php +++ b/src/routes/api.php @@ -26,99 +26,99 @@ 'prefix' => '/'.sharp()->config()->get('custom_url_segment').'/api', 'middleware' => ['sharp_common', 'sharp_api'], ], function () { - Route::get('/{filterKey}/dashboard/{dashboardKey}/command/{commandKey}/form', [ApiDashboardCommandController::class, 'show']) + Route::get('/{globalFilter}/dashboard/{dashboardKey}/command/{commandKey}/form', [ApiDashboardCommandController::class, 'show']) ->name('code16.sharp.api.dashboard.command.form'); - Route::post('/{filterKey}/dashboard/{dashboardKey}/command/{commandKey}', [ApiDashboardCommandController::class, 'update']) + Route::post('/{globalFilter}/dashboard/{dashboardKey}/command/{commandKey}', [ApiDashboardCommandController::class, 'update']) ->name('code16.sharp.api.dashboard.command'); - Route::get('/{filterKey}/list/{entityKey}/form/{formEntityKey}/create', [ApiEntityListQuickCreationCommandController::class, 'create']) + Route::get('/{globalFilter}/list/{entityKey}/form/{formEntityKey}/create', [ApiEntityListQuickCreationCommandController::class, 'create']) ->name('code16.sharp.api.list.command.quick-creation-form.create'); - Route::post('/{filterKey}/list/{entityKey}/form/{formEntityKey}/create', [ApiEntityListQuickCreationCommandController::class, 'store']) + Route::post('/{globalFilter}/list/{entityKey}/form/{formEntityKey}/create', [ApiEntityListQuickCreationCommandController::class, 'store']) ->name('code16.sharp.api.list.command.quick-creation-form.store'); // EmbeddedEntityLists - Route::get('/{filterKey}/list/{entityKey}', [EntityListController::class, 'show']) + Route::get('/{globalFilter}/list/{entityKey}', [EntityListController::class, 'show']) ->name('code16.sharp.api.list') ->middleware('cache.headers:no_store'); - Route::post('/{filterKey}/list/{entityKey}/filters', [ApiEntityListFiltersController::class, 'store']) + Route::post('/{globalFilter}/list/{entityKey}/filters', [ApiEntityListFiltersController::class, 'store']) ->name('code16.sharp.api.list.filters.store'); - Route::post('/{filterKey}/list/{entityKey}/reorder', [ApiEntityListController::class, 'update']) + Route::post('/{globalFilter}/list/{entityKey}/reorder', [ApiEntityListController::class, 'update']) ->name('code16.sharp.api.list.reorder'); - Route::delete('/{filterKey}/list/{entityKey}/{instanceId}', [ApiEntityListController::class, 'delete']) + Route::delete('/{globalFilter}/list/{entityKey}/{instanceId}', [ApiEntityListController::class, 'delete']) ->name('code16.sharp.api.list.delete'); - Route::post('/{filterKey}/list/{entityKey}/state/{instanceId}', [ApiEntityListEntityStateController::class, 'update']) + Route::post('/{globalFilter}/list/{entityKey}/state/{instanceId}', [ApiEntityListEntityStateController::class, 'update']) ->name('code16.sharp.api.list.state'); - Route::post('/{filterKey}/list/{entityKey}/command/{commandKey}', [ApiEntityListEntityCommandController::class, 'update']) + Route::post('/{globalFilter}/list/{entityKey}/command/{commandKey}', [ApiEntityListEntityCommandController::class, 'update']) ->name('code16.sharp.api.list.command.entity'); - Route::get('/{filterKey}/list/{entityKey}/command/{commandKey}/form', [ApiEntityListEntityCommandController::class, 'show']) + Route::get('/{globalFilter}/list/{entityKey}/command/{commandKey}/form', [ApiEntityListEntityCommandController::class, 'show']) ->name('code16.sharp.api.list.command.entity.form'); - Route::post('/{filterKey}/list/{entityKey}/command/{commandKey}/{instanceId}', [ApiEntityListInstanceCommandController::class, 'update']) + Route::post('/{globalFilter}/list/{entityKey}/command/{commandKey}/{instanceId}', [ApiEntityListInstanceCommandController::class, 'update']) ->name('code16.sharp.api.list.command.instance'); - Route::get('/{filterKey}/list/{entityKey}/command/{commandKey}/{instanceId}/form', [ApiEntityListInstanceCommandController::class, 'show']) + Route::get('/{globalFilter}/list/{entityKey}/command/{commandKey}/{instanceId}/form', [ApiEntityListInstanceCommandController::class, 'show']) ->name('code16.sharp.api.list.command.instance.form'); // EmbeddedDashboards - Route::get('/{filterKey}/dashboard/{dashboardKey}', [DashboardController::class, 'show']) + Route::get('/{globalFilter}/dashboard/{dashboardKey}', [DashboardController::class, 'show']) ->name('code16.sharp.api.dashboard') ->middleware('cache.headers:no_store'); - Route::post('/{filterKey}/dashboard/{dashboardKey}/filters', [ApiDashboardFiltersController::class, 'store']) + Route::post('/{globalFilter}/dashboard/{dashboardKey}/filters', [ApiDashboardFiltersController::class, 'store']) ->name('code16.sharp.api.dashboard.filters.store'); - Route::post('/{filterKey}/show/{entityKey}/command/{commandKey}/{instanceId?}', [ApiShowInstanceCommandController::class, 'update']) + Route::post('/{globalFilter}/show/{entityKey}/command/{commandKey}/{instanceId?}', [ApiShowInstanceCommandController::class, 'update']) ->name('code16.sharp.api.show.command.instance'); - Route::get('/{filterKey}/show/{entityKey}/command/{commandKey}/{instanceId}/form', [ApiShowInstanceCommandController::class, 'show']) + Route::get('/{globalFilter}/show/{entityKey}/command/{commandKey}/{instanceId}/form', [ApiShowInstanceCommandController::class, 'show']) ->name('code16.sharp.api.show.command.instance.form'); // Specific route for single shows, because /show/{entityKey}/command/{commandKey}/{instanceId?}/data // does not work since instanceId is optional but not the last segment. - Route::get('/{filterKey}/show/{entityKey}/command/{commandKey}/form', [ApiShowInstanceCommandController::class, 'show']) + Route::get('/{globalFilter}/show/{entityKey}/command/{commandKey}/form', [ApiShowInstanceCommandController::class, 'show']) ->name('code16.sharp.api.show.command.singleInstance.form'); - Route::post('/{filterKey}/show/{entityKey}/state/{instanceId?}', [ApiShowEntityStateController::class, 'update']) + Route::post('/{globalFilter}/show/{entityKey}/state/{instanceId?}', [ApiShowEntityStateController::class, 'update']) ->name('code16.sharp.api.show.state'); - Route::get('/{filterKey}/search', [ApiSearchController::class, 'index']) + Route::get('/{globalFilter}/search', [ApiSearchController::class, 'index']) ->name('code16.sharp.api.search.index'); - Route::post('/{filterKey}/embeds/{embedKey}/{entityKey}/form/init', [ApiEmbedsFormController::class, 'show']) + Route::post('/{globalFilter}/embeds/{embedKey}/{entityKey}/form/init', [ApiEmbedsFormController::class, 'show']) ->name('code16.sharp.api.embed.form.show'); - Route::post('/{filterKey}/embeds/{embedKey}/{entityKey}/form', [ApiEmbedsFormController::class, 'update']) + Route::post('/{globalFilter}/embeds/{embedKey}/{entityKey}/form', [ApiEmbedsFormController::class, 'update']) ->name('code16.sharp.api.embed.form.update'); - Route::post('/{filterKey}/embeds/{embedKey}/{entityKey}/{instanceId}/form/init', [ApiEmbedsFormController::class, 'show']) + Route::post('/{globalFilter}/embeds/{embedKey}/{entityKey}/{instanceId}/form/init', [ApiEmbedsFormController::class, 'show']) ->name('code16.sharp.api.embed.instance.form.show'); - Route::post('/{filterKey}/embeds/{embedKey}/{entityKey}/{instanceId}/form', [ApiEmbedsFormController::class, 'update']) + Route::post('/{globalFilter}/embeds/{embedKey}/{entityKey}/{instanceId}/form', [ApiEmbedsFormController::class, 'update']) ->name('code16.sharp.api.embed.instance.form.update'); - Route::post('/{filterKey}/form/editors/upload/form/{entityKey}/{instanceId?}', [ApiFormEditorUploadFormController::class, 'update']) + Route::post('/{globalFilter}/form/editors/upload/form/{entityKey}/{instanceId?}', [ApiFormEditorUploadFormController::class, 'update']) ->name('code16.sharp.api.form.editor.upload.form.update'); - Route::post('/{filterKey}/upload/thumbnail/{entityKey}/{instanceId?}', [ApiFormUploadThumbnailController::class, 'show']) + Route::post('/{globalFilter}/upload/thumbnail/{entityKey}/{instanceId?}', [ApiFormUploadThumbnailController::class, 'show']) ->name('code16.sharp.api.form.upload.thumbnail.show'); Route::post('/upload', [ApiFormUploadController::class, 'store']) ->name('code16.sharp.api.form.upload'); - Route::post('/{filterKey}/form/autocomplete/{entityKey}/{autocompleteFieldKey}', [ApiFormAutocompleteController::class, 'index']) + Route::post('/{globalFilter}/form/autocomplete/{entityKey}/{autocompleteFieldKey}', [ApiFormAutocompleteController::class, 'index']) ->name('code16.sharp.api.form.autocomplete.index'); - Route::post('/{filterKey}/form/refresh/{entityKey}', [ApiFormRefreshController::class, 'update']) + Route::post('/{globalFilter}/form/refresh/{entityKey}', [ApiFormRefreshController::class, 'update']) ->name('code16.sharp.api.form.refresh.update'); - Route::post('/{filterKey}/filters/autocomplete/{entityKey}/{filterHandlerKey}', [ApiFilterAutocompleteController::class, 'index']) + Route::post('/{globalFilter}/filters/autocomplete/{entityKey}/{filterHandlerKey}', [ApiFilterAutocompleteController::class, 'index']) ->name('code16.sharp.api.filters.autocomplete.index'); }); diff --git a/src/routes/web.php b/src/routes/web.php index 3d1d270b5..65d4aeeb2 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -17,59 +17,59 @@ 'prefix' => '/'.sharp()->config()->get('custom_url_segment'), 'middleware' => ['sharp_common', 'sharp_web'], ], function () { - // Redirect GET routes without filterKey + // Redirect GET routes without globalFilter Route::get('/', fn () => redirect( route('code16.sharp.home', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), ]) )); Route::get('s-dashboard/{dashboardKey}', fn ($entityKey) => redirect( route('code16.sharp.dashboard', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'dashboardKey' => $entityKey, ]) )); Route::get('s-list/{entityKey}', fn ($entityKey) => redirect( route('code16.sharp.list', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $entityKey, ]) )); Route::get('s-show/{entityKey}', fn ($entityKey) => redirect( route('code16.sharp.single-show', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $entityKey, ]) )); - Route::get('{filterKey}/home', [HomeController::class, 'index']) + Route::get('{globalFilter}/home', [HomeController::class, 'index']) ->name('code16.sharp.home'); - Route::get('{filterKey}/s-dashboard/{dashboardKey}', [DashboardController::class, 'show']) + Route::get('{globalFilter}/s-dashboard/{dashboardKey}', [DashboardController::class, 'show']) ->name('code16.sharp.dashboard'); - Route::post('{filterKey}/s-dashboard/{dashboardKey}', [DashboardFiltersController::class, 'store']) + Route::post('{globalFilter}/s-dashboard/{dashboardKey}', [DashboardFiltersController::class, 'store']) ->name('code16.sharp.dashboard.filters.store'); - Route::get('{filterKey}/s-list/{entityKey}', [EntityListController::class, 'show']) + Route::get('{globalFilter}/s-list/{entityKey}', [EntityListController::class, 'show']) ->name('code16.sharp.list'); - Route::post('{filterKey}/s-list/{entityKey}/filters', [EntityListFiltersController::class, 'store']) + Route::post('{globalFilter}/s-list/{entityKey}/filters', [EntityListFiltersController::class, 'store']) ->name('code16.sharp.list.filters.store'); - Route::get('{filterKey}/s-show/{entityKey}', [SingleShowController::class, 'show']) + Route::get('{globalFilter}/s-show/{entityKey}', [SingleShowController::class, 'show']) ->name('code16.sharp.single-show'); - Route::get('{filterKey}/download/{entityKey}/{instanceId?}', [DownloadController::class, 'show']) + Route::get('{globalFilter}/download/{entityKey}/{instanceId?}', [DownloadController::class, 'show']) ->name('code16.sharp.download.show'); Route::where([ 'parentUri' => '(s-list|s-show)/.+', ])->group(function () { - // Redirect GET routes without filterKey + // Redirect GET routes without globalFilter Route::get('{parentUri}/s-show/{entityKey}/{instanceId}', fn ($parentUri, $entityKey, $instanceId) => redirect( route('code16.sharp.show.show', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'parentUri' => $parentUri, 'entityKey' => $entityKey, 'instanceId' => $instanceId, @@ -77,40 +77,40 @@ )); Route::get('{parentUri}/s-form/{entityKey}', fn ($parentUri, $entityKey) => redirect( route('code16.sharp.form.create', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'parentUri' => $parentUri, 'entityKey' => $entityKey, ]) )); Route::get('{parentUri}/s-form/{entityKey}/{instanceId}', fn ($parentUri, $entityKey, $instanceId) => redirect( route('code16.sharp.form.edit', [ - 'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), 'parentUri' => $parentUri, 'entityKey' => $entityKey, 'instanceId' => $instanceId, ]) )); - Route::get('/{filterKey}/{parentUri}/s-show/{entityKey}/{instanceId}', [ShowController::class, 'show']) + Route::get('/{globalFilter}/{parentUri}/s-show/{entityKey}/{instanceId}', [ShowController::class, 'show']) ->name('code16.sharp.show.show'); - Route::delete('/{filterKey}/{parentUri}/s-show/{entityKey}/{instanceId}', [ShowController::class, 'delete']) + Route::delete('/{globalFilter}/{parentUri}/s-show/{entityKey}/{instanceId}', [ShowController::class, 'delete']) ->name('code16.sharp.show.delete'); - Route::get('/{filterKey}/{parentUri}/s-form/{entityKey}', [FormController::class, 'create']) + Route::get('/{globalFilter}/{parentUri}/s-form/{entityKey}', [FormController::class, 'create']) ->name('code16.sharp.form.create'); - Route::post('/{filterKey}/{parentUri}/s-form/{entityKey}', [FormController::class, 'store']) + Route::post('/{globalFilter}/{parentUri}/s-form/{entityKey}', [FormController::class, 'store']) ->name('code16.sharp.form.store'); - Route::get('/{filterKey}/{parentUri}/s-form/{entityKey}/{instanceId?}', [FormController::class, 'edit']) + Route::get('/{globalFilter}/{parentUri}/s-form/{entityKey}/{instanceId?}', [FormController::class, 'edit']) ->name('code16.sharp.form.edit'); - Route::post('/{filterKey}/{parentUri}/s-form/{entityKey}/{instanceId?}', [FormController::class, 'update']) + Route::post('/{globalFilter}/{parentUri}/s-form/{entityKey}/{instanceId?}', [FormController::class, 'update']) ->name('code16.sharp.form.update'); }); - Route::post('{filterKey}/filters', [GlobalFilterController::class, 'update']) + Route::post('{globalFilter}/filters', [GlobalFilterController::class, 'update']) ->name('code16.sharp.filters.update'); Route::post('/update-assets', UpdateAssetsController::class) diff --git a/tests/Http/Api/ApiFilterAutocompleteTest.php b/tests/Http/Api/ApiFilterAutocompleteTest.php index 89669677a..4c8c56325 100644 --- a/tests/Http/Api/ApiFilterAutocompleteTest.php +++ b/tests/Http/Api/ApiFilterAutocompleteTest.php @@ -49,7 +49,7 @@ public function valueLabelFor(string $id): string $this ->postJson(route('code16.sharp.api.filters.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'filterHandlerKey' => 'test', ]), [ @@ -100,7 +100,7 @@ public function valueLabelFor(string $id): string $this ->postJson(route('code16.sharp.api.filters.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'filterHandlerKey' => 'test', ]), [ @@ -152,7 +152,7 @@ public function valueLabelFor(string $id): string $this ->postJson(route('code16.sharp.api.filters.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'dashboard', 'filterHandlerKey' => 'test', ]), [ diff --git a/tests/Http/Api/ApiFormAutocompleteControllerTest.php b/tests/Http/Api/ApiFormAutocompleteControllerTest.php index fc07c4497..0389677be 100644 --- a/tests/Http/Api/ApiFormAutocompleteControllerTest.php +++ b/tests/Http/Api/ApiFormAutocompleteControllerTest.php @@ -44,7 +44,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -79,7 +79,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -120,7 +120,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'list.autocomplete_field', 'formData' => [ @@ -162,7 +162,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -202,7 +202,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -239,7 +239,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -276,7 +276,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -319,7 +319,7 @@ public function getNameAndJob(): string $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -354,7 +354,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -385,7 +385,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ])); @@ -406,7 +406,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'name', ])); @@ -432,7 +432,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -460,7 +460,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -494,7 +494,7 @@ public function buildFormFields(FieldsContainer $formFields): void foreach (['/my/endpoint', url('/my/endpoint')] as $endpoint) { $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -505,7 +505,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_full_field', ]), [ @@ -533,7 +533,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -560,7 +560,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -587,7 +587,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -614,7 +614,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -642,7 +642,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', ]), [ @@ -676,7 +676,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'embed_key' => (new ApiFormAutocompleteControllerAutocompleteEmbed())->key(), @@ -729,7 +729,7 @@ public function execute(mixed $instanceId, array $data = []): array {} $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'instance_id' => 1, @@ -783,7 +783,7 @@ public function execute(array $data = []): array {} $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'entity_list_command_key' => 'my-command', @@ -836,7 +836,7 @@ protected function executeSingle(array $data): array {} $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'instance_id' => 1, @@ -890,7 +890,7 @@ protected function executeSingle(array $data): array {} $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'show_command_key' => 'my-command', @@ -948,7 +948,7 @@ public function execute(mixed $instanceId, array $data = []): array {} $this ->postJson(route('code16.sharp.api.form.autocomplete.index', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'autocompleteFieldKey' => 'autocomplete_field', 'instance_id' => 1, diff --git a/tests/Http/Api/ApiFormRefreshControllerTest.php b/tests/Http/Api/ApiFormRefreshControllerTest.php index 1b8f34656..e49636bd2 100644 --- a/tests/Http/Api/ApiFormRefreshControllerTest.php +++ b/tests/Http/Api/ApiFormRefreshControllerTest.php @@ -46,7 +46,7 @@ public function update(mixed $id, array $data) {} $this->post( route('code16.sharp.api.form.refresh.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instance_id' => 1, ]), @@ -97,7 +97,7 @@ public function execute(array $data = []): array $this->post( route('code16.sharp.api.form.refresh.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'entity_list_command_key' => 'cmd', ]), @@ -148,7 +148,7 @@ public function execute(mixed $instanceId, array $data = []): array $this->post( route('code16.sharp.api.form.refresh.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'entity_list_command_key' => 'cmd', 'instance_id' => 1, @@ -200,7 +200,7 @@ public function execute(mixed $instanceId, array $data = []): array $this->post( route('code16.sharp.api.form.refresh.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'show_command_key' => 'cmd', 'instance_id' => 1, @@ -230,7 +230,7 @@ public function execute(mixed $instanceId, array $data = []): array $this ->postJson( route('code16.sharp.api.form.refresh.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'embed_key' => (new ApiFormRefreshControllerEmbed())->key(), ]), diff --git a/tests/Http/Api/ApiFormUploadThumbnailControllerTest.php b/tests/Http/Api/ApiFormUploadThumbnailControllerTest.php index ca1a0256b..c7eae602e 100644 --- a/tests/Http/Api/ApiFormUploadThumbnailControllerTest.php +++ b/tests/Http/Api/ApiFormUploadThumbnailControllerTest.php @@ -13,7 +13,7 @@ ->storeAs('data/Posts/1', 'image.jpg', ['disk' => 'local']); $this->postJson(route('code16.sharp.api.form.upload.thumbnail.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => '1', 'path' => 'data/Posts/1/image.jpg', diff --git a/tests/Http/Api/Commands/ApiEntityListEntityCommandControllerTest.php b/tests/Http/Api/Commands/ApiEntityListEntityCommandControllerTest.php index e889d4de2..fd36d0bec 100644 --- a/tests/Http/Api/Commands/ApiEntityListEntityCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiEntityListEntityCommandControllerTest.php @@ -41,7 +41,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -76,7 +76,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -109,7 +109,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -144,7 +144,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -177,7 +177,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -221,7 +221,7 @@ public function getListData(): array|\Illuminate\Contracts\Support\Arrayable }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -258,7 +258,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -293,7 +293,7 @@ public function execute(array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -337,7 +337,7 @@ public function execute(array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -351,7 +351,7 @@ public function execute(array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -395,7 +395,7 @@ public function execute(array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -409,7 +409,7 @@ public function execute(array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -447,7 +447,7 @@ public function execute(array $data = []): array $response = $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -481,7 +481,7 @@ public function execute(array $data = []): array $response = $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -516,7 +516,7 @@ public function execute(array $data = []): array $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -551,7 +551,7 @@ public function execute(array $data = []): array $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -592,7 +592,7 @@ public function execute(array $data = []): array }); $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ]), @@ -674,7 +674,7 @@ public function execute(array $data = []): array $this ->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -749,7 +749,7 @@ public function execute(array $data = []): array {} }); $this->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])); @@ -793,7 +793,7 @@ public function execute(array $data = []): array $this ->withoutExceptionHandling() ->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -842,7 +842,7 @@ public function getDataLocalizations(): array $this ->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) @@ -902,7 +902,7 @@ public function initialData(): array $this ->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', ])) diff --git a/tests/Http/Api/Commands/ApiEntityListEntityWizardCommandControllerTest.php b/tests/Http/Api/Commands/ApiEntityListEntityWizardCommandControllerTest.php index 9840c2fe8..fe78d81dd 100644 --- a/tests/Http/Api/Commands/ApiEntityListEntityWizardCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiEntityListEntityWizardCommandControllerTest.php @@ -40,7 +40,7 @@ protected function executeFirstStep(array $data): array $this ->getJson(route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ])) @@ -110,7 +110,7 @@ protected function executeFirstStep(array $data): array $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ])) @@ -119,7 +119,7 @@ protected function executeFirstStep(array $data): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ]), @@ -186,7 +186,7 @@ protected function executeStepNextStep(array $data): array $this ->getJson( route('code16.sharp.api.list.command.entity.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'command_step' => 'next-step:test-key', @@ -198,7 +198,7 @@ protected function executeStepNextStep(array $data): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ]), @@ -279,7 +279,7 @@ protected function executeStepNextStep(array $data): array $this ->postJson( route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ]), @@ -352,7 +352,7 @@ public function executeStep(string $step, array $data = []): array // First post step 1... $this ->postJson(route('code16.sharp.api.list.command.entity', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', ])) diff --git a/tests/Http/Api/Commands/ApiEntityListInstanceCommandControllerTest.php b/tests/Http/Api/Commands/ApiEntityListInstanceCommandControllerTest.php index a7ee37c92..82445e26c 100644 --- a/tests/Http/Api/Commands/ApiEntityListInstanceCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiEntityListInstanceCommandControllerTest.php @@ -38,7 +38,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_info', 'instanceId' => 1, @@ -74,7 +74,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_reload', 'instanceId' => 1, @@ -108,7 +108,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_info', 'instanceId' => 1, @@ -144,7 +144,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_view', 'instanceId' => 1, @@ -178,7 +178,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_html', 'instanceId' => 1, @@ -223,7 +223,7 @@ public function getListData(): array|\Illuminate\Contracts\Support\Arrayable }); $this->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_refresh', 'instanceId' => 1, @@ -270,7 +270,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_form', 'instanceId' => 1, @@ -285,7 +285,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson( route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_form', 'instanceId' => 1, @@ -324,7 +324,7 @@ public function execute($instanceId, array $data = []): array $response = $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_download', 'instanceId' => 1, @@ -359,7 +359,7 @@ public function execute($instanceId, array $data = []): array $response = $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_streamDownload', 'instanceId' => 1, @@ -395,7 +395,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_417', 'instanceId' => 1, @@ -435,7 +435,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_unauthorized', 'instanceId' => 1, @@ -444,7 +444,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_unauthorized', 'instanceId' => 2, @@ -481,7 +481,7 @@ public function execute($instanceId, array $data = []): array $this ->getJson(route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_form', 'instanceId' => 1, @@ -553,7 +553,7 @@ public function execute($instanceId, array $data = []): array $this ->getJson(route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', 'instanceId' => 1, @@ -603,7 +603,7 @@ public function getDataLocalizations(): array $this ->getJson(route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_form_localized', 'instanceId' => 1, @@ -664,7 +664,7 @@ public function initialData($instanceId): array $this ->getJson(route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'instance_with_init_data', 'instanceId' => 1, diff --git a/tests/Http/Api/Commands/ApiEntityListInstanceWizardCommandControllerTest.php b/tests/Http/Api/Commands/ApiEntityListInstanceWizardCommandControllerTest.php index 13f2a39e7..bd954f4ea 100644 --- a/tests/Http/Api/Commands/ApiEntityListInstanceWizardCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiEntityListInstanceWizardCommandControllerTest.php @@ -40,7 +40,7 @@ protected function executeFirstStep($instanceId, array $data): array $this ->getJson(route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1])) @@ -110,7 +110,7 @@ protected function executeFirstStep($instanceId, array $data): array $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1])) @@ -119,7 +119,7 @@ protected function executeFirstStep($instanceId, array $data): array $this ->postJson( route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1, @@ -187,7 +187,7 @@ protected function executeStepNextStep($instanceId, array $data): array $this ->getJson( route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1, @@ -200,7 +200,7 @@ protected function executeStepNextStep($instanceId, array $data): array $this ->postJson( route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1, @@ -212,7 +212,7 @@ protected function executeStepNextStep($instanceId, array $data): array $this ->getJson( route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1, @@ -284,7 +284,7 @@ protected function executeStepNextStep($instanceId, array $data): array $this ->postJson( route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1]), @@ -358,7 +358,7 @@ public function executeStep(string $step, $instanceId, array $data = []): array // First post step 1... $this ->postJson(route('code16.sharp.api.list.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1])) @@ -368,7 +368,7 @@ public function executeStep(string $step, $instanceId, array $data = []): array $this ->getJson( route('code16.sharp.api.list.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'wizard', 'instanceId' => 1, diff --git a/tests/Http/Api/Commands/ApiEntityListQuickCreationCommandControllerTest.php b/tests/Http/Api/Commands/ApiEntityListQuickCreationCommandControllerTest.php index a520e5184..bdd973395 100644 --- a/tests/Http/Api/Commands/ApiEntityListQuickCreationCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiEntityListQuickCreationCommandControllerTest.php @@ -35,7 +35,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->getJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -74,7 +74,7 @@ public function buildFormFields(FieldsContainer $formFields): void $this ->getJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -92,7 +92,7 @@ public function buildListConfig(): void {} $this ->getJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -131,7 +131,7 @@ public function update($id, array $data) $this ->postJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -160,7 +160,7 @@ public function update($id, array $data) {} $this ->postJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -198,7 +198,7 @@ public function update($id, array $data) $this ->postJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -241,7 +241,7 @@ public function update($id, array $data) $this ->postJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -278,7 +278,7 @@ public function update($id, array $data) $this ->postJson( route('code16.sharp.api.list.command.quick-creation-form.create', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'formEntityKey' => 'person', ]), @@ -319,7 +319,7 @@ public function update($id, array $data) $this ->get( route('code16.sharp.show.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'parentUri' => 's-list/person/', 'person', 1, diff --git a/tests/Http/Api/Commands/ApiShowInstanceCommandControllerTest.php b/tests/Http/Api/Commands/ApiShowInstanceCommandControllerTest.php index 07cf7999f..9c54297f3 100644 --- a/tests/Http/Api/Commands/ApiShowInstanceCommandControllerTest.php +++ b/tests/Http/Api/Commands/ApiShowInstanceCommandControllerTest.php @@ -37,7 +37,7 @@ public function execute($instanceId, array $data = []): array }); $this->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', 'instanceId' => 1, @@ -75,7 +75,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'cmd', ])) @@ -132,7 +132,7 @@ public function execute($instanceId, array $data = []): array $this ->getJson(route('code16.sharp.api.show.command.instance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', 'instanceId' => 1, @@ -177,7 +177,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson( route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'commandKey' => 'cmd', 'instanceId' => 1, @@ -234,7 +234,7 @@ public function execute($instanceId, array $data = []): array $this ->getJson( route('code16.sharp.api.show.command.singleInstance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'single_cmd', ]) @@ -279,7 +279,7 @@ public function execute($instanceId, array $data = []): array $this ->postJson( route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'single_cmd', ]), diff --git a/tests/Http/Api/DownloadControllerTest.php b/tests/Http/Api/DownloadControllerTest.php index 9989a66ad..9ae1f62b0 100644 --- a/tests/Http/Api/DownloadControllerTest.php +++ b/tests/Http/Api/DownloadControllerTest.php @@ -18,7 +18,7 @@ $response = $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'disk' => 'local', @@ -38,7 +38,7 @@ $response = $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'disk' => 'local', @@ -55,7 +55,7 @@ $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'fileName' => 'test.jpg', @@ -72,7 +72,7 @@ $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'disk' => 'local', @@ -91,7 +91,7 @@ $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'disk' => 'local', @@ -110,7 +110,7 @@ $this ->get( route('code16.sharp.download.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', 'instanceId' => 1, 'disk' => 'local', diff --git a/tests/Http/Api/Embeds/ApiEmbedsFormControllerTest.php b/tests/Http/Api/Embeds/ApiEmbedsFormControllerTest.php index 37be4a049..70995a7f0 100644 --- a/tests/Http/Api/Embeds/ApiEmbedsFormControllerTest.php +++ b/tests/Http/Api/Embeds/ApiEmbedsFormControllerTest.php @@ -18,7 +18,7 @@ $this ->postJson( route('code16.sharp.api.embed.instance.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, @@ -64,7 +64,7 @@ $this ->postJson( route('code16.sharp.api.embed.instance.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, @@ -98,7 +98,7 @@ public function entity($user): bool $this ->postJson( route('code16.sharp.api.embed.instance.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, @@ -109,7 +109,7 @@ public function entity($user): bool $this ->postJson( route('code16.sharp.api.embed.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', ]), @@ -129,7 +129,7 @@ public function view($user, $instanceId): bool $this ->postJson( route('code16.sharp.api.embed.instance.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, @@ -140,7 +140,7 @@ public function view($user, $instanceId): bool $this ->postJson( route('code16.sharp.api.embed.instance.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 2, @@ -151,7 +151,7 @@ public function view($user, $instanceId): bool $this ->postJson( route('code16.sharp.api.embed.form.show', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', ]), @@ -166,7 +166,7 @@ public function view($user, $instanceId): bool $this ->postJson( route('code16.sharp.api.embed.instance.form.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, @@ -188,7 +188,7 @@ public function view($user, $instanceId): bool $this ->postJson( route('code16.sharp.api.embed.instance.form.update', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'embedKey' => ApiEmbedsFormControllerTestEmbed::$key, 'entityKey' => 'person', 'instanceId' => 1, diff --git a/tests/Http/Auth/ChangePasswordCommandTraitTest.php b/tests/Http/Auth/ChangePasswordCommandTraitTest.php index 90ba2d8f0..a8aa0ee11 100644 --- a/tests/Http/Auth/ChangePasswordCommandTraitTest.php +++ b/tests/Http/Auth/ChangePasswordCommandTraitTest.php @@ -41,7 +41,7 @@ protected function executeSingle(array $data): array // Fetch the command form (single show variant) $this ->getJson(route('code16.sharp.api.show.command.singleInstance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password', ])) @@ -85,7 +85,7 @@ protected function executeSingle(array $data): array // Form contains the confirmation field $this ->getJson(route('code16.sharp.api.show.command.singleInstance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ])) @@ -101,7 +101,7 @@ protected function executeSingle(array $data): array // Fails when confirmation is missing/mismatch $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ]), [ @@ -116,7 +116,7 @@ protected function executeSingle(array $data): array // Fails when password rule is not satisfied (requires number) $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ]), [ @@ -132,7 +132,7 @@ protected function executeSingle(array $data): array // Succeeds with valid data $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ]), [ @@ -172,7 +172,7 @@ protected function executeSingle(array $data): array // Form does not contain the current password field $this ->getJson(route('code16.sharp.api.show.command.singleInstance.form', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ])) @@ -187,7 +187,7 @@ protected function executeSingle(array $data): array // Succeeds with valid data $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_confirm', ]), [ @@ -221,7 +221,7 @@ protected function executeSingle(array $data): array for ($i = 0; $i < 3; $i++) { $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_rl', ]), [ @@ -235,7 +235,7 @@ protected function executeSingle(array $data): array // 4th attempt should be blocked by rate limiter with SharpApplicativeException (417) $this ->postJson(route('code16.sharp.api.show.command.instance', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'single-person', 'commandKey' => 'change_password_rl', ]), [ diff --git a/tests/Http/BreadcrumbTest.php b/tests/Http/BreadcrumbTest.php index d04cd4d79..4079ec096 100644 --- a/tests/Http/BreadcrumbTest.php +++ b/tests/Http/BreadcrumbTest.php @@ -15,7 +15,7 @@ // We add a default here to avoid putting this everywhere in unit tests // it's handled by middleware in a real request, but we don't want to test that here. - \Illuminate\Support\Facades\URL::defaults(['filterKey' => \Code16\Sharp\Filters\GlobalFilters\GlobalFilters::$defaultKey]); + \Illuminate\Support\Facades\URL::defaults(['globalFilter' => \Code16\Sharp\Filters\GlobalFilters\GlobalFilters::$defaultKey]); }); it('builds the breadcrumb for an entity list', function () { diff --git a/tests/Http/Context/SharpContextTest.php b/tests/Http/Context/SharpContextTest.php index 91e98663e..321e9bcc2 100644 --- a/tests/Http/Context/SharpContextTest.php +++ b/tests/Http/Context/SharpContextTest.php @@ -197,7 +197,7 @@ public function values(): array ->withoutExceptionHandling() ->post( route('code16.sharp.list.filters.store', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', ]), [ 'filterValues' => [ diff --git a/tests/Http/FiltersInRequestTest.php b/tests/Http/FiltersInRequestTest.php index 4d2c48e0f..5d670db9a 100644 --- a/tests/Http/FiltersInRequestTest.php +++ b/tests/Http/FiltersInRequestTest.php @@ -227,7 +227,7 @@ public function getListData(): array|Arrayable ->withoutExceptionHandling() ->post( route('code16.sharp.list.filters.store', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', ]), [ 'filterValues' => ['job' => 'physicist'], @@ -323,7 +323,7 @@ public function values(): array $this ->post( route('code16.sharp.list.filters.store', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', ]), [ 'filterValues' => ['job' => ['physicist', 'physician']], @@ -484,7 +484,7 @@ public function values(): array $this ->post( route('code16.sharp.list.filters.store', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'entityKey' => 'person', ]), [ 'filterValues' => [ diff --git a/tests/Http/GlobalFilterRoutesTest.php b/tests/Http/GlobalFilterRoutesTest.php index 11cbff813..b580fd25a 100644 --- a/tests/Http/GlobalFilterRoutesTest.php +++ b/tests/Http/GlobalFilterRoutesTest.php @@ -13,7 +13,7 @@ login(); }); -it('redirects to route with default filterKey when missing', function () { +it('redirects to route with default globalFilter when missing', function () { sharp()->config() ->declareEntity(DashboardEntity::class) ->declareEntity(SinglePersonEntity::class); @@ -37,14 +37,14 @@ ->assertRedirect('/sharp/root/s-show/single-person'); }); -it('redirects to route with correct filterKey when missing and global filters are defined', function () { +it('redirects to route with correct globalFilter when missing and global filters are defined', function () { fakeGlobalFilter(); $this->get('/sharp/s-list/person') ->assertRedirect('/sharp/two/s-list/person'); }); -it('sets the current filterKey according to the URL', function () { +it('sets the current globalFilter according to the URL', function () { fakeGlobalFilter(); $this->get('/sharp/one/s-list/person/s-show/person/1') @@ -53,7 +53,7 @@ expect(sharp()->context()->globalFilterValue('test'))->toEqual('one'); }); -it('sets the current filterKey according to the URL for API routes', function () { +it('sets the current globalFilter according to the URL for API routes', function () { fakeGlobalFilter(); fakeListFor('person', new class() extends PersonList { @@ -85,16 +85,16 @@ public function execute(array $data = []): array {} expect(sharp()->context()->globalFilterValue('test'))->toEqual('one'); }); -it('redirects to the homepage if an invalid filterKey is set in the URL', function () { +it('redirects to the homepage if an invalid globalFilter is set in the URL', function () { fakeGlobalFilter(); $this->get('/sharp/five/s-list/person/s-show/person/1') - ->assertRedirect(route('code16.sharp.home', ['filterKey' => 'two'])); + ->assertRedirect(route('code16.sharp.home', ['globalFilter' => 'two'])); expect(sharp()->context()->globalFilterValue('test'))->toEqual('two'); }); -it('redirects to route with correct filterKeys when missing and multiple global filters are defined', function () { +it('redirects to route with correct globalFilters when missing and multiple global filters are defined', function () { fakeGlobalFilter('test1'); fakeGlobalFilter('test2'); @@ -102,7 +102,7 @@ public function execute(array $data = []): array {} ->assertRedirect('/sharp/two~two/s-list/person'); }); -it('sets the current multiple filterKeys according to the URL', function () { +it('sets the current multiple globalFilters according to the URL', function () { fakeGlobalFilter('test1'); fakeGlobalFilter('test2'); diff --git a/tests/Pest.php b/tests/Pest.php index 9b9b52f17..132a6f3eb 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -15,7 +15,7 @@ ->beforeEach(function () { // We add a default here to avoid putting this everywhere in unit tests // it's handled by middleware in a real request, but we don't want to test that here. - \Illuminate\Support\Facades\URL::defaults(['filterKey' => \Code16\Sharp\Filters\GlobalFilters\GlobalFilters::$defaultKey]); + \Illuminate\Support\Facades\URL::defaults(['globalFilter' => \Code16\Sharp\Filters\GlobalFilters\GlobalFilters::$defaultKey]); }) ->in(__DIR__.'/Unit'); diff --git a/tests/Unit/Utils/Testing/SharpAssertionsTest.php b/tests/Unit/Utils/Testing/SharpAssertionsTest.php index 0f45c3822..64b2fc166 100644 --- a/tests/Unit/Utils/Testing/SharpAssertionsTest.php +++ b/tests/Unit/Utils/Testing/SharpAssertionsTest.php @@ -205,7 +205,7 @@ $this->assertEquals( route('code16.sharp.form.edit', [ - 'filterKey' => 'root', + 'globalFilter' => 'root', 'parentUri' => 's-list/leaves', 'entityKey' => 'leaves', 'instanceId' => 6, @@ -217,13 +217,13 @@ $this->assertEquals( route('code16.sharp.form.edit', [ - 'filterKey' => 'one', + 'globalFilter' => 'one', 'parentUri' => 's-list/leaves', 'entityKey' => 'leaves', 'instanceId' => 6, ]), fakeResponse() - ->withSharpGlobalFilterKeys('one') + ->withSharpGlobalFilterValues('one') ->getSharpForm('leaves', 6) ->uri, ); @@ -232,13 +232,13 @@ $this->assertEquals( route('code16.sharp.form.edit', [ - 'filterKey' => 'one~two', + 'globalFilter' => 'one~two', 'parentUri' => 's-list/leaves', 'entityKey' => 'leaves', 'instanceId' => 6, ]), fakeResponse() - ->withSharpGlobalFilterKeys(['one', 'two']) + ->withSharpGlobalFilterValues(['one', 'two']) ->getSharpForm('leaves', 6) ->uri, ); From fff3003649b19c9ede0b881a90f528e6be784b6e Mon Sep 17 00:00:00 2001 From: antoine Date: Wed, 17 Dec 2025 15:22:15 +0100 Subject: [PATCH 2/4] rename types --- resources/js/types/routes.d.ts | 86 +++++++++---------- src/Data/Dashboard/DashboardData.php | 2 +- .../EntityList/EntityListQueryParamsData.php | 2 +- .../Commands/TypescriptGenerateCommand.php | 2 +- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/resources/js/types/routes.d.ts b/resources/js/types/routes.d.ts index 8df621c42..78dcac1db 100644 --- a/resources/js/types/routes.d.ts +++ b/resources/js/types/routes.d.ts @@ -3,12 +3,12 @@ declare module 'ziggy-js' { interface RouteList { "code16.sharp.home": [ { - "name": "filterKey" + "name": "globalFilter" } ], "code16.sharp.dashboard": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -18,7 +18,7 @@ declare module 'ziggy-js' { ], "code16.sharp.dashboard.filters.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -27,7 +27,7 @@ declare module 'ziggy-js' { ], "code16.sharp.list": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -37,7 +37,7 @@ declare module 'ziggy-js' { ], "code16.sharp.list.filters.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -46,7 +46,7 @@ declare module 'ziggy-js' { ], "code16.sharp.single-show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -56,7 +56,7 @@ declare module 'ziggy-js' { ], "code16.sharp.download.show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -69,7 +69,7 @@ declare module 'ziggy-js' { ], "code16.sharp.show.show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -87,7 +87,7 @@ declare module 'ziggy-js' { ], "code16.sharp.show.delete": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -104,7 +104,7 @@ declare module 'ziggy-js' { ], "code16.sharp.form.create": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -118,7 +118,7 @@ declare module 'ziggy-js' { ], "code16.sharp.form.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -132,7 +132,7 @@ declare module 'ziggy-js' { ], "code16.sharp.form.edit": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -150,7 +150,7 @@ declare module 'ziggy-js' { ], "code16.sharp.form.update": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "parentUri", @@ -168,13 +168,13 @@ declare module 'ziggy-js' { ], "code16.sharp.filters.update": [ { - "name": "filterKey" + "name": "globalFilter" } ], "code16.sharp.update-assets": [], "code16.sharp.api.dashboard.command.form": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -187,7 +187,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.dashboard.command": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -200,7 +200,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.quick-creation-form.create": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -215,7 +215,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.quick-creation-form.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -230,7 +230,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -240,7 +240,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.filters.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -249,7 +249,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.reorder": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -258,7 +258,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.delete": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -271,7 +271,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.state": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -284,7 +284,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.entity": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -297,7 +297,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.entity.form": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -310,7 +310,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.instance": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -327,7 +327,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.list.command.instance.form": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -344,7 +344,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.dashboard": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -354,7 +354,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.dashboard.filters.store": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "dashboardKey", @@ -363,7 +363,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.show.command.instance": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -380,7 +380,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.show.command.instance.form": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -397,7 +397,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.show.command.singleInstance.form": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -410,7 +410,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.show.state": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -423,12 +423,12 @@ declare module 'ziggy-js' { ], "code16.sharp.api.search.index": [ { - "name": "filterKey" + "name": "globalFilter" } ], "code16.sharp.api.embed.form.show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "embedKey", @@ -441,7 +441,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.embed.form.update": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "embedKey", @@ -454,7 +454,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.embed.instance.form.show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "embedKey", @@ -471,7 +471,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.embed.instance.form.update": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "embedKey", @@ -488,7 +488,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.form.editor.upload.form.update": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -501,7 +501,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.form.upload.thumbnail.show": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -515,7 +515,7 @@ declare module 'ziggy-js' { "code16.sharp.api.form.upload": [], "code16.sharp.api.form.autocomplete.index": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -529,7 +529,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.form.refresh.update": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", @@ -539,7 +539,7 @@ declare module 'ziggy-js' { ], "code16.sharp.api.filters.autocomplete.index": [ { - "name": "filterKey" + "name": "globalFilter" }, { "name": "entityKey", diff --git a/src/Data/Dashboard/DashboardData.php b/src/Data/Dashboard/DashboardData.php index 859aebc59..4439de46d 100644 --- a/src/Data/Dashboard/DashboardData.php +++ b/src/Data/Dashboard/DashboardData.php @@ -23,7 +23,7 @@ public function __construct( public FilterValuesData $filterValues, public ?PageAlertData $pageAlert = null, #[LiteralTypeScriptType('{ - [globalFilter: string]: string, + [filterKey: string]: string, }')] public ?array $query = null, ) {} diff --git a/src/Data/EntityList/EntityListQueryParamsData.php b/src/Data/EntityList/EntityListQueryParamsData.php index ee279d759..a935661c6 100644 --- a/src/Data/EntityList/EntityListQueryParamsData.php +++ b/src/Data/EntityList/EntityListQueryParamsData.php @@ -12,7 +12,7 @@ sort?: string, dir?: "asc" | "desc", } & { - [globalFilter: string]: string, + [filterKey: string]: string, }')] /** * @internal diff --git a/src/Dev/Commands/TypescriptGenerateCommand.php b/src/Dev/Commands/TypescriptGenerateCommand.php index 8551379b1..33cd656dd 100644 --- a/src/Dev/Commands/TypescriptGenerateCommand.php +++ b/src/Dev/Commands/TypescriptGenerateCommand.php @@ -33,7 +33,7 @@ public function handle() file_put_contents( $ziggyOutput = base_path(config('ziggy.output.path')), str(file_get_contents($ziggyOutput)) - ->replaceMatches('/("name": "filterKey"),\s+"required": true/', '$1') + ->replaceMatches('/("name": "globalFilter"),\s+"required": true/', '$1') ); Artisan::call('typescript:transform', [], $this->output); From aed2779a8651a2d06bc3bd61b7bdc02e4b5d9173 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 17 Dec 2025 16:26:54 +0100 Subject: [PATCH 3/4] Throw an exception instead of aborting for invalid --- .../SharpInvalidGlobalFilterKeyException.php | 11 +++++++++++ src/Http/Context/SharpContext.php | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/Exceptions/SharpInvalidGlobalFilterKeyException.php diff --git a/src/Exceptions/SharpInvalidGlobalFilterKeyException.php b/src/Exceptions/SharpInvalidGlobalFilterKeyException.php new file mode 100644 index 000000000..24bd4f96b --- /dev/null +++ b/src/Exceptions/SharpInvalidGlobalFilterKeyException.php @@ -0,0 +1,11 @@ +globalFiltersHandler->findFilter($handlerClassOrKey); - abort_if(! $handler instanceof GlobalRequiredFilter, 404); + throw_if( + ! $handler instanceof GlobalRequiredFilter, + new SharpInvalidGlobalFilterKeyException('Filter ['.$handlerClassOrKey.'] is not a global required filter.') + ); return $handler->currentValue(); } From df5b6a4c3a2ba11c92fa07058b35a1d0f4d6b517 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 17 Dec 2025 16:27:27 +0100 Subject: [PATCH 4/4] Add SharpLinkTo::withGlobalFilterValues() + test + doc --- docs/guide/link-to.md | 4 ++++ src/Utils/Links/LinkToDashboard.php | 5 ++++- src/Utils/Links/LinkToEntityList.php | 2 +- src/Utils/Links/LinkToShowPage.php | 3 ++- src/Utils/Links/LinkToSingleShowPage.php | 2 +- src/Utils/Links/SharpLinkTo.php | 10 ++++++++++ tests/Unit/Utils/SharpLinkToTest.php | 12 ++++++++++++ 7 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/guide/link-to.md b/docs/guide/link-to.md index 9dc92d499..96f72b7ff 100644 --- a/docs/guide/link-to.md +++ b/docs/guide/link-to.md @@ -118,6 +118,10 @@ Set a filter and its value; for the filter, you can either pass its custom key o Set a default sort. +### `withGlobalFilterValues(array|string $globalFilterValues)` + +Set a global filter value(s). Ex: `LinkToShowPage::make(...)->withGlobalFilterValues($tenant->id)->renderAsUrl()`. + ### `setFullQuerystring(array $querystring)` `LinkToEntityList` only diff --git a/src/Utils/Links/LinkToDashboard.php b/src/Utils/Links/LinkToDashboard.php index ef395152a..20079e6a7 100644 --- a/src/Utils/Links/LinkToDashboard.php +++ b/src/Utils/Links/LinkToDashboard.php @@ -11,6 +11,9 @@ public static function make(string $entityClassOrKey): self public function renderAsUrl(): string { - return route('code16.sharp.dashboard', $this->entityKey); + return route('code16.sharp.dashboard', [ + 'globalFilter' => $this->globalFilter ?: sharp()->context()->globalFilterUrlSegmentValue(), + 'dashboardKey' => $this->entityKey, + ]); } } diff --git a/src/Utils/Links/LinkToEntityList.php b/src/Utils/Links/LinkToEntityList.php index 265fff9c1..8a233a305 100644 --- a/src/Utils/Links/LinkToEntityList.php +++ b/src/Utils/Links/LinkToEntityList.php @@ -55,7 +55,7 @@ public function renderAsUrl(): string return route('code16.sharp.list', array_merge( [ - 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => $this->globalFilter ?: sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $this->entityKey, ], $this->generateQuerystring(), diff --git a/src/Utils/Links/LinkToShowPage.php b/src/Utils/Links/LinkToShowPage.php index c8c0c5f46..3a8d78997 100644 --- a/src/Utils/Links/LinkToShowPage.php +++ b/src/Utils/Links/LinkToShowPage.php @@ -44,7 +44,7 @@ public function renderAsUrl(): string sprintf( '%s/%s/%s/%s', sharp()->config()->get('custom_url_segment'), - sharp()->context()->globalFilterUrlSegmentValue(), + $this->globalFilter ?: sharp()->context()->globalFilterUrlSegmentValue(), $this->breadcrumbBuilder->generateUri(), $this->generateUri() ) @@ -57,6 +57,7 @@ public function renderAsUrl(): string protected function generateUrl(): string { return route('code16.sharp.show.show', [ + 'globalFilter' => $this->globalFilter ?: sharp()->context()->globalFilterUrlSegmentValue(), 'parentUri' => sprintf('s-list/%s', $this->listEntityKey ?: $this->entityKey), 'entityKey' => $this->entityKey, 'instanceId' => $this->instanceId, diff --git a/src/Utils/Links/LinkToSingleShowPage.php b/src/Utils/Links/LinkToSingleShowPage.php index 80d75a7b5..d7cc0134f 100644 --- a/src/Utils/Links/LinkToSingleShowPage.php +++ b/src/Utils/Links/LinkToSingleShowPage.php @@ -12,7 +12,7 @@ public static function make(string $entityKey): self public function renderAsUrl(): string { return route('code16.sharp.single-show', [ - 'globalFilter' => sharp()->context()->globalFilterUrlSegmentValue(), + 'globalFilter' => $this->globalFilter ?: sharp()->context()->globalFilterUrlSegmentValue(), 'entityKey' => $this->entityKey, ]); } diff --git a/src/Utils/Links/SharpLinkTo.php b/src/Utils/Links/SharpLinkTo.php index 5336f81a3..0908ec21c 100644 --- a/src/Utils/Links/SharpLinkTo.php +++ b/src/Utils/Links/SharpLinkTo.php @@ -2,12 +2,14 @@ namespace Code16\Sharp\Utils\Links; +use Code16\Sharp\Filters\GlobalFilters\GlobalFilters; use Code16\Sharp\Utils\Entities\SharpEntityManager; abstract class SharpLinkTo { protected string $entityKey; protected string $tooltip = ''; + protected ?string $globalFilter = null; protected function __construct(string $entityClassOrKey) { @@ -21,6 +23,14 @@ public function setTooltip($tooltip): self return $this; } + public function withGlobalFilterValues(array|string $globalFilterValues): self + { + $this->globalFilter = collect((array) $globalFilterValues) + ->implode(GlobalFilters::$valuesUrlSeparator); + + return $this; + } + public function renderAsText(string $text): string { return sprintf( diff --git a/tests/Unit/Utils/SharpLinkToTest.php b/tests/Unit/Utils/SharpLinkToTest.php index 332cd3172..9dcf1249b 100644 --- a/tests/Unit/Utils/SharpLinkToTest.php +++ b/tests/Unit/Utils/SharpLinkToTest.php @@ -264,3 +264,15 @@ public function values(): array ->renderAsUrl(), ); }); + +it('allows to generate an url to a show page with a global filter', function () { + $this->assertEquals( + 'http://localhost/sharp/tenant-1/s-list/my-entity/s-show/my-entity/3', + LinkToShowPage::make('my-entity', 3) + ->withBreadcrumb(fn (BreadcrumbBuilder $builder) => $builder + ->appendEntityList('my-entity') + ) + ->withGlobalFilterValues('tenant-1') + ->renderAsUrl(), + ); +});