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

88 lines
3.0 KiB
Vue
Raw Normal View History

2021-11-19 22:58:27 +01:00
<template>
<div class="sidebar flex flex-col">
<sidebar-header :links="indexLinks" @close="$emit('close')" @create="mode = 'create'; single = {}" title="Ausbildungen"></sidebar-header>
<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>
<f-select id="course_id" :options="courses" v-model="single.course_id" label="Baustein" required></f-select>
<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>
<table v-else class="custom-table custom-table-light custom-table-sm text-sm flex-grow">
<thead>
<th>Baustein</th>
<th>Veranstaltung</th>
<th>Veranstalter</th>
<th>Datum</th>
<th></th>
</thead>
<tr v-for="course, index in value.courses">
<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">
<a href="#" @click.prevent="single = course; mode = 'edit'" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></a>
2022-01-02 12:50:25 +01:00
<Link href="#" @click.prevent="remove(course)" class="inline-flex btn btn-danger btn-sm"><sprite src="trash"></sprite></Link>
2021-11-19 22:58:27 +01:00
</td>
</tr>
</table>
</div>
</template>
<script>
import SidebarHeader from '../../components/SidebarHeader.vue';
export default {
data: function() {
return {
mode: null,
single: null,
indexLinks: [
{event: 'create', label: 'Neuer Kurs'}
]
};
},
props: {
2021-11-20 01:43:20 +01:00
courses: {},
2021-11-19 22:58:27 +01:00
value: {}
},
components: { SidebarHeader },
methods: {
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;
this.mode === 'create'
2021-11-20 01:43:20 +01:00
? this.$inertia.post(`/member/${this.value.id}/course`, this.single, {
2021-11-19 22:58:27 +01: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, {
2021-11-19 22:58:27 +01:00
onFinish() {
_self.single = null;
}
});
}
}
};
</script>