adrema/resources/js/views/member/MemberCourses.vue

104 lines
3.7 KiB
Vue
Raw Normal View History

2021-11-19 22:58:27 +01:00
<template>
2023-05-20 01:45:43 +02:00
<div class="sidebar flex flex-col group is-bright">
<page-header :links="indexLinks" @close="$emit('close')" title="Ausbildungen">
2023-05-20 01:12:53 +02:00
<div class="flex" slot="toolbar">
<page-toolbar-button @click.prevent="create" color="primary" icon="plus" v-if="single === null">Neue Ausbildung</page-toolbar-button>
<page-toolbar-button @click.prevent="cancel" color="primary" icon="undo" v-if="single !== null">Zurück</page-toolbar-button>
</div>
2023-05-20 01:45:43 +02:00
</page-header>
2021-11-19 22:58:27 +01:00
<form v-if="single" class="p-6 grid gap-4 justify-start" @submit.prevent="submit">
2021-11-20 01:43:20 +01:00
<f-text id="completed_at" type="date" v-model="single.completed_at" label="Datum" required></f-text>
2023-05-20 01:12:53 +02:00
<f-select id="course_id" name="course_id" :options="courses" v-model="single.course_id" label="Baustein" required></f-select>
2021-11-20 01:43:20 +01:00
<f-text id="event_name" v-model="single.event_name" label="Veranstaltung" required></f-text>
<f-text id="organizer" v-model="single.organizer" label="Veranstalter" required></f-text>
2021-11-19 22:58:27 +01:00
<button type="submit" class="btn btn-primary">Absenden</button>
</form>
2022-02-10 02:18:57 +01:00
<div class="grow" v-else>
<table class="custom-table custom-table-light custom-table-sm text-sm grow">
<thead>
<th>Baustein</th>
<th>Veranstaltung</th>
<th>Veranstalter</th>
<th>Datum</th>
<th></th>
</thead>
2021-11-19 22:58:27 +01:00
2022-08-23 23:49:19 +02:00
<tr v-for="(course, index) in value.courses" :key="index">
2022-02-10 02:18:57 +01:00
<td v-text="course.course_name"></td>
<td v-text="course.event_name"></td>
<td v-text="course.organizer"></td>
<td v-text="course.completed_at_human"></td>
<td class="flex">
2022-08-23 23:49:19 +02:00
<a
href="#"
@click.prevent="
single = course;
mode = 'edit';
"
class="inline-flex btn btn-warning btn-sm"
><svg-sprite src="pencil"></svg-sprite
></a>
2023-05-20 01:12:53 +02:00
<i-link href="#" @click.prevent="remove(course)" class="inline-flex btn btn-danger btn-sm"><svg-sprite src="trash"></svg-sprite></i-link>
2022-02-10 02:18:57 +01:00
</td>
</tr>
</table>
</div>
2021-11-19 22:58:27 +01:00
</div>
</template>
<script>
export default {
2022-08-23 23:49:19 +02:00
data: function () {
2021-11-19 22:58:27 +01:00
return {
mode: null,
single: null,
2022-08-23 23:49:19 +02:00
indexLinks: [{event: 'create', label: 'Neuer Kurs'}],
2021-11-19 22:58:27 +01:00
};
},
props: {
2021-11-20 01:43:20 +01:00
courses: {},
2022-08-23 23:49:19 +02:00
value: {},
2021-11-19 22:58:27 +01:00
},
methods: {
2023-05-20 01:12:53 +02:00
create() {
this.mode = 'create';
this.single = {};
},
cancel() {
this.mode = this.single = null;
},
2021-11-19 22:58:27 +01:00
remove(payment) {
2021-11-20 01:43:20 +01:00
this.$inertia.delete(`/member/${this.value.id}/course/${payment.id}`);
2021-11-19 22:58:27 +01:00
},
openLink(link) {
if (link.disabled) {
return;
}
window.open(link.href);
},
submit() {
var _self = this;
2022-08-23 23:49:19 +02:00
this.mode === 'create'
2021-11-20 01:43:20 +01:00
? this.$inertia.post(`/member/${this.value.id}/course`, this.single, {
2022-08-23 23:49:19 +02:00
onFinish() {
_self.single = null;
},
})
2021-11-20 01:43:20 +01:00
: this.$inertia.patch(`/member/${this.value.id}/course/${this.single.id}`, this.single, {
2022-08-23 23:49:19 +02:00
onFinish() {
_self.single = null;
},
});
},
},
2021-11-19 22:58:27 +01:00
};
</script>