Compare commits
4 Commits
98976700a9
...
d4057ff08f
Author | SHA1 | Date |
---|---|---|
|
d4057ff08f | |
|
657a648f46 | |
|
d9c45f5236 | |
|
5d48521875 |
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class ParticipantStoreAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var Form */
|
||||
$form = request()->route('form');
|
||||
|
||||
return $form->getRegistrationRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getValidationAttributes(): array
|
||||
{
|
||||
/** @var Form */
|
||||
$form = request()->route('form');
|
||||
|
||||
return $form->getRegistrationAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getValidationMessages(): array
|
||||
{
|
||||
/** @var Form */
|
||||
$form = request()->route('form');
|
||||
|
||||
return $form->getRegistrationMessages();
|
||||
}
|
||||
|
||||
public function handle(Form $form, ActionRequest $request): JsonResponse
|
||||
{
|
||||
$form->participants()->create(['data' => $request->validated()]);
|
||||
ExportSyncAction::dispatch($form->id);
|
||||
Succeeded::message('Teilnehmer*in erstellt.')->dispatch();
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
|
@ -17,15 +17,38 @@ class ParticipantUpdateAction
|
|||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'required',
|
||||
];
|
||||
/** @var Participant */
|
||||
$participant = request()->route('participant');
|
||||
|
||||
return $participant->form->getRegistrationRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getValidationAttributes(): array
|
||||
{
|
||||
/** @var Participant */
|
||||
$participant = request()->route('participant');
|
||||
|
||||
return $participant->form->getRegistrationAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getValidationMessages(): array
|
||||
{
|
||||
/** @var Participant */
|
||||
$participant = request()->route('participant');
|
||||
|
||||
return $participant->form->getRegistrationMessages();
|
||||
}
|
||||
|
||||
public function handle(Participant $participant, ActionRequest $request): JsonResponse
|
||||
{
|
||||
$participant->update(['data' => [...$participant->data, ...$request->validated('data')]]);
|
||||
|
||||
$participant->update(['data' => [...$participant->data, ...$request->validated()]]);
|
||||
ExportSyncAction::dispatch($participant->form->id);
|
||||
Succeeded::message('Teilnehmer*in bearbeitet.')->dispatch();
|
||||
return response()->json([]);
|
||||
}
|
||||
|
|
|
@ -60,12 +60,14 @@ class ParticipantResource extends JsonResource
|
|||
|
||||
return [
|
||||
'filter' => ParticipantFilterScope::fromRequest(request()->input('filter', ''))->setForm($form),
|
||||
'form_config' => $form->config,
|
||||
'default_filter_value' => ParticipantFilterScope::$nan,
|
||||
'filters' => $filterData,
|
||||
'form_meta' => $form->meta,
|
||||
'has_nami_field' => $form->getFields()->hasNamiField(),
|
||||
'links' => [
|
||||
'update_form_meta' => route('form.update-meta', ['form' => $form]),
|
||||
'store_participant' => route('form.participant.store', ['form' => $form]),
|
||||
],
|
||||
'columns' => $fieldData->push([
|
||||
'name' => 'Registriert am',
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
<template>
|
||||
<ui-popup v-if="visible === true" heading="Filtern" @close="visible = false">
|
||||
<div class="grid gap-3 md:grid-cols-2">
|
||||
<slot></slot>
|
||||
<slot name="fields"></slot>
|
||||
</div>
|
||||
</ui-popup>
|
||||
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleDesktop">
|
||||
<slot></slot>
|
||||
<div class="px-6 py-2 border-b border-gray-600" :class="visibleDesktopBlock">
|
||||
<div class="flex items-end space-x-3">
|
||||
<slot name="buttons"></slot>
|
||||
<ui-icon-button v-if="filterable" icon="filter" @click="filterVisible = !filterVisible">Filtern</ui-icon-button>
|
||||
</div>
|
||||
<ui-box v-if="filterVisible" class="mt-3">
|
||||
<div class="grid grid-cols-4 gap-3 items-end">
|
||||
<slot name="fields"></slot>
|
||||
<ui-icon-button class="col-start-1" icon="close" @click="filterVisible = false">Schließen</ui-icon-button>
|
||||
</div>
|
||||
</ui-box>
|
||||
</div>
|
||||
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleMobile">
|
||||
<ui-icon-button icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3">
|
||||
<slot name="buttons"></slot>
|
||||
<ui-icon-button v-if="filterable" icon="filter" @click="visible = true">Filtern</ui-icon-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -18,12 +30,18 @@ import useBreakpoints from '../../composables/useBreakpoints.js';
|
|||
|
||||
const visible = ref(false);
|
||||
|
||||
const filterVisible = ref(false);
|
||||
|
||||
const props = defineProps({
|
||||
breakpoint: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
filterable: {
|
||||
type: Boolean,
|
||||
default: () => true,
|
||||
},
|
||||
});
|
||||
|
||||
const {visibleDesktop, visibleMobile} = useBreakpoints(props);
|
||||
const {visibleDesktopBlock, visibleMobile} = useBreakpoints(props);
|
||||
</script>
|
||||
|
|
|
@ -19,8 +19,28 @@ export default function (props) {
|
|||
}[props.breakpoint];
|
||||
});
|
||||
|
||||
const visibleMobileBlock = computed(() => {
|
||||
return {
|
||||
sm: 'block sm:hidden',
|
||||
md: 'block md:hidden',
|
||||
lg: 'block lg:hidden',
|
||||
xl: 'block xl:hidden',
|
||||
}[props.breakpoint];
|
||||
});
|
||||
|
||||
const visibleDesktopBlock = computed(() => {
|
||||
return {
|
||||
sm: 'hidden sm:block',
|
||||
md: 'hidden md:block',
|
||||
lg: 'hidden lg:block',
|
||||
xl: 'hidden xl:block',
|
||||
}[props.breakpoint];
|
||||
});
|
||||
|
||||
return {
|
||||
visibleMobile,
|
||||
visibleDesktop,
|
||||
visibleDesktopBlock,
|
||||
visibleMobileBlock,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -140,10 +140,12 @@
|
|||
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
|
||||
</ui-popup>
|
||||
|
||||
<page-filter breakpoint="xl">
|
||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
||||
<f-switch id="inactive" :model-value="getFilter('inactive')" label="inaktive zeigen" name="inactive" size="sm" @update:model-value="setFilter('inactive', $event)"></f-switch>
|
||||
<page-filter breakpoint="xl" :filterable="false">
|
||||
<template #buttons>
|
||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" name="past" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
|
||||
<f-switch id="inactive" :model-value="getFilter('inactive')" label="inaktive zeigen" name="inactive" size="sm" @update:model-value="setFilter('inactive', $event)"></f-switch>
|
||||
</template>
|
||||
</page-filter>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<div class="mt-5">
|
||||
<div>
|
||||
<ui-popup v-if="editing !== null" heading="Mitglied bearbeiten" closeable full @close="editing = null">
|
||||
<event-form
|
||||
:value="editingPreviewString"
|
||||
:value="editing.preview"
|
||||
:base-url="meta.base_url"
|
||||
style="--primary: hsl(181, 75%, 26%); --secondary: hsl(181, 75%, 35%); --font: hsl(181, 84%, 78%); --circle: hsl(181, 86%, 16%)"
|
||||
as-form
|
||||
|
@ -22,43 +22,48 @@
|
|||
</div>
|
||||
</ui-popup>
|
||||
<page-filter breakpoint="lg">
|
||||
<f-switch v-if="meta.has_nami_field" id="group_participants" v-model="groupParticipants" label="Gruppieren" size="sm" name="group_participants"></f-switch>
|
||||
<f-multipleselect id="active_columns" v-model="activeColumnsConfig" :options="meta.columns" label="Aktive Spalten" size="sm"></f-multipleselect>
|
||||
<template #buttons>
|
||||
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
||||
<f-switch v-if="meta.has_nami_field" id="group_participants" v-model="groupParticipants" label="Gruppieren" size="sm" name="group_participants"></f-switch>
|
||||
<f-multipleselect id="active_columns" v-model="activeColumnsConfig" :options="meta.columns" label="Aktive Spalten" size="sm"></f-multipleselect>
|
||||
</template>
|
||||
|
||||
<template v-for="(filter, index) in meta.filters">
|
||||
<f-select
|
||||
v-if="filter.base_type === 'CheckboxField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="checkboxFilterOptions"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
<f-select
|
||||
v-if="filter.base_type === 'DropdownField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="dropdownFilterOptions(filter)"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
<f-select
|
||||
v-if="filter.base_type === 'RadioField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="dropdownFilterOptions(filter)"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
<template #fields>
|
||||
<template v-for="(filter, index) in meta.filters">
|
||||
<f-select
|
||||
v-if="filter.base_type === 'CheckboxField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="checkboxFilterOptions"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
<f-select
|
||||
v-if="filter.base_type === 'DropdownField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="dropdownFilterOptions(filter)"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
<f-select
|
||||
v-if="filter.base_type === 'RadioField'"
|
||||
:id="`filter-field-${index}`"
|
||||
:key="`filter-field-${index}`"
|
||||
v-model="innerFilter.data[filter.key]"
|
||||
:null-value="meta.default_filter_value"
|
||||
:name="`filter-field-${index}`"
|
||||
:options="dropdownFilterOptions(filter)"
|
||||
:label="filter.name"
|
||||
size="sm"
|
||||
></f-select>
|
||||
</template>
|
||||
</template>
|
||||
</page-filter>
|
||||
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
|
||||
|
@ -216,12 +221,16 @@ async function editReal(participant) {
|
|||
const response = await axios.get(participant.links.fields);
|
||||
editing.value = {
|
||||
participant: participant,
|
||||
config: response.data.data.config,
|
||||
preview: JSON.stringify(response.data.data.config),
|
||||
};
|
||||
}
|
||||
|
||||
async function updateParticipant(payload) {
|
||||
await axios.patch(editing.value.participant.links.update, {data: payload});
|
||||
if (editing.value.participant === null) {
|
||||
await axios.post(meta.value.links.store_participant, payload);
|
||||
} else {
|
||||
await axios.patch(editing.value.participant.links.update, payload);
|
||||
}
|
||||
|
||||
await reload();
|
||||
|
||||
|
@ -229,5 +238,4 @@ async function updateParticipant(payload) {
|
|||
}
|
||||
|
||||
const editing = ref(null);
|
||||
const editingPreviewString = computed(() => editing.value === null ? '' : JSON.stringify(editing.value.config));
|
||||
</script>
|
||||
|
|
|
@ -72,15 +72,17 @@
|
|||
</section>
|
||||
</form>
|
||||
</ui-popup>
|
||||
<page-filter breakpoint="xl">
|
||||
<f-multipleselect
|
||||
id="statuses"
|
||||
:options="meta.statuses"
|
||||
:model-value="getFilter('statuses')"
|
||||
label="Status"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('statuses', $event)"
|
||||
></f-multipleselect>
|
||||
<page-filter breakpoint="xl" :filterable="false">
|
||||
<template #buttons>
|
||||
<f-multipleselect
|
||||
id="statuses"
|
||||
:options="meta.statuses"
|
||||
:model-value="getFilter('statuses')"
|
||||
label="Status"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('statuses', $event)"
|
||||
></f-multipleselect>
|
||||
</template>
|
||||
</page-filter>
|
||||
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
|
||||
<thead>
|
||||
|
|
|
@ -39,34 +39,38 @@
|
|||
</button>
|
||||
</ui-popup>
|
||||
<page-filter breakpoint="xl">
|
||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||
<f-switch v-show="hasModule('bill')" id="ausstand" :model-value="getFilter('ausstand')" label="Nur Ausstände" size="sm" @update:model-value="setFilter('ausstand', $event)"></f-switch>
|
||||
<f-multipleselect
|
||||
id="group_ids"
|
||||
:options="meta.groups"
|
||||
:model-value="getFilter('group_ids')"
|
||||
label="Gruppierungen"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('group_ids', $event)"
|
||||
></f-multipleselect>
|
||||
<f-select
|
||||
v-show="hasModule('bill')"
|
||||
id="billKinds"
|
||||
name="billKinds"
|
||||
:options="meta.billKinds"
|
||||
:model-value="getFilter('bill_kind')"
|
||||
label="Rechnung"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('bill_kind', $event)"
|
||||
></f-select>
|
||||
<button class="btn btn-primary label mr-2" @click.prevent="membershipFilters = getFilter('memberships')">
|
||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite>
|
||||
<span class="hidden xl:inline">Mitgliedschaften</span>
|
||||
</button>
|
||||
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
||||
<span class="hidden xl:inline">Exportieren</span>
|
||||
</button>
|
||||
<template #fields>
|
||||
<f-switch v-show="hasModule('bill')" id="ausstand" :model-value="getFilter('ausstand')" label="Nur Ausstände" size="sm" @update:model-value="setFilter('ausstand', $event)"></f-switch>
|
||||
<f-multipleselect
|
||||
id="group_ids"
|
||||
:options="meta.groups"
|
||||
:model-value="getFilter('group_ids')"
|
||||
label="Gruppierungen"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('group_ids', $event)"
|
||||
></f-multipleselect>
|
||||
<f-select
|
||||
v-show="hasModule('bill')"
|
||||
id="billKinds"
|
||||
name="billKinds"
|
||||
:options="meta.billKinds"
|
||||
:model-value="getFilter('bill_kind')"
|
||||
label="Rechnung"
|
||||
size="sm"
|
||||
@update:model-value="setFilter('bill_kind', $event)"
|
||||
></f-select>
|
||||
<button class="btn btn-primary label mr-2" @click.prevent="membershipFilters = getFilter('memberships')">
|
||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite>
|
||||
<span class="hidden xl:inline">Mitgliedschaften</span>
|
||||
</button>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
|
||||
<button class="btn btn-primary label mr-2" @click.prevent="exportMembers">
|
||||
<ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
|
||||
<span class="hidden xl:inline">Exportieren</span>
|
||||
</button>
|
||||
</template>
|
||||
</page-filter>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table">
|
||||
|
|
|
@ -40,6 +40,7 @@ use App\Form\Actions\ParticipantAssignAction;
|
|||
use App\Form\Actions\ParticipantDestroyAction;
|
||||
use App\Form\Actions\ParticipantFieldsAction;
|
||||
use App\Form\Actions\ParticipantIndexAction;
|
||||
use App\Form\Actions\ParticipantStoreAction;
|
||||
use App\Form\Actions\ParticipantUpdateAction;
|
||||
use App\Initialize\Actions\InitializeAction;
|
||||
use App\Initialize\Actions\InitializeFormAction;
|
||||
|
@ -176,6 +177,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
|||
Route::post('/participant/{participant}/assign', ParticipantAssignAction::class)->name('participant.assign');
|
||||
Route::get('/participant/{participant}/fields', ParticipantFieldsAction::class)->name('participant.fields');
|
||||
Route::patch('/participant/{participant}', ParticipantUpdateAction::class)->name('participant.update');
|
||||
Route::post('/form/{form}/participant', ParticipantStoreAction::class)->name('form.participant.store');
|
||||
|
||||
// ------------------------------------ fileshare -----------------------------------
|
||||
Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store');
|
||||
|
|
|
@ -10,7 +10,7 @@ use App\Form\Enums\SpecialType;
|
|||
/**
|
||||
* @method self name(string $name)
|
||||
* @method self key(string $key)
|
||||
* @method self required(string|bool $key)
|
||||
* @method self required(bool $isRequired)
|
||||
* @method self rows(int $rows)
|
||||
* @method self columns(array{mobile: int, tablet: int, desktop: int} $rows)
|
||||
* @method self default(mixed $default)
|
||||
|
|
|
@ -58,7 +58,9 @@ class ParticipantIndexActionTest extends FormTestCase
|
|||
->assertJsonPath('meta.form_meta.active_columns', ['vorname', 'select', 'stufe', 'test1'])
|
||||
->assertJsonPath('meta.has_nami_field', false)
|
||||
->assertJsonPath('meta.links.update_form_meta', route('form.update-meta', ['form' => $form]))
|
||||
->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc']);
|
||||
->assertJsonPath('meta.links.store_participant', route('form.participant.store', ['form' => $form]))
|
||||
->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc'])
|
||||
->assertJsonPath('meta.form_config.sections.0.fields.0.key', 'vorname');
|
||||
}
|
||||
|
||||
public function testItShowsEmptyFilters(): void
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Form\Actions\ExportSyncAction;
|
||||
use App\Form\Models\Form;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
|
||||
class ParticipantStoreActionTest extends FormTestCase
|
||||
{
|
||||
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testItStoresParticipant(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$form = Form::factory()->fields([
|
||||
$this->textField('vorname')->name('Vorname')->required(true),
|
||||
])
|
||||
->create();
|
||||
|
||||
$this->postJson(route('form.participant.store', ['form' => $form->id]), ['vorname' => 'Jane'])
|
||||
->assertOk();
|
||||
|
||||
$this->assertEquals('Jane', $form->participants->first()->data['vorname']);
|
||||
ExportSyncAction::assertPushed();
|
||||
}
|
||||
|
||||
public function testItHasValidation(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$this->login()->loginNami();
|
||||
$form = Form::factory()->fields([
|
||||
$this->textField('vorname')->name('Vorname')->required(true),
|
||||
])
|
||||
->create();
|
||||
|
||||
$this->postJson(route('form.participant.store', ['form' => $form->id]), ['vorname' => ''])
|
||||
->assertJsonValidationErrors(['vorname' => 'Vorname ist erforderlich.']);
|
||||
}
|
||||
}
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Form\Actions\ExportSyncAction;
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
|
||||
class ParticipantUpdateActionTest extends FormTestCase
|
||||
{
|
||||
|
@ -13,19 +15,31 @@ class ParticipantUpdateActionTest extends FormTestCase
|
|||
|
||||
public function testItUpdatesParticipant(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$participant = Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B']])
|
||||
->for(Form::factory()->sections([
|
||||
FormtemplateSectionRequest::new()->name('Sektion')->fields([
|
||||
$this->textField('vorname')->name('Vorname'),
|
||||
$this->checkboxesField('select')->options(['A', 'B', 'C']),
|
||||
])
|
||||
$participant = Participant::factory()->data(['vorname' => 'Max'])
|
||||
->for(Form::factory()->fields([
|
||||
$this->textField('vorname')->name('Vorname'),
|
||||
]))
|
||||
->create();
|
||||
|
||||
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['data' => ['vorname' => 'Jane']])
|
||||
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['vorname' => 'Jane'])
|
||||
->assertOk();
|
||||
|
||||
$this->assertEquals('Jane', $participant->fresh()->data['vorname']);
|
||||
ExportSyncAction::assertPushed();
|
||||
}
|
||||
|
||||
public function testItHasValidation(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$participant = Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B']])
|
||||
->for(Form::factory()->fields([
|
||||
$this->textField('vorname')->name('Vorname')->required(true),
|
||||
]))
|
||||
->create();
|
||||
|
||||
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['vorname' => ''])
|
||||
->assertJsonValidationErrors(['vorname' => 'Vorname ist erforderlich.']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rm -R /var/www/owncloud/core/skeleton/*
|
||||
rm -R /var/www/owncloud/core/skeleton/* || true
|
||||
|
||||
true
|
||||
|
|
Loading…
Reference in New Issue