2018-11-02 16:05:53 +02:00
|
|
|
<template>
|
2018-11-04 08:16:05 +02:00
|
|
|
<div class="tumhkfkmgtvzljezfvmgkeurkfncshbe">
|
2018-11-02 16:05:53 +02:00
|
|
|
<ui-card>
|
2018-11-05 18:40:11 +02:00
|
|
|
<div slot="title"><fa icon="plus"/> %i18n:@add-emoji.title%</div>
|
2018-11-02 16:05:53 +02:00
|
|
|
<section class="fit-top">
|
2018-11-04 07:23:28 +02:00
|
|
|
<ui-horizon-group inputs>
|
|
|
|
<ui-input v-model="name">
|
|
|
|
<span>%i18n:@add-emoji.name%</span>
|
2018-11-06 08:08:22 +02:00
|
|
|
<span slot="desc">%i18n:@add-emoji.name-desc%</span>
|
2018-11-04 07:23:28 +02:00
|
|
|
</ui-input>
|
|
|
|
<ui-input v-model="aliases">
|
|
|
|
<span>%i18n:@add-emoji.aliases%</span>
|
2018-11-06 08:08:22 +02:00
|
|
|
<span slot="desc">%i18n:@add-emoji.aliases-desc%</span>
|
2018-11-04 07:23:28 +02:00
|
|
|
</ui-input>
|
|
|
|
</ui-horizon-group>
|
2018-11-02 16:05:53 +02:00
|
|
|
<ui-input v-model="url">
|
2018-11-06 00:28:49 +02:00
|
|
|
<i slot="icon"><fa icon="link"/></i>
|
2018-11-02 16:05:53 +02:00
|
|
|
<span>%i18n:@add-emoji.url%</span>
|
|
|
|
</ui-input>
|
2018-11-04 18:33:06 +02:00
|
|
|
<ui-info>%i18n:@add-emoji.info%</ui-info>
|
2018-11-02 16:05:53 +02:00
|
|
|
<ui-button @click="add">%i18n:@add-emoji.add%</ui-button>
|
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-11-03 20:18:57 +02:00
|
|
|
|
|
|
|
<ui-card>
|
2018-11-05 18:40:11 +02:00
|
|
|
<div slot="title"><fa :icon="['far', 'grin']"/> %i18n:@emojis.title%</div>
|
2018-11-03 20:18:57 +02:00
|
|
|
<section v-for="emoji in emojis">
|
|
|
|
<img :src="emoji.url" :alt="emoji.name" style="width: 64px;"/>
|
2018-11-04 07:23:28 +02:00
|
|
|
<ui-horizon-group inputs>
|
|
|
|
<ui-input v-model="emoji.name">
|
|
|
|
<span>%i18n:@add-emoji.name%</span>
|
|
|
|
</ui-input>
|
|
|
|
<ui-input v-model="emoji.aliases">
|
|
|
|
<span>%i18n:@add-emoji.aliases%</span>
|
|
|
|
</ui-input>
|
|
|
|
</ui-horizon-group>
|
2018-11-03 20:18:57 +02:00
|
|
|
<ui-input v-model="emoji.url">
|
2018-11-06 00:28:49 +02:00
|
|
|
<i slot="icon"><fa icon="link"/></i>
|
2018-11-03 20:18:57 +02:00
|
|
|
<span>%i18n:@add-emoji.url%</span>
|
|
|
|
</ui-input>
|
2018-11-04 07:23:28 +02:00
|
|
|
<ui-horizon-group>
|
2018-11-05 18:40:11 +02:00
|
|
|
<ui-button @click="updateEmoji(emoji)"><fa :icon="['far', 'save']"/> %i18n:@emojis.update%</ui-button>
|
|
|
|
<ui-button @click="removeEmoji(emoji)"><fa :icon="['far', 'trash-alt']"/> %i18n:@emojis.remove%</ui-button>
|
2018-11-04 07:23:28 +02:00
|
|
|
</ui-horizon-group>
|
2018-11-03 20:18:57 +02:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-11-02 16:05:53 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from "vue";
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
url: '',
|
|
|
|
aliases: '',
|
2018-11-03 20:18:57 +02:00
|
|
|
emojis: []
|
2018-11-02 16:05:53 +02:00
|
|
|
};
|
|
|
|
},
|
2018-11-03 20:18:57 +02:00
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.fetchEmojis();
|
|
|
|
},
|
|
|
|
|
2018-11-02 16:05:53 +02:00
|
|
|
methods: {
|
|
|
|
add() {
|
2018-11-03 20:18:57 +02:00
|
|
|
(this as any).api('admin/emoji/add', {
|
2018-11-02 16:05:53 +02:00
|
|
|
name: this.name,
|
|
|
|
url: this.url,
|
2018-11-05 06:23:30 +02:00
|
|
|
aliases: this.aliases.split(' ').filter(x => x.length > 0)
|
2018-11-02 16:05:53 +02:00
|
|
|
}).then(() => {
|
2018-11-05 03:32:45 +02:00
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
|
|
|
text: '%i18n:@add-emoji.added%'
|
|
|
|
});
|
2018-11-03 20:18:57 +02:00
|
|
|
this.fetchEmojis();
|
|
|
|
}).catch(e => {
|
2018-11-05 03:32:45 +02:00
|
|
|
this.$swal({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-11-03 20:18:57 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchEmojis() {
|
|
|
|
(this as any).api('admin/emoji/list').then(emojis => {
|
2018-11-05 03:32:45 +02:00
|
|
|
emojis.reverse();
|
2018-11-03 20:18:57 +02:00
|
|
|
emojis.forEach(e => e.aliases = (e.aliases || []).join(' '));
|
|
|
|
this.emojis = emojis;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateEmoji(emoji) {
|
|
|
|
(this as any).api('admin/emoji/update', {
|
|
|
|
id: emoji.id,
|
|
|
|
name: emoji.name,
|
|
|
|
url: emoji.url,
|
2018-11-05 06:23:30 +02:00
|
|
|
aliases: emoji.aliases.split(' ').filter(x => x.length > 0)
|
2018-11-03 20:18:57 +02:00
|
|
|
}).then(() => {
|
2018-11-05 03:32:45 +02:00
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
|
|
|
text: '%i18n:@updated%'
|
|
|
|
});
|
2018-11-03 20:18:57 +02:00
|
|
|
}).catch(e => {
|
2018-11-05 03:32:45 +02:00
|
|
|
this.$swal({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-11-03 20:18:57 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeEmoji(emoji) {
|
2018-11-05 03:32:45 +02:00
|
|
|
this.$swal({
|
|
|
|
type: 'warning',
|
|
|
|
text: '%i18n:@remove-emoji.are-you-sure%'.replace('$1', emoji.name),
|
|
|
|
showCancelButton: true
|
|
|
|
}).then(res => {
|
|
|
|
if (!res.value) return;
|
|
|
|
|
|
|
|
(this as any).api('admin/emoji/remove', {
|
|
|
|
id: emoji.id
|
|
|
|
}).then(() => {
|
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
|
|
|
text: '%i18n:@remove-emoji.removed%'
|
|
|
|
});
|
|
|
|
this.fetchEmojis();
|
|
|
|
}).catch(e => {
|
|
|
|
this.$swal({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
});
|
2018-11-02 16:05:53 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2018-11-04 08:16:05 +02:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.tumhkfkmgtvzljezfvmgkeurkfncshbe
|
|
|
|
@media (min-width 500px)
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
</style>
|