diff --git a/resources/js/show/Show.ts b/resources/js/show/Show.ts index 057a9d4c8..64ef8c05e 100644 --- a/resources/js/show/Show.ts +++ b/resources/js/show/Show.ts @@ -32,21 +32,17 @@ export class Show implements ShowData { } get formUrl(): string { - const multiformKey = this.config.multiformAttribute - ? this.data[this.config.multiformAttribute] - : null; - if(route().params.instanceId) { return route('code16.sharp.form.edit', { parentUri: getAppendableParentUri(), - entityKey: multiformKey ? `${this.entityKey}:${multiformKey}` : this.entityKey, + entityKey: this.entityKey, instanceId: this.instanceId, }); } return route('code16.sharp.form.create', { parentUri: getAppendableParentUri(), - entityKey: multiformKey ? `${this.entityKey}:${multiformKey}` : this.entityKey, + entityKey: this.entityKey, }); } diff --git a/resources/js/types/generated.d.ts b/resources/js/types/generated.d.ts index 13e01f144..bb3391518 100644 --- a/resources/js/types/generated.d.ts +++ b/resources/js/types/generated.d.ts @@ -745,7 +745,6 @@ export type ShowConfigData = { deleteConfirmationText: string; isSingle: boolean; commands: ConfigCommandsData | null; - multiformAttribute: string | null; titleAttribute: string | null; breadcrumbAttribute: string | null; editButtonLabel: string | null; diff --git a/src/Data/Show/ShowConfigData.php b/src/Data/Show/ShowConfigData.php index 1bdbc1701..826d10be6 100644 --- a/src/Data/Show/ShowConfigData.php +++ b/src/Data/Show/ShowConfigData.php @@ -15,7 +15,6 @@ public function __construct( public string $deleteConfirmationText, public bool $isSingle = false, public ?ConfigCommandsData $commands = null, - public ?string $multiformAttribute = null, public ?string $titleAttribute = null, public ?string $breadcrumbAttribute = null, public ?string $editButtonLabel = null, diff --git a/src/Http/Controllers/ShowController.php b/src/Http/Controllers/ShowController.php index 5294ad6b5..d5444582c 100644 --- a/src/Http/Controllers/ShowController.php +++ b/src/Http/Controllers/ShowController.php @@ -33,7 +33,7 @@ public function show(string $parentUri, EntityKey $entityKey, string $instanceId abort_if($show instanceof SharpSingleShow, 404); $show->buildShowConfig(); - + $showData = $show->instance($instanceId); $payload = ShowData::from([ 'title' => $showData[$show->titleAttribute()] ?? $entity->getLabel($entityKey->subEntity()), diff --git a/src/Show/SharpShow.php b/src/Show/SharpShow.php index cebf10958..87dc9e3e2 100644 --- a/src/Show/SharpShow.php +++ b/src/Show/SharpShow.php @@ -24,7 +24,6 @@ abstract class SharpShow use WithCustomTransformers; protected ?ShowLayout $showLayout = null; - protected ?string $multiformAttribute = null; protected ?SharpShowTextField $pageTitleField = null; protected ?string $deleteConfirmationText = null; protected ?string $editButtonLabel = null; @@ -51,7 +50,6 @@ final public function instance(mixed $id): array ->merge(array_keys($this->transformers)) ->when($this->breadcrumbAttribute, fn ($collect) => $collect->push($this->breadcrumbAttribute)) ->when($this->entityStateAttribute, fn ($collect) => $collect->push($this->entityStateAttribute)) - ->when($this->multiformAttribute, fn ($collect) => $collect->push($this->multiformAttribute)) ->unique() ->values() ->toArray() @@ -66,9 +64,6 @@ public function showConfig(mixed $instanceId, array $config = []): array 'deleteConfirmationText' => $this->deleteConfirmationText ?: trans('sharp::show.delete_confirmation_text'), 'editButtonLabel' => $this->editButtonLabel, ]) - ->when($this->multiformAttribute, fn ($collection) => $collection->merge([ - 'multiformAttribute' => $this->multiformAttribute, - ])) ->when($this->pageTitleField, fn ($collection) => $collection->merge([ 'titleAttribute' => $this->pageTitleField->key, ])) @@ -81,10 +76,11 @@ public function showConfig(mixed $instanceId, array $config = []): array }); } + /** + * @deprecated to be deleted, no more useful + */ final protected function configureMultiformAttribute(string $attribute): self { - $this->multiformAttribute = $attribute; - return $this; } diff --git a/tests/Http/ShowControllerTest.php b/tests/Http/ShowControllerTest.php index 6debd7535..21aea7750 100644 --- a/tests/Http/ShowControllerTest.php +++ b/tests/Http/ShowControllerTest.php @@ -9,7 +9,6 @@ use Code16\Sharp\Show\Layout\ShowLayoutSection; use Code16\Sharp\Tests\Fixtures\Entities\PersonEntity; use Code16\Sharp\Tests\Fixtures\Entities\SinglePersonEntity; -use Code16\Sharp\Tests\Fixtures\Sharp\PersonForm; use Code16\Sharp\Tests\Fixtures\Sharp\PersonShow; use Code16\Sharp\Tests\Fixtures\Sharp\PersonSingleShow; use Code16\Sharp\Utils\Entities\SharpEntityManager; @@ -285,39 +284,6 @@ public function authorizeFor(mixed $instanceId): bool ); }); -it('returns the valuated multiform attribute if configured', function () { - fakeShowFor('person', new class() extends PersonShow - { - public function buildShowConfig(): void - { - $this->configureMultiformAttribute('nobel'); - } - - public function find($id): array - { - return [ - 'id' => 1, - 'name' => 'Marie Curie', - 'nobel' => 'nobelized', - ]; - } - }); - - app(SharpEntityManager::class) - ->entityFor('person') - ->setMultiforms([ - 'nobelized' => [PersonForm::class, 'With Nobel prize'], - 'nope' => [PersonForm::class, 'No Nobel prize'], - ]); - - $this->get('/sharp/s-list/person/s-show/person/1') - ->assertOk() - ->assertInertia(fn (Assert $page) => $page - ->where('show.config.multiformAttribute', 'nobel') - ->where('show.data.nobel', 'nobelized') - ); -}); - it('allows to configure a page alert', function () { fakeShowFor('person', new class() extends PersonShow {