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