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