2018-09-03 09:23:50 -05:00
|
|
|
<template>
|
2019-01-19 08:00:15 -06:00
|
|
|
<div>
|
2018-11-02 09:05:53 -05:00
|
|
|
<ui-card>
|
2018-11-08 12:44:35 -06:00
|
|
|
<div slot="title"><fa icon="broadcast-tower"/> {{ $t('announcements') }}</div>
|
2018-11-03 09:57:14 -05:00
|
|
|
<section v-for="(announcement, i) in announcements" class="fit-top">
|
|
|
|
<ui-input v-model="announcement.title" @change="save">
|
2018-11-08 12:44:35 -06:00
|
|
|
<span>{{ $t('title') }}</span>
|
2018-11-03 09:57:14 -05:00
|
|
|
</ui-input>
|
|
|
|
<ui-textarea v-model="announcement.text">
|
2018-11-08 12:44:35 -06:00
|
|
|
<span>{{ $t('text') }}</span>
|
2018-11-03 09:57:14 -05:00
|
|
|
</ui-textarea>
|
2018-11-22 17:01:14 -06:00
|
|
|
<ui-horizon-group class="fit-bottom">
|
2018-11-08 12:44:35 -06: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 00:23:28 -05:00
|
|
|
</ui-horizon-group>
|
2018-11-03 09:57:14 -05:00
|
|
|
</section>
|
2018-11-02 09:05:53 -05:00
|
|
|
<section>
|
2018-11-08 12:44:35 -06:00
|
|
|
<ui-button @click="add"><fa icon="plus"/> {{ $t('add') }}</ui-button>
|
2018-11-02 09:05:53 -05:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-09-03 09:23:50 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2018-11-08 12:44:35 -06:00
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../i18n';
|
2018-09-03 09:23:50 -05:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 12:44:35 -06:00
|
|
|
i18n: i18n('admin/views/announcements.vue'),
|
2018-09-03 09:23:50 -05:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-03 09:57:14 -05:00
|
|
|
announcements: [],
|
2018-09-03 09:23:50 -05:00
|
|
|
};
|
|
|
|
},
|
2018-11-03 09:57:14 -05:00
|
|
|
|
2018-09-03 09:23:50 -05:00
|
|
|
created() {
|
2018-11-08 17:13:34 -06:00
|
|
|
this.$root.getMeta().then(meta => {
|
2018-11-03 09:57:14 -05:00
|
|
|
this.announcements = meta.broadcasts;
|
2018-09-03 09:23:50 -05:00
|
|
|
});
|
|
|
|
},
|
2018-11-03 09:57:14 -05:00
|
|
|
|
2018-09-03 09:23:50 -05:00
|
|
|
methods: {
|
2018-11-03 09:57:14 -05:00
|
|
|
add() {
|
2018-11-14 14:00:30 -06:00
|
|
|
this.announcements.unshift({
|
2018-11-03 09:57:14 -05:00
|
|
|
title: '',
|
|
|
|
text: ''
|
|
|
|
});
|
|
|
|
},
|
2018-10-02 09:42:46 -05:00
|
|
|
|
2018-11-03 09:57:14 -05:00
|
|
|
remove(i) {
|
2018-12-02 00:28:52 -06:00
|
|
|
this.$root.dialog({
|
2018-11-04 19:40:01 -06:00
|
|
|
type: 'warning',
|
2018-11-08 12:44:35 -06:00
|
|
|
text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title),
|
2018-11-04 19:40:01 -06:00
|
|
|
showCancelButton: true
|
2018-12-02 05:10:53 -06:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
2018-11-04 19:40:01 -06:00
|
|
|
this.announcements = this.announcements.filter((_, j) => j !== i);
|
|
|
|
this.save(true);
|
2018-12-02 00:28:52 -06:00
|
|
|
this.$root.dialog({
|
2018-11-04 19:40:01 -06:00
|
|
|
type: 'success',
|
2018-11-08 12:44:35 -06:00
|
|
|
text: this.$t('_remove.removed')
|
2018-11-04 19:40:01 -06:00
|
|
|
});
|
|
|
|
});
|
2018-11-03 09:57:14 -05:00
|
|
|
},
|
2018-10-02 09:42:46 -05:00
|
|
|
|
2018-11-04 19:40:01 -06:00
|
|
|
save(silent) {
|
2018-11-08 17:13:34 -06:00
|
|
|
this.$root.api('admin/update-meta', {
|
2018-11-03 09:57:14 -05:00
|
|
|
broadcasts: this.announcements
|
2018-10-02 09:42:46 -05:00
|
|
|
}).then(() => {
|
2018-11-04 19:40:01 -06:00
|
|
|
if (!silent) {
|
2018-12-02 00:28:52 -06:00
|
|
|
this.$root.dialog({
|
2018-11-04 19:40:01 -06:00
|
|
|
type: 'success',
|
2018-11-08 12:44:35 -06:00
|
|
|
text: this.$t('saved')
|
2018-11-04 19:40:01 -06:00
|
|
|
});
|
|
|
|
}
|
2018-11-03 09:57:14 -05:00
|
|
|
}).catch(e => {
|
2018-12-02 00:28:52 -06:00
|
|
|
this.$root.dialog({
|
2018-11-04 19:32:45 -06:00
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-09-03 09:23:50 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|