2018-11-02 14:05:53 +00:00
|
|
|
<template>
|
2019-01-19 14:00:15 +00:00
|
|
|
<div>
|
2018-11-02 14:05:53 +00:00
|
|
|
<ui-card>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #title><fa icon="plus"/> {{ $t('add-emoji.title') }}</template>
|
2018-11-02 14:05:53 +00:00
|
|
|
<section class="fit-top">
|
2018-11-04 05:23:28 +00:00
|
|
|
<ui-horizon-group inputs>
|
|
|
|
<ui-input v-model="name">
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('add-emoji.name') }}</span>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #desc>{{ $t('add-emoji.name-desc') }}</template>
|
2018-11-04 05:23:28 +00:00
|
|
|
</ui-input>
|
|
|
|
<ui-input v-model="aliases">
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('add-emoji.aliases') }}</span>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #desc>{{ $t('add-emoji.aliases-desc') }}</template>
|
2018-11-04 05:23:28 +00:00
|
|
|
</ui-input>
|
|
|
|
</ui-horizon-group>
|
2018-11-02 14:05:53 +00:00
|
|
|
<ui-input v-model="url">
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #icon><fa icon="link"/></template>
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('add-emoji.url') }}</span>
|
2018-11-02 14:05:53 +00:00
|
|
|
</ui-input>
|
2018-11-08 18:44:35 +00:00
|
|
|
<ui-info>{{ $t('add-emoji.info') }}</ui-info>
|
|
|
|
<ui-button @click="add">{{ $t('add-emoji.add') }}</ui-button>
|
2018-11-02 14:05:53 +00:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-11-03 18:18:57 +00:00
|
|
|
|
|
|
|
<ui-card>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #title><fa :icon="faGrin"/> {{ $t('emojis.title') }}</template>
|
2018-12-15 07:48:28 +00:00
|
|
|
<section v-for="emoji in emojis" class="oryfrbft">
|
|
|
|
<div>
|
|
|
|
<img :src="emoji.url" :alt="emoji.name" style="width: 64px;"/>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<ui-horizon-group>
|
|
|
|
<ui-input v-model="emoji.name">
|
|
|
|
<span>{{ $t('add-emoji.name') }}</span>
|
|
|
|
</ui-input>
|
|
|
|
<ui-input v-model="emoji.aliases">
|
|
|
|
<span>{{ $t('add-emoji.aliases') }}</span>
|
|
|
|
</ui-input>
|
|
|
|
</ui-horizon-group>
|
|
|
|
<ui-input v-model="emoji.url">
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #icon><fa icon="link"/></template>
|
2018-12-15 07:48:28 +00:00
|
|
|
<span>{{ $t('add-emoji.url') }}</span>
|
2018-11-04 05:23:28 +00:00
|
|
|
</ui-input>
|
2018-12-15 07:48:28 +00:00
|
|
|
<ui-horizon-group class="fit-bottom">
|
|
|
|
<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>
|
|
|
|
</ui-horizon-group>
|
|
|
|
</div>
|
2018-11-03 18:18:57 +00:00
|
|
|
</section>
|
|
|
|
</ui-card>
|
2018-11-02 14:05:53 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2018-11-08 18:44:35 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../i18n';
|
2018-11-14 05:57:59 +00:00
|
|
|
import { faGrin } from '@fortawesome/free-regular-svg-icons';
|
2018-11-02 14:05:53 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 18:44:35 +00:00
|
|
|
i18n: i18n('admin/views/emoji.vue'),
|
2018-11-02 14:05:53 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
url: '',
|
|
|
|
aliases: '',
|
2018-11-14 05:57:59 +00:00
|
|
|
emojis: [],
|
|
|
|
faGrin
|
2018-11-02 14:05:53 +00:00
|
|
|
};
|
|
|
|
},
|
2018-11-03 18:18:57 +00:00
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.fetchEmojis();
|
|
|
|
},
|
|
|
|
|
2018-11-02 14:05:53 +00:00
|
|
|
methods: {
|
|
|
|
add() {
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api('admin/emoji/add', {
|
2018-11-02 14:05:53 +00:00
|
|
|
name: this.name,
|
|
|
|
url: this.url,
|
2018-11-05 04:23:30 +00:00
|
|
|
aliases: this.aliases.split(' ').filter(x => x.length > 0)
|
2018-11-02 14:05:53 +00:00
|
|
|
}).then(() => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'success',
|
2018-11-08 18:44:35 +00:00
|
|
|
text: this.$t('add-emoji.added')
|
2018-11-05 01:32:45 +00:00
|
|
|
});
|
2018-11-03 18:18:57 +00:00
|
|
|
this.fetchEmojis();
|
|
|
|
}).catch(e => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-11-03 18:18:57 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchEmojis() {
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api('admin/emoji/list').then(emojis => {
|
2018-11-05 01:32:45 +00:00
|
|
|
emojis.reverse();
|
2018-12-11 11:36:55 +00:00
|
|
|
for (const e of emojis) {
|
|
|
|
e.aliases = (e.aliases || []).join(' ');
|
|
|
|
}
|
2018-11-03 18:18:57 +00:00
|
|
|
this.emojis = emojis;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateEmoji(emoji) {
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api('admin/emoji/update', {
|
2018-11-03 18:18:57 +00:00
|
|
|
id: emoji.id,
|
|
|
|
name: emoji.name,
|
|
|
|
url: emoji.url,
|
2018-11-05 04:23:30 +00:00
|
|
|
aliases: emoji.aliases.split(' ').filter(x => x.length > 0)
|
2018-11-03 18:18:57 +00:00
|
|
|
}).then(() => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'success',
|
2018-11-08 18:44:35 +00:00
|
|
|
text: this.$t('updated')
|
2018-11-05 01:32:45 +00:00
|
|
|
});
|
2018-11-03 18:18:57 +00:00
|
|
|
}).catch(e => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-11-03 18:18:57 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeEmoji(emoji) {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'warning',
|
2018-11-08 18:44:35 +00:00
|
|
|
text: this.$t('remove-emoji.are-you-sure').replace('$1', emoji.name),
|
2018-11-05 01:32:45 +00:00
|
|
|
showCancelButton: true
|
2018-12-02 11:10:53 +00:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
2018-11-05 01:32:45 +00:00
|
|
|
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api('admin/emoji/remove', {
|
2018-11-05 01:32:45 +00:00
|
|
|
id: emoji.id
|
|
|
|
}).then(() => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'success',
|
2018-11-08 18:44:35 +00:00
|
|
|
text: this.$t('remove-emoji.removed')
|
2018-11-05 01:32:45 +00:00
|
|
|
});
|
|
|
|
this.fetchEmojis();
|
|
|
|
}).catch(e => {
|
2018-12-02 06:28:52 +00:00
|
|
|
this.$root.dialog({
|
2018-11-05 01:32:45 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
});
|
2018-11-02 14:05:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2018-11-04 06:16:05 +00:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2019-01-19 14:00:15 +00:00
|
|
|
.oryfrbft
|
2018-11-04 06:16:05 +00:00
|
|
|
@media (min-width 500px)
|
2019-01-19 14:00:15 +00:00
|
|
|
display flex
|
2018-11-04 06:16:05 +00:00
|
|
|
|
2019-01-19 14:00:15 +00:00
|
|
|
> div:first-child
|
|
|
|
@media (max-width 500px)
|
|
|
|
padding-bottom 16px
|
2018-12-15 07:48:28 +00:00
|
|
|
|
2019-01-19 14:00:15 +00:00
|
|
|
> img
|
|
|
|
vertical-align bottom
|
2018-12-15 07:48:28 +00:00
|
|
|
|
2019-01-19 14:00:15 +00:00
|
|
|
> div:last-child
|
|
|
|
flex 1
|
2018-12-15 07:48:28 +00:00
|
|
|
|
2019-01-19 14:00:15 +00:00
|
|
|
@media (min-width 500px)
|
|
|
|
padding-left 16px
|
2018-12-15 07:48:28 +00:00
|
|
|
|
2018-11-04 06:16:05 +00:00
|
|
|
</style>
|