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

133 lines
4.0 KiB
Vue
Raw Normal View History

2022-05-17 01:37:07 +02:00
<template>
2023-02-26 20:51:59 +01:00
<form action="/contribution/generate" target="_BLANK" class="max-w-4xl w-full mx-auto gap-6 grid-cols-2 grid p-6">
2022-05-17 01:37:07 +02:00
<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"
2023-02-26 20:51:59 +01:00
id="search_text"
name="search_text"
v-model="searchText"
label="Suchen …"
size="sm"
2023-02-26 20:51:59 +01:00
ref="search_text_field"
@keypress.enter.prevent="onSubmitFirstMemberResult"
></f-text>
2023-02-26 20:51:59 +01:00
<div class="mt-2 grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2 col-span-2">
<f-switch
:id="`members-${member.id}`"
:key="member.id"
:label="`${member.firstname} ${member.lastname}`"
2023-02-26 20:51:59 +01:00
v-for="member in search.results"
name="members[]"
:value="member.id"
v-model="values.members"
2023-02-26 20:51:59 +01:00
size="sm"
@keypress.enter.prevent="onSubmitMemberResult(member)"
2023-02-26 20:51:59 +01:00
inline
></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>
2023-02-26 20:51:59 +01:00
import debounce from 'lodash/debounce';
2022-05-17 01:37:07 +02:00
export default {
data: function () {
return {
2023-02-26 20:51:59 +01:00
search: {
s: '',
results: [],
},
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,
2023-02-26 20:51:59 +01:00
...this.data,
2022-05-17 01:37:07 +02:00
},
};
},
props: {
2023-02-26 20:51:59 +01:00
data: {},
2022-08-23 23:49:19 +02:00
countries: {},
2022-11-17 21:47:45 +01:00
compilers: {},
2022-05-17 01:37:07 +02:00
},
computed: {
2023-02-26 20:51:59 +01:00
searchText: {
get() {
return this.search.s;
},
set: debounce(async function(event) {
this.search.s = event;
var response = await this.axios.post('/api/member/search', {search: event, minLength: 3});
2023-02-26 20:51:59 +01:00
this.search.results = response.data.data;
}, 300),
},
},
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);
}
2023-02-26 20:51:59 +01:00
this.searchText = '';
this.$refs.search_text_field.$el.querySelector('input').focus();
},
onSubmitFirstMemberResult() {
2023-02-26 20:51:59 +01:00
if (this.search.results.length === 0) {
this.searchText = '';
return;
}
2023-02-26 20:51:59 +01:00
this.onSubmitMemberResult(this.search.results[0]);
},
},
2022-08-23 23:49:19 +02:00
2022-05-17 01:37:07 +02:00
};
</script>