-
-
+
|
@@ -104,10 +112,13 @@
import {watch, ref, computed} from 'vue';
import {useApiIndex} from '../../composables/useApiIndex.js';
import useTableToggle from '../../composables/useTableToggle.js';
+import MemberAssign from './MemberAssign.vue';
const deleting = ref(null);
const {isOpen, toggle, childrenOf, clearToggle} = useTableToggle({});
+const assigning = ref(null);
+
const props = defineProps({
url: {
type: String,
@@ -137,6 +148,12 @@ const groupParticipants = computed({
},
});
+async function assign(memberId) {
+ await axios.post(assigning.value.links.assign, {member_id: memberId});
+ reload();
+ assigning.value = null;
+}
+
var {meta, data, reload, reloadPage, axios, remove, toFilterString, url, updateUrl} = useApiIndex(props.hasNamiField ? props.rootUrl : props.url, 'participant');
const activeColumns = computed(() => meta.value.columns.filter((c) => meta.value.form_meta.active_columns.includes(c.id)));
diff --git a/routes/web.php b/routes/web.php
index 7c074007..d5d36ebf 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -36,6 +36,7 @@ use App\Form\Actions\FormtemplateUpdateAction;
use App\Form\Actions\FormUpdateAction;
use App\Form\Actions\FormUpdateMetaAction;
use App\Form\Actions\IsDirtyAction;
+use App\Form\Actions\ParticipantAssignAction;
use App\Form\Actions\ParticipantDestroyAction;
use App\Form\Actions\ParticipantIndexAction;
use App\Initialize\Actions\InitializeAction;
@@ -170,6 +171,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::get('/form/{form}/participants/{parent?}', ParticipantIndexAction::class)->name('form.participant.index');
Route::post('/form/{form}/is-dirty', IsDirtyAction::class)->name('form.is-dirty');
Route::delete('/participant/{participant}', ParticipantDestroyAction::class)->name('participant.destroy');
+ Route::post('/participant/{participant}/assign', ParticipantAssignAction::class)->name('participant.assign');
// ------------------------------------ fileshare -----------------------------------
Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store');
diff --git a/tests/Feature/Form/ParticipantAssignActionTest.php b/tests/Feature/Form/ParticipantAssignActionTest.php
new file mode 100644
index 00000000..5e127e2a
--- /dev/null
+++ b/tests/Feature/Form/ParticipantAssignActionTest.php
@@ -0,0 +1,26 @@
+login()->loginNami();
+ $participant = Participant::factory()->for(Form::factory())->create();
+ $member = Member::factory()->defaults()->create();
+
+ $this->postJson(route('participant.assign', ['participant' => $participant]), ['member_id' => $member->id])->assertOk();
+
+ $this->assertEquals($member->id, $participant->fresh()->member_id);
+ }
+}
diff --git a/tests/Feature/Form/ParticipantIndexActionTest.php b/tests/Feature/Form/ParticipantIndexActionTest.php
index 77133ec1..c4948b54 100644
--- a/tests/Feature/Form/ParticipantIndexActionTest.php
+++ b/tests/Feature/Form/ParticipantIndexActionTest.php
@@ -20,7 +20,7 @@ class ParticipantIndexActionTest extends FormTestCase
$this->login()->loginNami()->withoutExceptionHandling();
$group = Group::factory()->innerName('Stamm')->create();
$form = Form::factory()
- ->has(Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B'], 'stufe' => 'Pfadfinder', 'test1' => '', 'test2' => '', 'test3' => '', 'birthday' => '1991-04-20', 'bezirk' => $group->id]))
+ ->has(Participant::factory()->state(['member_id' => 55])->data(['vorname' => 'Max', 'select' => ['A', 'B'], 'stufe' => 'Pfadfinder', 'test1' => '', 'test2' => '', 'test3' => '', 'birthday' => '1991-04-20', 'bezirk' => $group->id]))
->fields([
$this->textField('vorname')->name('Vorname'),
$this->checkboxesField('select')->options(['A', 'B', 'C']),
@@ -40,12 +40,14 @@ class ParticipantIndexActionTest extends FormTestCase
->assertJsonPath('data.0.vorname_display', 'Max')
->assertJsonPath('data.0.stufe', 'Pfadfinder')
->assertJsonPath('data.0.bezirk', $group->id)
+ ->assertJsonPath('data.0.member_id', 55)
->assertJsonPath('data.0.bezirk_display', 'Stamm')
->assertJsonPath('data.0.birthday_display', '20.04.1991')
->assertJsonPath('data.0.birthday', '1991-04-20')
->assertJsonPath('data.0.select', ['A', 'B'])
->assertJsonPath('data.0.select_display', 'A, B')
->assertJsonPath('data.0.links.destroy', route('participant.destroy', ['participant' => $form->participants->first()]))
+ ->assertJsonPath('data.0.links.assign', route('participant.assign', ['participant' => $form->participants->first()]))
->assertJsonPath('meta.columns.0.name', 'Vorname')
->assertJsonPath('meta.columns.0.base_type', class_basename(TextField::class))
->assertJsonPath('meta.columns.0.id', 'vorname')
|