2023-02-25 17:19:17 +01:00
|
|
|
<template>
|
2023-04-29 23:41:26 +02:00
|
|
|
<page-layout>
|
2023-05-20 02:38:38 +02:00
|
|
|
<template #toolbar>
|
2023-05-19 01:06:46 +02:00
|
|
|
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button>
|
2023-05-20 02:38:38 +02:00
|
|
|
</template>
|
2023-04-29 23:41:26 +02:00
|
|
|
<form id="actionform" class="grow p-3" @submit.prevent="submit">
|
2023-05-19 01:06:46 +02:00
|
|
|
<ui-popup heading="Neue Untertätigkeit" v-if="mode === 'edit' && currentSubactivity !== null" @close="currentSubactivity = null">
|
2023-04-29 23:41:26 +02:00
|
|
|
<subactivity-form class="mt-4" v-if="currentSubactivity" :value="currentSubactivity" @stored="reloadSubactivities" @updated="mergeSubactivity"></subactivity-form>
|
2023-05-19 01:06:46 +02:00
|
|
|
</ui-popup>
|
2023-04-29 23:41:26 +02:00
|
|
|
<div class="flex space-x-3">
|
|
|
|
<f-text id="name" v-model="inner.name" label="Name" required></f-text>
|
|
|
|
<f-switch v-model="inner.is_filterable" name="is_filterable" id="is_filterable" label="Filterbar"></f-switch>
|
2023-03-07 01:35:39 +01:00
|
|
|
</div>
|
2023-04-29 23:41:26 +02:00
|
|
|
<div class="flex space-x-3 items-center mt-6 mb-2">
|
2023-05-19 01:06:46 +02:00
|
|
|
<f-checkboxes-label>Untertätigkeiten</f-checkboxes-label>
|
|
|
|
<ui-icon-button icon="plus" v-if="mode === 'edit'" @click.prevent="currentSubactivity = inner.subactivity_model">Neu</ui-icon-button>
|
2023-04-29 23:41:26 +02:00
|
|
|
</div>
|
|
|
|
<div class="grid gap-2 sm:grid-cols-2 md:grid-cols-4">
|
|
|
|
<div v-for="option in subactivities" class="flex items-center space-x-2">
|
|
|
|
<a href="#" @click.prevent="currentSubactivity = option" class="transition hover:bg-yellow-600 group w-5 h-5 rounded-full flex items-center justify-center flex-none">
|
|
|
|
<svg-sprite src="pencil" class="text-yellow-800 w-3 h-3 group-hover:text-yellow-200 transition"></svg-sprite>
|
|
|
|
</a>
|
|
|
|
<f-switch
|
|
|
|
inline
|
|
|
|
size="sm"
|
|
|
|
:key="option.id"
|
|
|
|
v-model="inner.subactivities"
|
|
|
|
name="subactivities[]"
|
|
|
|
:id="`subactivities-${option.id}`"
|
|
|
|
:value="option.id"
|
|
|
|
:label="option.name"
|
|
|
|
></f-switch>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-19 01:06:46 +02:00
|
|
|
<f-save-button form="actionform"></f-save-button>
|
2023-04-29 23:41:26 +02:00
|
|
|
</form>
|
|
|
|
</page-layout>
|
2023-02-25 17:19:17 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data: function () {
|
|
|
|
return {
|
2023-03-07 01:35:39 +01:00
|
|
|
currentSubactivity: null,
|
2023-03-04 12:02:17 +01:00
|
|
|
subactivities: [...this.meta.subactivities],
|
2023-02-25 17:19:17 +01:00
|
|
|
inner: {...this.data},
|
2023-02-25 18:00:23 +01:00
|
|
|
mode: this.data.name === '' ? 'create' : 'edit',
|
2023-02-25 17:19:17 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
data: {},
|
|
|
|
meta: {},
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
2023-03-04 15:23:45 +01:00
|
|
|
'subactivity-form': () => import('./SubactivityForm.vue'),
|
2023-02-25 17:19:17 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
submit() {
|
2023-03-04 12:02:17 +01:00
|
|
|
this.mode === 'create' ? this.$inertia.post('/activity', this.inner) : this.$inertia.patch(`/activity/${this.inner.id}`, this.inner);
|
2023-02-25 17:19:17 +01:00
|
|
|
},
|
|
|
|
|
2023-03-04 12:02:17 +01:00
|
|
|
reloadSubactivities(model) {
|
|
|
|
var _self = this;
|
|
|
|
|
|
|
|
this.$inertia.reload({
|
|
|
|
onSuccess(page) {
|
|
|
|
_self.subactivities = page.props.meta.subactivities;
|
|
|
|
_self.inner.subactivities.push(model.id);
|
|
|
|
_self.$success('Untertätigkeit gespeichert.');
|
2023-03-07 01:35:39 +01:00
|
|
|
_self.currentSubactivity = null;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
mergeSubactivity(model) {
|
|
|
|
var _self = this;
|
|
|
|
|
|
|
|
this.$inertia.reload({
|
|
|
|
onSuccess(page) {
|
|
|
|
_self.subactivities = page.props.meta.subactivities;
|
|
|
|
_self.inner.subactivities = _self.inner.subactivities.map((s) => (s.id === model.id ? model : s));
|
|
|
|
_self.$success('Untertätigkeit aktualisiert.');
|
|
|
|
_self.currentSubactivity = null;
|
2023-03-04 12:02:17 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
2023-02-25 17:19:17 +01:00
|
|
|
};
|
|
|
|
</script>
|