Compare commits

..

No commits in common. "d4057ff08f45c47706f0ab2750846d96a444e02b" and "98976700a9e3c4bcb4313bb09fe7c47089439f75" have entirely different histories.

15 changed files with 102 additions and 298 deletions

View File

@ -1,56 +0,0 @@
<?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([]);
}
}

View File

@ -17,38 +17,15 @@ class ParticipantUpdateAction
*/ */
public function rules(): array public function rules(): array
{ {
/** @var Participant */ return [
$participant = request()->route('participant'); 'data' => 'required',
];
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 public function handle(Participant $participant, ActionRequest $request): JsonResponse
{ {
$participant->update(['data' => [...$participant->data, ...$request->validated()]]); $participant->update(['data' => [...$participant->data, ...$request->validated('data')]]);
ExportSyncAction::dispatch($participant->form->id);
Succeeded::message('Teilnehmer*in bearbeitet.')->dispatch(); Succeeded::message('Teilnehmer*in bearbeitet.')->dispatch();
return response()->json([]); return response()->json([]);
} }

View File

@ -60,14 +60,12 @@ class ParticipantResource extends JsonResource
return [ return [
'filter' => ParticipantFilterScope::fromRequest(request()->input('filter', ''))->setForm($form), 'filter' => ParticipantFilterScope::fromRequest(request()->input('filter', ''))->setForm($form),
'form_config' => $form->config,
'default_filter_value' => ParticipantFilterScope::$nan, 'default_filter_value' => ParticipantFilterScope::$nan,
'filters' => $filterData, 'filters' => $filterData,
'form_meta' => $form->meta, 'form_meta' => $form->meta,
'has_nami_field' => $form->getFields()->hasNamiField(), 'has_nami_field' => $form->getFields()->hasNamiField(),
'links' => [ 'links' => [
'update_form_meta' => route('form.update-meta', ['form' => $form]), 'update_form_meta' => route('form.update-meta', ['form' => $form]),
'store_participant' => route('form.participant.store', ['form' => $form]),
], ],
'columns' => $fieldData->push([ 'columns' => $fieldData->push([
'name' => 'Registriert am', 'name' => 'Registriert am',

View File

@ -1,26 +1,14 @@
<template> <template>
<ui-popup v-if="visible === true" heading="Filtern" @close="visible = false"> <ui-popup v-if="visible === true" heading="Filtern" @close="visible = false">
<div class="grid gap-3 md:grid-cols-2"> <div class="grid gap-3 md:grid-cols-2">
<slot name="fields"></slot> <slot></slot>
</div> </div>
</ui-popup> </ui-popup>
<div class="px-6 py-2 border-b border-gray-600" :class="visibleDesktopBlock"> <div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleDesktop">
<div class="flex items-end space-x-3"> <slot></slot>
<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>
<div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleMobile"> <div class="px-6 py-2 border-b border-gray-600 items-center space-x-3" :class="visibleMobile">
<div class="flex flex-col sm:flex-row items-stretch sm:items-end space-y-1 sm:space-y-0 sm:space-x-3"> <ui-icon-button icon="filter" @click="visible = true">Filtern</ui-icon-button>
<slot name="buttons"></slot>
<ui-icon-button v-if="filterable" icon="filter" @click="visible = true">Filtern</ui-icon-button>
</div>
</div> </div>
</template> </template>
@ -30,18 +18,12 @@ import useBreakpoints from '../../composables/useBreakpoints.js';
const visible = ref(false); const visible = ref(false);
const filterVisible = ref(false);
const props = defineProps({ const props = defineProps({
breakpoint: { breakpoint: {
type: String, type: String,
required: true, required: true,
}, },
filterable: {
type: Boolean,
default: () => true,
},
}); });
const {visibleDesktopBlock, visibleMobile} = useBreakpoints(props); const {visibleDesktop, visibleMobile} = useBreakpoints(props);
</script> </script>

View File

@ -19,28 +19,8 @@ export default function (props) {
}[props.breakpoint]; }[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 { return {
visibleMobile, visibleMobile,
visibleDesktop, visibleDesktop,
visibleDesktopBlock,
visibleMobileBlock,
}; };
} }

View File

@ -140,12 +140,10 @@
<conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form> <conditions-form id="filesettings" :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions-form>
</ui-popup> </ui-popup>
<page-filter breakpoint="xl" :filterable="false"> <page-filter breakpoint="xl">
<template #buttons>
<f-text id="search" :model-value="getFilter('search')" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text> <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="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> <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> </page-filter>
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm"> <table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">

View File

@ -1,8 +1,8 @@
<template> <template>
<div> <div class="mt-5">
<ui-popup v-if="editing !== null" heading="Mitglied bearbeiten" closeable full @close="editing = null"> <ui-popup v-if="editing !== null" heading="Mitglied bearbeiten" closeable full @close="editing = null">
<event-form <event-form
:value="editing.preview" :value="editingPreviewString"
:base-url="meta.base_url" :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%)" style="--primary: hsl(181, 75%, 26%); --secondary: hsl(181, 75%, 35%); --font: hsl(181, 84%, 78%); --circle: hsl(181, 86%, 16%)"
as-form as-form
@ -22,13 +22,9 @@
</div> </div>
</ui-popup> </ui-popup>
<page-filter breakpoint="lg"> <page-filter breakpoint="lg">
<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-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> <f-multipleselect id="active_columns" v-model="activeColumnsConfig" :options="meta.columns" label="Aktive Spalten" size="sm"></f-multipleselect>
</template>
<template #fields>
<template v-for="(filter, index) in meta.filters"> <template v-for="(filter, index) in meta.filters">
<f-select <f-select
v-if="filter.base_type === 'CheckboxField'" v-if="filter.base_type === 'CheckboxField'"
@ -64,7 +60,6 @@
size="sm" size="sm"
></f-select> ></f-select>
</template> </template>
</template>
</page-filter> </page-filter>
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm"> <table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
<thead> <thead>
@ -221,16 +216,12 @@ async function editReal(participant) {
const response = await axios.get(participant.links.fields); const response = await axios.get(participant.links.fields);
editing.value = { editing.value = {
participant: participant, participant: participant,
preview: JSON.stringify(response.data.data.config), config: response.data.data.config,
}; };
} }
async function updateParticipant(payload) { async function updateParticipant(payload) {
if (editing.value.participant === null) { await axios.patch(editing.value.participant.links.update, {data: payload});
await axios.post(meta.value.links.store_participant, payload);
} else {
await axios.patch(editing.value.participant.links.update, payload);
}
await reload(); await reload();
@ -238,4 +229,5 @@ async function updateParticipant(payload) {
} }
const editing = ref(null); const editing = ref(null);
const editingPreviewString = computed(() => editing.value === null ? '' : JSON.stringify(editing.value.config));
</script> </script>

View File

@ -72,8 +72,7 @@
</section> </section>
</form> </form>
</ui-popup> </ui-popup>
<page-filter breakpoint="xl" :filterable="false"> <page-filter breakpoint="xl">
<template #buttons>
<f-multipleselect <f-multipleselect
id="statuses" id="statuses"
:options="meta.statuses" :options="meta.statuses"
@ -82,7 +81,6 @@
size="sm" size="sm"
@update:model-value="setFilter('statuses', $event)" @update:model-value="setFilter('statuses', $event)"
></f-multipleselect> ></f-multipleselect>
</template>
</page-filter> </page-filter>
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm"> <table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
<thead> <thead>

View File

@ -39,7 +39,7 @@
</button> </button>
</ui-popup> </ui-popup>
<page-filter breakpoint="xl"> <page-filter breakpoint="xl">
<template #fields> <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-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 <f-multipleselect
id="group_ids" id="group_ids"
@ -63,14 +63,10 @@
<ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite> <ui-sprite class="w-3 h-3 xl:mr-2" src="filter"></ui-sprite>
<span class="hidden xl:inline">Mitgliedschaften</span> <span class="hidden xl:inline">Mitgliedschaften</span>
</button> </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"> <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> <ui-sprite class="w-3 h-3 xl:mr-2" src="save"></ui-sprite>
<span class="hidden xl:inline">Exportieren</span> <span class="hidden xl:inline">Exportieren</span>
</button> </button>
</template>
</page-filter> </page-filter>
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table"> <table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table">

View File

@ -40,7 +40,6 @@ use App\Form\Actions\ParticipantAssignAction;
use App\Form\Actions\ParticipantDestroyAction; use App\Form\Actions\ParticipantDestroyAction;
use App\Form\Actions\ParticipantFieldsAction; use App\Form\Actions\ParticipantFieldsAction;
use App\Form\Actions\ParticipantIndexAction; use App\Form\Actions\ParticipantIndexAction;
use App\Form\Actions\ParticipantStoreAction;
use App\Form\Actions\ParticipantUpdateAction; use App\Form\Actions\ParticipantUpdateAction;
use App\Initialize\Actions\InitializeAction; use App\Initialize\Actions\InitializeAction;
use App\Initialize\Actions\InitializeFormAction; use App\Initialize\Actions\InitializeFormAction;
@ -177,7 +176,6 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::post('/participant/{participant}/assign', ParticipantAssignAction::class)->name('participant.assign'); Route::post('/participant/{participant}/assign', ParticipantAssignAction::class)->name('participant.assign');
Route::get('/participant/{participant}/fields', ParticipantFieldsAction::class)->name('participant.fields'); Route::get('/participant/{participant}/fields', ParticipantFieldsAction::class)->name('participant.fields');
Route::patch('/participant/{participant}', ParticipantUpdateAction::class)->name('participant.update'); Route::patch('/participant/{participant}', ParticipantUpdateAction::class)->name('participant.update');
Route::post('/form/{form}/participant', ParticipantStoreAction::class)->name('form.participant.store');
// ------------------------------------ fileshare ----------------------------------- // ------------------------------------ fileshare -----------------------------------
Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store'); Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store');

View File

@ -10,7 +10,7 @@ use App\Form\Enums\SpecialType;
/** /**
* @method self name(string $name) * @method self name(string $name)
* @method self key(string $key) * @method self key(string $key)
* @method self required(bool $isRequired) * @method self required(string|bool $key)
* @method self rows(int $rows) * @method self rows(int $rows)
* @method self columns(array{mobile: int, tablet: int, desktop: int} $rows) * @method self columns(array{mobile: int, tablet: int, desktop: int} $rows)
* @method self default(mixed $default) * @method self default(mixed $default)

View File

@ -58,9 +58,7 @@ class ParticipantIndexActionTest extends FormTestCase
->assertJsonPath('meta.form_meta.active_columns', ['vorname', 'select', 'stufe', 'test1']) ->assertJsonPath('meta.form_meta.active_columns', ['vorname', 'select', 'stufe', 'test1'])
->assertJsonPath('meta.has_nami_field', false) ->assertJsonPath('meta.has_nami_field', false)
->assertJsonPath('meta.links.update_form_meta', route('form.update-meta', ['form' => $form])) ->assertJsonPath('meta.links.update_form_meta', route('form.update-meta', ['form' => $form]))
->assertJsonPath('meta.links.store_participant', route('form.participant.store', ['form' => $form])) ->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc']);
->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc'])
->assertJsonPath('meta.form_config.sections.0.fields.0.key', 'vorname');
} }
public function testItShowsEmptyFilters(): void public function testItShowsEmptyFilters(): void

View File

@ -1,43 +0,0 @@
<?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.']);
}
}

View File

@ -2,11 +2,9 @@
namespace Tests\Feature\Form; namespace Tests\Feature\Form;
use App\Form\Actions\ExportSyncAction;
use App\Form\Models\Form; use App\Form\Models\Form;
use App\Form\Models\Participant; use App\Form\Models\Participant;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Queue;
class ParticipantUpdateActionTest extends FormTestCase class ParticipantUpdateActionTest extends FormTestCase
{ {
@ -15,31 +13,19 @@ class ParticipantUpdateActionTest extends FormTestCase
public function testItUpdatesParticipant(): void public function testItUpdatesParticipant(): void
{ {
Queue::fake();
$this->login()->loginNami()->withoutExceptionHandling(); $this->login()->loginNami()->withoutExceptionHandling();
$participant = Participant::factory()->data(['vorname' => 'Max']) $participant = Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B']])
->for(Form::factory()->fields([ ->for(Form::factory()->sections([
FormtemplateSectionRequest::new()->name('Sektion')->fields([
$this->textField('vorname')->name('Vorname'), $this->textField('vorname')->name('Vorname'),
$this->checkboxesField('select')->options(['A', 'B', 'C']),
])
])) ]))
->create(); ->create();
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['vorname' => 'Jane']) $this->patchJson(route('participant.update', ['participant' => $participant->id]), ['data' => ['vorname' => 'Jane']])
->assertOk(); ->assertOk();
$this->assertEquals('Jane', $participant->fresh()->data['vorname']); $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.']);
} }
} }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
rm -R /var/www/owncloud/core/skeleton/* || true rm -R /var/www/owncloud/core/skeleton/*
true true