From a66145e105e48e45e61df36904baed7d0fd948f3 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 27 Feb 2023 22:40:47 +0100 Subject: [PATCH] Add salutation field --- .prettierrc | 2 +- app/Member/Member.php | 2 +- app/Member/MemberRequest.php | 1 + app/Member/MemberResource.php | 1 + ...13656_create_members_salutation_column.php | 32 +++++++++++++++++++ resources/js/views/member/VForm.vue | 19 ++++++----- tests/Feature/Member/EditTest.php | 3 +- tests/Feature/Member/StoreTest.php | 2 ++ tests/Feature/Member/UpdateTest.php | 2 ++ 9 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2023_02_27_213656_create_members_salutation_column.php diff --git a/.prettierrc b/.prettierrc index a833d36d..0bbb9468 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,5 @@ { - "printWidth": 120, + "printWidth": 200, "singleQuote": true, "tabWidth": 4, "quoteProps": "consistent", diff --git a/app/Member/Member.php b/app/Member/Member.php index 49bf9bed..d71c18d8 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -49,7 +49,7 @@ class Member extends Model /** * @var array */ - public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug', 'search']; + public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug']; /** * @var array diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 77f12131..408bb355 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -78,6 +78,7 @@ class MemberRequest extends FormRequest 'children_phone' => '', 'fax' => '', 'other_country' => '', + 'salutation' => '', ]; } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 2617e9ae..5bdc5a26 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -89,6 +89,7 @@ class MemberResource extends JsonResource 'age' => $this->getModel()->getAge(), 'is_leader' => $this->leaderMemberships->count() > 0, 'group_id' => $this->group_id, + 'salutation' => $this->salutation, 'links' => [ 'show' => route('member.show', ['member' => $this->getModel()]), ], diff --git a/database/migrations/2023_02_27_213656_create_members_salutation_column.php b/database/migrations/2023_02_27_213656_create_members_salutation_column.php new file mode 100644 index 00000000..f4d3e07b --- /dev/null +++ b/database/migrations/2023_02_27_213656_create_members_salutation_column.php @@ -0,0 +1,32 @@ +string('salutation')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('members', function (Blueprint $table) { + $table->dropColumn('salutation'); + }); + } +}; diff --git a/resources/js/views/member/VForm.vue b/resources/js/views/member/VForm.vue index ccf4e5d1..d3b7012a 100644 --- a/resources/js/views/member/VForm.vue +++ b/resources/js/views/member/VForm.vue @@ -21,14 +21,17 @@
- +
+ + +
withoutExceptionHandling(); $this->login()->loginNami(); - $member = Member::factory()->defaults()->create(['firstname' => 'Max']); + $member = Member::factory()->defaults()->create(['salutation' => 'Doktor', 'firstname' => 'Max']); $activity = Activity::factory()->inNami(66)->hasAttached(Subactivity::factory()->inNami(56)->name('Biber'))->name('€ Mitglied')->create(); $subactivity = $activity->subactivities->first(); @@ -25,6 +25,7 @@ class EditTest extends TestCase $this->assertInertiaHas('Biber', $response, "subactivities.{$activity->id}.{$subactivity->id}"); $this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}"); $this->assertInertiaHas('Max', $response, 'data.firstname'); + $this->assertInertiaHas('Doktor', $response, 'data.salutation'); $this->assertInertiaHas('edit', $response, 'mode'); $this->assertInertiaHas(false, $response, 'conflict'); $this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'billKinds.0'); diff --git a/tests/Feature/Member/StoreTest.php b/tests/Feature/Member/StoreTest.php index 345b2a20..39a3aaf8 100644 --- a/tests/Feature/Member/StoreTest.php +++ b/tests/Feature/Member/StoreTest.php @@ -45,6 +45,7 @@ class StoreTest extends TestCase 'first_subactivity_id' => $subactivity->id, 'subscription_id' => $subscription->id, 'bill_kind' => 'Post', + 'salutation' => 'Doktor', ])); $response->assertRedirect('/member')->assertSessionHasNoErrors(); @@ -70,6 +71,7 @@ class StoreTest extends TestCase 'subscription_id' => $subscription->id, 'zip' => '42719', 'fax' => '+49 666', + 'salutation' => 'Doktor', ]); NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member) && $activityParam->is($activity) diff --git a/tests/Feature/Member/UpdateTest.php b/tests/Feature/Member/UpdateTest.php index 674b4113..08ca4dbf 100644 --- a/tests/Feature/Member/UpdateTest.php +++ b/tests/Feature/Member/UpdateTest.php @@ -87,6 +87,7 @@ class UpdateTest extends TestCase 'has_nami' => false, 'multiply_pv' => true, 'multiply_more_pv' => true, + 'salutation' => 'Doktor', ])); $this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d')); @@ -98,6 +99,7 @@ class UpdateTest extends TestCase $this->assertEquals('2021-02-03', $member->fresh()->efz->format('Y-m-d')); $this->assertEquals('2021-02-04', $member->fresh()->without_education_at->format('Y-m-d')); $this->assertEquals('2021-02-05', $member->fresh()->without_efz_at->format('Y-m-d')); + $this->assertEquals('Doktor', $member->fresh()->salutation); } /**