Add prävention
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2022-04-28 23:20:41 +02:00
parent 6b015d501a
commit 8137d37c73
7 changed files with 255 additions and 35 deletions

7
.prettierrc Normal file
View File

@ -0,0 +1,7 @@
{
"printWidth": 120,
"singleQuote": true,
"tabWidth": 4,
"quoteProps": "consistent",
"bracketSpacing": false
}

View File

@ -34,7 +34,7 @@ class Member extends Model
use Notifiable; use Notifiable;
use HasFactory; use HasFactory;
public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id', 'confirmed_at', 'children_phone', 'efz']; public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id', 'confirmed_at', 'children_phone', 'efz', 'ps_at', 'more_ps_at', 'has_svk', 'has_vk', 'without_education_at', 'without_efz_at', 'multiply_pv', 'multiply_more_pv'];
public $dates = ['try_created_at', 'joined_at', 'birthday']; public $dates = ['try_created_at', 'joined_at', 'birthday'];
@ -48,6 +48,10 @@ class Member extends Model
'confession_id' => 'integer', 'confession_id' => 'integer',
'nami_id' => 'integer', 'nami_id' => 'integer',
'is_confirmed' => 'boolean', 'is_confirmed' => 'boolean',
'has_svk' => 'boolean',
'has_vk' => 'boolean',
'multiply_pv' => 'boolean',
'multiply_more_pv' => 'boolean',
]; ];
public function scopeSearch(Builder $q, ?string $text): Builder public function scopeSearch(Builder $q, ?string $text): Builder

View File

@ -77,7 +77,7 @@ class MemberRequest extends FormRequest
CreateJob::dispatch($member, auth()->user()); CreateJob::dispatch($member, auth()->user());
} }
if ($this->input('has_nami') && null !== $member->nami_id) { if ($this->input('has_nami') && null !== $member->nami_id) {
UpdateJob::dispatch($member, auth()->user()); UpdateJob::dispatch($member->fresh(), auth()->user());
} }
if (!$this->input('has_nami') && null !== $member->nami_id) { if (!$this->input('has_nami') && null !== $member->nami_id) {
DeleteJob::dispatch($member, auth()->user()); DeleteJob::dispatch($member, auth()->user());

View File

@ -63,6 +63,14 @@ class MemberResource extends JsonResource
'courses' => CourseResource::collection($this->whenLoaded('courses')), 'courses' => CourseResource::collection($this->whenLoaded('courses')),
'efz' => $this->efz, 'efz' => $this->efz,
'efz_link' => $this->getEfzLink(), 'efz_link' => $this->getEfzLink(),
'ps_at' => $this->ps_at,
'more_ps_at' => $this->more_ps_at,
'has_svk' => $this->has_svk,
'has_vk' => $this->has_vk,
'without_education_at' => $this->without_education_at,
'without_efz_at' => $this->without_efz_at,
'multiply_pv' => $this->multiply_pv,
'multiply_more_pv' => $this->multiply_more_pv,
]; ];
} }
} }

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('members', function (Blueprint $table) {
$table->date('ps_at')->nullable();
$table->date('more_ps_at')->nullable();
$table->date('without_education_at')->nullable();
$table->date('without_efz_at')->nullable();
$table->boolean('has_svk')->default(false);
$table->boolean('has_vk')->default(false);
$table->boolean('multiply_pv')->default(false);
$table->boolean('multiply_more_pv')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
});
}
};

View File

@ -3,10 +3,26 @@
<!-- ****************************** menu links ******************************* --> <!-- ****************************** menu links ******************************* -->
<div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between"> <div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
<div class="grid gap-1"> <div class="grid gap-1">
<a v-for="item, index in menu" :key="index" href="#" :data-cy="`menu-${item.id}`" @click.prevent="openMenu(index)" class="rounded py-1 px-3 text-gray-400" :class="index == active ? `bg-gray-600` : ''" v-text="item.title"></a> <a
v-for="(item, index) in menu"
:key="index"
href="#"
:data-cy="`menu-${item.id}`"
@click.prevent="openMenu(index)"
class="rounded py-1 px-3 text-gray-400"
:class="index == active ? `bg-gray-600` : ''"
v-text="item.title"
></a>
</div> </div>
<div> <div>
<button type="button" v-show="mode !== 'create'" @click.prevent="confirm" class="btn block w-full btn-primary">Daten bestätigen</button> <button
type="button"
v-show="mode !== 'create'"
@click.prevent="confirm"
class="btn block w-full btn-primary"
>
Daten bestätigen
</button>
<button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button> <button type="submit" class="mt-3 btn block w-full btn-primary">Speichern</button>
</div> </div>
</div> </div>
@ -23,14 +39,44 @@
<f-text id="location" v-model="inner.location" label="Ort" required></f-text> <f-text id="location" v-model="inner.location" label="Ort" required></f-text>
<f-text type="date" id="birthday" v-model="inner.birthday" label="Geburtsdatum" required></f-text> <f-text type="date" id="birthday" v-model="inner.birthday" label="Geburtsdatum" required></f-text>
<f-select :options="regions" id="region_id" v-model="inner.region_id" label="Bundesland"></f-select> <f-select :options="regions" id="region_id" v-model="inner.region_id" label="Bundesland"></f-select>
<f-select :options="countries" id="country_id" v-model="inner.country_id" label="Land" required></f-select> <f-select
<f-select :options="nationalities" id="nationality_id" v-model="inner.nationality_id" label="Staatsangehörigkeit" required></f-select> :options="countries"
<f-text class="col-span-2" id="other_country" v-model="inner.other_country" label="Andere Staatsangehörigkeit"></f-text> id="country_id"
v-model="inner.country_id"
label="Land"
required
></f-select>
<f-select
:options="nationalities"
id="nationality_id"
v-model="inner.nationality_id"
label="Staatsangehörigkeit"
required
></f-select>
<f-text
class="col-span-2"
id="other_country"
v-model="inner.other_country"
label="Andere Staatsangehörigkeit"
></f-text>
<div class="contents"> <div class="contents">
<h2 class="col-span-full font-semibold text-lg text-white">Erste Gruppierung</h2> <h2 class="col-span-full font-semibold text-lg text-white">Erste Gruppierung</h2>
<f-select :options="activities" id="first_activity_id" v-model="inner.first_activity_id" label="Erste Tätigkeit" required></f-select> <f-select
<f-select v-if="inner.first_activity_id" :options="subactivities[inner.first_activity_id]" id="first_subactivity_id" v-model="inner.first_subactivity_id" label="Erste Untertätigkeit" required></f-select> :options="activities"
id="first_activity_id"
v-model="inner.first_activity_id"
label="Erste Tätigkeit"
required
></f-select>
<f-select
v-if="inner.first_activity_id"
:options="subactivities[inner.first_activity_id]"
id="first_subactivity_id"
v-model="inner.first_subactivity_id"
label="Erste Untertätigkeit"
required
></f-select>
</div> </div>
</div> </div>
<div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'Kontakt'"> <div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'Kontakt'">
@ -43,24 +89,126 @@
<f-text id="fax" v-model="inner.fax" label="Fax"></f-text> <f-text id="fax" v-model="inner.fax" label="Fax"></f-text>
</div> </div>
<div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'System'"> <div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'System'">
<f-select :options="billKinds" id="bill_kind_id" v-model="inner.bill_kind_id" label="Rechnung versenden über"></f-select> <f-select
:options="billKinds"
id="bill_kind_id"
v-model="inner.bill_kind_id"
label="Rechnung versenden über"
></f-select>
</div>
<div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'Prävention'">
<div class="grid grid-cols-[max-content_1fr] col-span-2 gap-3">
<f-switch id="has_efz" v-model="hasEfz" label="Führungszeugnis eingesehen"></f-switch>
<div>
<f-text
v-if="inner.efz !== null"
type="date"
id="efz"
v-model="inner.efz"
label="Führungszeugnis eingesehen am"
></f-text>
</div>
<f-switch id="has_ps" v-model="hasPs" label="Hat Präventionsschulung"></f-switch>
<div>
<f-text
v-if="inner.ps_at !== null"
type="date"
id="ps_at"
v-model="inner.ps_at"
label="Präventionsschulung am"
></f-text>
</div>
<f-switch id="has_more_ps" v-model="hasMorePs" label="Hat Vertierungsschulung"></f-switch>
<div>
<f-text
v-if="inner.more_ps_at !== null"
type="date"
id="more_ps_at"
v-model="inner.more_ps_at"
label="Vertiefungsschulung am"
></f-text>
</div>
<f-switch
id="has_without_education"
v-model="hasWithoutEducation"
label="Einsatz ohne Schulung"
></f-switch>
<div>
<f-text
v-if="inner.without_education_at !== null"
type="date"
id="without_education_at"
v-model="inner.without_education_at"
label="Einsatz ohne Schulung am"
></f-text>
</div>
<f-switch id="has_without_efz" v-model="hasWithoutEfz" label="Einsatz ohne EFZ"></f-switch>
<div>
<f-text
v-if="inner.without_efz_at !== null"
type="date"
id="without_efz_at"
v-model="inner.without_efz_at"
label="Einsatz ohne EFZ am"
></f-text>
</div>
</div>
<div class="flex col-span-full space-x-3">
<f-switch id="has_svk" v-model="inner.has_svk" label="SVK unterschrieben"></f-switch>
<f-switch id="has_vk" v-model="inner.has_vk" label="Verhaltenskodex unterschrieben"></f-switch>
<f-switch
id="multiply_pv"
v-model="inner.multiply_pv"
label="Multiplikator*in Präventionsschulung"
></f-switch>
<f-switch
id="multiply_more_pv"
v-model="inner.multiply_more_pv"
label="Multiplikator*in Vertierungsschulung"
></f-switch>
</div>
</div> </div>
<div class="grid grid-cols-4 gap-3 p-4" v-if="menuTitle == 'Verwaltung'"> <div class="grid grid-cols-4 gap-3 p-4" v-if="menuTitle == 'Verwaltung'">
<f-switch id="has_nami" v-model="inner.has_nami" label="In Nami eintragen"></f-switch> <f-switch id="has_nami" v-model="inner.has_nami" label="In Nami eintragen"></f-switch>
<f-switch id="send_newspaper" v-model="inner.send_newspaper" label="Mittendrin versenden"></f-switch> <f-switch id="send_newspaper" v-model="inner.send_newspaper" label="Mittendrin versenden"></f-switch>
<f-text class="col-span-2" type="date" id="joined_at" v-model="inner.joined_at" label="Eintrittsdatum"></f-text> <f-text
<f-select class="col-span-2" :options="subscriptions" id="subscription_id" v-model="inner.subscription_id" label="Beitrag"></f-select> class="col-span-2"
<f-textarea class="col-span-2" rows="4" id="letter_address" v-model="inner.letter_address" label="Brief-Adresse"></f-textarea> type="date"
<div class="grid grid-cols-[max-content_1fr] col-span-2 gap-1"> id="joined_at"
<f-switch id="has_efz" v-model="hasEfz" label="Führungszeugnis eingesehen"></f-switch> v-model="inner.joined_at"
<f-text v-if="inner.efz !== null" type="date" id="efz" v-model="inner.efz" label="Führungszeugnis eingesehen am"></f-text> label="Eintrittsdatum"
</div> ></f-text>
<f-select
class="col-span-2"
:options="subscriptions"
id="subscription_id"
v-model="inner.subscription_id"
label="Beitrag"
></f-select>
<f-textarea
class="col-span-2"
rows="4"
id="letter_address"
v-model="inner.letter_address"
label="Brief-Adresse"
></f-textarea>
</div> </div>
</div> </div>
</form> </form>
</template> </template>
<script> <script>
function issetComputed(val) {
return {
set(v) {
this.inner[val] = v ? '' : null;
},
get() {
return this.inner[val] !== null;
},
};
}
export default { export default {
data: function () { data: function () {
return { return {
@ -69,9 +217,10 @@ export default {
menu: [ menu: [
{id: 'stammdaten', title: 'Stammdaten'}, {id: 'stammdaten', title: 'Stammdaten'},
{id: 'kontakt', title: 'Kontakt'}, {id: 'kontakt', title: 'Kontakt'},
{id: 'praevention', title: 'Prävention'},
{id: 'system', title: 'System'}, {id: 'system', title: 'System'},
{id: 'verwaltung', title: 'Verwaltung'}, {id: 'verwaltung', title: 'Verwaltung'},
] ],
}; };
}, },
@ -100,25 +249,22 @@ export default {
this.mode === 'create' this.mode === 'create'
? this.$inertia.post(`/member`, this.inner) ? this.$inertia.post(`/member`, this.inner)
: this.$inertia.patch(`/member/${this.inner.id}`, this.inner); : this.$inertia.patch(`/member/${this.inner.id}`, this.inner);
} },
}, },
computed: { computed: {
menuTitle() { menuTitle() {
return this.menu[this.active].title; return this.menu[this.active].title;
}, },
hasEfz: { hasEfz: issetComputed('efz'),
set(v) { hasPs: issetComputed('ps_at'),
this.inner.efz = v ? '' : null; hasMorePs: issetComputed('more_ps_at'),
}, hasWithoutEfz: issetComputed('without_efz_at'),
get() { hasWithoutEducation: issetComputed('without_education_at'),
return this.inner.efz !== null;
}
}
}, },
created() { created() {
this.inner = this.data; this.inner = this.data;
} },
}; };
</script> </script>

View File

@ -38,7 +38,6 @@ class UpdateTest extends TestCase
$this->fakeRequest(); $this->fakeRequest();
$response = $this $response = $this
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::'])); ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']));
Http::assertSent(fn ($request) => 'PUT' === $request->method() Http::assertSent(fn ($request) => 'PUT' === $request->method()
@ -84,9 +83,28 @@ class UpdateTest extends TestCase
$response = $this $response = $this
->from("/member/{$member->id}") ->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['efz' => '2021-02-03', 'has_nami' => true])); ->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'ps_at' => '2021-02-01',
'more_ps_at' => '2021-02-02',
'has_svk' => true,
'has_vk' => true,
'efz' => '2021-02-03',
'without_education_at' => '2021-02-04',
'without_efz_at' => '2021-02-05',
'has_nami' => true,
'multiply_pv' => true,
'multiply_more_pv' => true,
]));
$this->assertEquals('2021-02-01', $member->fresh()->ps_at);
$this->assertEquals('2021-02-02', $member->fresh()->more_ps_at);
$this->assertTrue($member->fresh()->has_svk);
$this->assertTrue($member->fresh()->has_vk);
$this->assertTrue($member->fresh()->multiply_pv);
$this->assertTrue($member->fresh()->multiply_more_pv);
$this->assertEquals('2021-02-03', $member->fresh()->efz); $this->assertEquals('2021-02-03', $member->fresh()->efz);
$this->assertEquals('2021-02-04', $member->fresh()->without_education_at);
$this->assertEquals('2021-02-05', $member->fresh()->without_efz_at);
} }
private function member(): Member private function member(): Member