adrema/resources/js/views/contribution/VIndex.vue

129 lines
4.0 KiB
Vue
Raw Normal View History

2022-05-17 01:37:07 +02:00
<template>
<form action="/contribution/generate" target="_BLANK" class="max-w-2xl w-full mx-auto gap-6 grid-cols-2 grid p-6">
<f-text
id="eventName"
name="eventName"
class="col-span-2"
v-model="values.eventName"
label="Veranstaltungs-Name"
required
></f-text>
<f-text id="dateFrom" name="dateFrom" type="date" v-model="values.dateFrom" label="Datum von" required></f-text>
<f-text
id="dateUntil"
name="dateUntil"
type="date"
v-model="values.dateUntil"
label="Datum bis"
required
></f-text>
2022-05-20 01:18:11 +02:00
2022-08-23 23:49:19 +02:00
<f-text id="zipLocation" name="zipLocation" v-model="values.zipLocation" label="PLZ / Ort" required></f-text>
<f-select
id="country"
:options="countries"
name="country"
v-model="values.country"
label="Land"
required
></f-select>
<div class="border-gray-200 shadow shadow-primary-700 p-3 shadow-[0_0_4px_gray] col-span-2">
<f-text
class="col-span-2"
id="membersearch"
name="membersearch"
v-model="membersearch"
label="Suchen …"
size="sm"
ref="membersearchfield"
@keypress.enter.prevent="onSubmitFirstMemberResult"
></f-text>
<div class="mt-2 grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 col-span-2">
<f-switch
:id="`members-${member.id}`"
:key="member.id"
:label="`${member.firstname} ${member.lastname}`"
v-for="member in memberResults"
name="members[]"
:value="member.id"
v-model="values.members"
@keypress.enter.prevent="onSubmitMemberResult(member)"
></f-switch>
</div>
2022-05-20 01:18:11 +02:00
</div>
2022-05-17 01:37:07 +02:00
<button
2022-11-17 21:47:45 +01:00
v-for="(compiler, index) in compilers"
2022-05-17 01:37:07 +02:00
target="_BLANK"
type="submit"
name="type"
2022-11-17 21:47:45 +01:00
:value="compiler.class"
2022-05-17 01:37:07 +02:00
class="btn btn-primary mt-3 inline-block"
2022-11-17 21:47:45 +01:00
v-text="compiler.title"
></button>
2022-05-17 01:37:07 +02:00
</form>
</template>
<script>
export default {
data: function () {
return {
membersearch: '',
2022-05-17 01:37:07 +02:00
values: {
2022-05-20 01:18:11 +02:00
members: [],
2022-05-17 01:37:07 +02:00
event_name: '',
dateFrom: '',
dateUntil: '',
2022-08-23 23:49:19 +02:00
zipLocation: '',
country: null,
2022-05-17 01:37:07 +02:00
},
};
},
props: {
2022-08-23 23:49:19 +02:00
countries: {},
defaultCountry: {},
2022-05-20 01:18:11 +02:00
allMembers: {},
2022-11-17 21:47:45 +01:00
compilers: {},
2022-05-17 01:37:07 +02:00
},
computed: {
memberResults() {
if (this.membersearch.length === 0) {
return this.allMembers.data;
}
return this.allMembers.data.filter(
(member) =>
(member.firstname + ' ' + member.lastname)
.toLowerCase()
.indexOf(this.membersearch.toLowerCase()) !== -1
);
},
},
methods: {
onSubmitMemberResult(selected) {
if (this.values.members.find((m) => m === selected.id) !== undefined) {
this.values.members = this.values.members.filter((m) => m === selected.id);
} else {
this.values.members.push(selected.id);
}
this.membersearch = '';
this.$refs.membersearchfield.$el.querySelector('input').focus();
},
onSubmitFirstMemberResult() {
if (this.memberResults.length === 0) {
this.membersearch = '';
return;
}
this.onSubmitMemberResult(this.memberResults[0]);
},
},
2022-08-23 23:49:19 +02:00
created() {
this.values.country = this.defaultCountry;
},
2022-05-17 01:37:07 +02:00
};
</script>