adrema/resources/js/views/activity/SubactivityForm.vue

51 lines
1.4 KiB
Vue
Raw Normal View History

2023-03-04 15:23:45 +01:00
<template>
<div>
2023-03-07 01:35:39 +01:00
<div class="flex space-x-3" v-if="model">
2023-03-04 15:23:45 +01:00
<f-text size="sm" id="name" v-model="model.name" label="Name" required></f-text>
<f-switch size="sm" v-model="model.is_filterable" name="subactivity_is_filterable" id="subactivity_is_filterable" label="Filterbar"></f-switch>
</div>
2023-05-19 01:06:46 +02:00
<ui-icon-button class="mt-3" icon="save" @click.prevent="store">Speichern</ui-icon-button>
2023-03-04 15:23:45 +01:00
</div>
</template>
<script>
export default {
data: function () {
return {
visible: false,
model: {...this.value},
};
},
props: {
value: {
required: true,
},
},
methods: {
async store() {
try {
2023-03-07 01:35:39 +01:00
if (this.model.id) {
var response = await this.axios.patch(this.model.links.update, this.model);
this.$emit('updated', response.data);
} else {
var response = await this.axios.post('/subactivity', this.model);
this.$emit('stored', response.data);
}
2023-03-04 15:23:45 +01:00
} catch (e) {
this.errorsFromException(e);
}
},
},
2023-03-07 01:35:39 +01:00
async created() {
if (this.value.id) {
var payload = (await this.axios.get(this.value.links.show)).data;
this.model = payload.data;
} else {
this.model = this.value;
}
},
2023-03-04 15:23:45 +01:00
};
</script>