2018-09-03 14:23:50 +00:00
|
|
|
<template>
|
2018-11-02 14:05:53 +00:00
|
|
|
<div>
|
|
|
|
<ui-card>
|
2018-11-03 14:57:14 +00:00
|
|
|
<div slot="title">%fa:broadcast-tower% %i18n:@announcements%</div>
|
|
|
|
<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>
|
|
|
|
<ui-button-group>
|
|
|
|
<ui-button inline @click="save">%fa:save R% %i18n:@save%</ui-button>
|
|
|
|
<ui-button inline @click="remove(i)">%fa:trash-alt R% %i18n:@remove%</ui-button>
|
|
|
|
</ui-button-group>
|
|
|
|
</section>
|
2018-11-02 14:05:53 +00:00
|
|
|
<section>
|
2018-11-03 14:57:14 +00:00
|
|
|
<ui-button @click="add">%fa:plus% %i18n:@add%</ui-button>
|
2018-11-02 14:05:53 +00:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-09-03 14:23:50 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from "vue";
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
2018-11-03 14:57:14 +00:00
|
|
|
announcements: [],
|
2018-09-03 14:23:50 +00:00
|
|
|
};
|
|
|
|
},
|
2018-11-03 14:57:14 +00:00
|
|
|
|
2018-09-03 14:23:50 +00:00
|
|
|
created() {
|
|
|
|
(this as any).os.getMeta().then(meta => {
|
2018-11-03 14:57:14 +00:00
|
|
|
this.announcements = meta.broadcasts;
|
2018-09-03 14:23:50 +00:00
|
|
|
});
|
|
|
|
},
|
2018-11-03 14:57:14 +00:00
|
|
|
|
2018-09-03 14:23:50 +00:00
|
|
|
methods: {
|
2018-11-03 14:57:14 +00:00
|
|
|
add() {
|
|
|
|
this.announcements.push({
|
|
|
|
title: '',
|
|
|
|
text: ''
|
|
|
|
});
|
|
|
|
},
|
2018-10-02 14:42:46 +00:00
|
|
|
|
2018-11-03 14:57:14 +00:00
|
|
|
remove(i) {
|
|
|
|
this.announcements = this.announcements.filter((_, j) => j !== i);
|
|
|
|
this.save();
|
|
|
|
},
|
2018-10-02 14:42:46 +00:00
|
|
|
|
2018-11-03 14:57:14 +00:00
|
|
|
save() {
|
2018-09-03 14:23:50 +00:00
|
|
|
(this as any).api('admin/update-meta', {
|
2018-11-03 14:57:14 +00:00
|
|
|
broadcasts: this.announcements
|
2018-10-02 14:42:46 +00:00
|
|
|
}).then(() => {
|
|
|
|
(this as any).os.apis.dialog({ text: `Saved` });
|
2018-11-03 14:57:14 +00:00
|
|
|
}).catch(e => {
|
2018-10-02 14:42:46 +00:00
|
|
|
(this as any).os.apis.dialog({ text: `Failed ${e}` });
|
2018-09-03 14:23:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|