2018-09-03 16:23:50 +02:00
|
|
|
<template>
|
2018-11-04 07:16:05 +01:00
|
|
|
<div class="cdeuzmsthagexbkpofbmatmugjuvogfb">
|
2018-11-02 15:05:53 +01:00
|
|
|
<ui-card>
|
2018-11-08 19:44:35 +01:00
|
|
|
<div slot="title"><fa icon="broadcast-tower"/> {{ $t('announcements') }}</div>
|
2018-11-03 15:57:14 +01:00
|
|
|
<section v-for="(announcement, i) in announcements" class="fit-top">
|
|
|
|
<ui-input v-model="announcement.title" @change="save">
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('title') }}</span>
|
2018-11-03 15:57:14 +01:00
|
|
|
</ui-input>
|
|
|
|
<ui-textarea v-model="announcement.text">
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('text') }}</span>
|
2018-11-03 15:57:14 +01:00
|
|
|
</ui-textarea>
|
2018-11-04 06:23:28 +01:00
|
|
|
<ui-horizon-group>
|
2018-11-08 19:44:35 +01:00
|
|
|
<ui-button @click="save()"><fa :icon="['far', 'save']"/> {{ $t('save') }}</ui-button>
|
|
|
|
<ui-button @click="remove(i)"><fa :icon="['far', 'trash-alt']"/> {{ $t('remove') }}</ui-button>
|
2018-11-04 06:23:28 +01:00
|
|
|
</ui-horizon-group>
|
2018-11-03 15:57:14 +01:00
|
|
|
</section>
|
2018-11-02 15:05:53 +01:00
|
|
|
<section>
|
2018-11-08 19:44:35 +01:00
|
|
|
<ui-button @click="add"><fa icon="plus"/> {{ $t('add') }}</ui-button>
|
2018-11-02 15:05:53 +01:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-09-03 16:23:50 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2018-11-08 19:44:35 +01:00
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../i18n';
|
2018-09-03 16:23:50 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('admin/views/announcements.vue'),
|
2018-09-03 16:23:50 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-03 15:57:14 +01:00
|
|
|
announcements: [],
|
2018-09-03 16:23:50 +02:00
|
|
|
};
|
|
|
|
},
|
2018-11-03 15:57:14 +01:00
|
|
|
|
2018-09-03 16:23:50 +02:00
|
|
|
created() {
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.getMeta().then(meta => {
|
2018-11-03 15:57:14 +01:00
|
|
|
this.announcements = meta.broadcasts;
|
2018-09-03 16:23:50 +02:00
|
|
|
});
|
|
|
|
},
|
2018-11-03 15:57:14 +01:00
|
|
|
|
2018-09-03 16:23:50 +02:00
|
|
|
methods: {
|
2018-11-03 15:57:14 +01:00
|
|
|
add() {
|
|
|
|
this.announcements.push({
|
|
|
|
title: '',
|
|
|
|
text: ''
|
|
|
|
});
|
|
|
|
},
|
2018-10-02 16:42:46 +02:00
|
|
|
|
2018-11-03 15:57:14 +01:00
|
|
|
remove(i) {
|
2018-11-05 02:40:01 +01:00
|
|
|
this.$swal({
|
|
|
|
type: 'warning',
|
2018-11-08 19:44:35 +01:00
|
|
|
text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title),
|
2018-11-05 02:40:01 +01:00
|
|
|
showCancelButton: true
|
|
|
|
}).then(res => {
|
|
|
|
if (!res.value) return;
|
|
|
|
this.announcements = this.announcements.filter((_, j) => j !== i);
|
|
|
|
this.save(true);
|
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
2018-11-08 19:44:35 +01:00
|
|
|
text: this.$t('_remove.removed')
|
2018-11-05 02:40:01 +01:00
|
|
|
});
|
|
|
|
});
|
2018-11-03 15:57:14 +01:00
|
|
|
},
|
2018-10-02 16:42:46 +02:00
|
|
|
|
2018-11-05 02:40:01 +01:00
|
|
|
save(silent) {
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.api('admin/update-meta', {
|
2018-11-03 15:57:14 +01:00
|
|
|
broadcasts: this.announcements
|
2018-10-02 16:42:46 +02:00
|
|
|
}).then(() => {
|
2018-11-05 02:40:01 +01:00
|
|
|
if (!silent) {
|
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
2018-11-08 19:44:35 +01:00
|
|
|
text: this.$t('saved')
|
2018-11-05 02:40:01 +01:00
|
|
|
});
|
|
|
|
}
|
2018-11-03 15:57:14 +01:00
|
|
|
}).catch(e => {
|
2018-11-05 02:32:45 +01:00
|
|
|
this.$swal({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-09-03 16:23:50 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2018-11-04 07:16:05 +01:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.cdeuzmsthagexbkpofbmatmugjuvogfb
|
|
|
|
@media (min-width 500px)
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
</style>
|