Add has_nami and two participant urls to form
This commit is contained in:
parent
e9e8b193f4
commit
43c528fc46
|
@ -35,6 +35,11 @@ class FieldCollection extends Collection
|
|||
return $this->filter(fn ($field) => !is_a($field, NamiField::class));
|
||||
}
|
||||
|
||||
public function hasNamiField(): bool
|
||||
{
|
||||
return $this->first(fn ($field) => is_a($field, NamiField::class)) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stdClass
|
||||
*/
|
||||
|
|
|
@ -46,8 +46,10 @@ class FormResource extends JsonResource
|
|||
'participants_count' => $this->participants_count,
|
||||
'is_active' => $this->is_active,
|
||||
'is_private' => $this->is_private,
|
||||
'has_nami_field' => $this->getFields()->hasNamiField(),
|
||||
'links' => [
|
||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel()]),
|
||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
||||
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
||||
'update' => route('form.update', ['form' => $this->getModel()]),
|
||||
'destroy' => route('form.destroy', ['form' => $this->getModel()]),
|
||||
'is_dirty' => route('form.is-dirty', ['form' => $this->getModel()]),
|
||||
|
|
|
@ -83,6 +83,18 @@ class FormIndexActionTest extends FormTestCase
|
|||
->assertInertiaCount('data.data', 2);
|
||||
}
|
||||
|
||||
public function testItDisplaysParentLinkForFormWithNamiFields(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form = Form::factory()->fields([$this->namiField('mitglieder')])->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaPath('data.data.0.has_nami_field', true)
|
||||
->assertInertiaPath('data.data.0.links.participant_root_index', route('form.participant.index', ['form' => $form, 'parent' => -1]))
|
||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form, 'parent' => null]));
|
||||
}
|
||||
|
||||
public function testItDisplaysRegisterUrl(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
|
Loading…
Reference in New Issue