2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2022-07-20 15:24:26 +02:00
|
|
|
<XModalWindow
|
|
|
|
ref="dialog"
|
2020-10-17 13:12:00 +02:00
|
|
|
:width="370"
|
|
|
|
:with-ok-button="true"
|
|
|
|
@close="$refs.dialog.close()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
@ok="ok()"
|
|
|
|
>
|
|
|
|
<template #header>:{{ emoji.name }}:</template>
|
|
|
|
|
2021-04-21 05:06:02 +02:00
|
|
|
<div class="_monolithic_">
|
|
|
|
<div class="yigymqpb _section">
|
|
|
|
<img :src="emoji.url" class="img"/>
|
2021-11-19 11:36:12 +01:00
|
|
|
<MkInput v-model="name" class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
2021-08-06 15:29:19 +02:00
|
|
|
</MkInput>
|
2021-11-19 11:36:12 +01:00
|
|
|
<MkInput v-model="category" class="_formBlock" :datalist="categories">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.category }}</template>
|
2021-08-06 15:29:19 +02:00
|
|
|
</MkInput>
|
2021-11-19 11:36:12 +01:00
|
|
|
<MkInput v-model="aliases" class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.tags }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.setMultipleBySeparatingWithSpace }}</template>
|
2021-04-21 05:06:02 +02:00
|
|
|
</MkInput>
|
2022-07-20 15:24:26 +02:00
|
|
|
<MkButton danger @click="del()"><i class="fas fa-trash-alt"></i> {{ i18n.ts.delete }}</MkButton>
|
2021-04-21 05:06:02 +02:00
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
|
|
|
</XModalWindow>
|
|
|
|
</template>
|
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import XModalWindow from '@/components/ui/modal-window.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { unique } from '@/scripts/array';
|
2022-05-15 15:20:01 +02:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { emojiCategories } from '@/instance';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
emoji: any,
|
|
|
|
}>();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
let dialog = $ref(null);
|
|
|
|
let name: string = $ref(props.emoji.name);
|
|
|
|
let category: string = $ref(props.emoji.category);
|
|
|
|
let aliases: string = $ref(props.emoji.aliases.join(' '));
|
|
|
|
let categories: string[] = $ref(emojiCategories);
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'done', v: { deleted?: boolean, updated?: any }): void,
|
|
|
|
(ev: 'closed'): void
|
|
|
|
}>();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
function ok() {
|
|
|
|
update();
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
async function update() {
|
|
|
|
await os.apiWithDialog('admin/emoji/update', {
|
|
|
|
id: props.emoji.id,
|
|
|
|
name,
|
|
|
|
category,
|
|
|
|
aliases: aliases.split(' '),
|
|
|
|
});
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
emit('done', {
|
|
|
|
updated: {
|
|
|
|
id: props.emoji.id,
|
|
|
|
name,
|
|
|
|
category,
|
|
|
|
aliases: aliases.split(' '),
|
2022-07-20 15:24:26 +02:00
|
|
|
},
|
2022-05-15 15:20:01 +02:00
|
|
|
});
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
dialog.close();
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
async function del() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('removeAreYouSure', { x: name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
os.api('admin/emoji/delete', {
|
2022-07-20 15:24:26 +02:00
|
|
|
id: props.emoji.id,
|
2022-05-15 15:20:01 +02:00
|
|
|
}).then(() => {
|
|
|
|
emit('done', {
|
2022-07-20 15:24:26 +02:00
|
|
|
deleted: true,
|
2022-05-15 15:20:01 +02:00
|
|
|
});
|
|
|
|
dialog.close();
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.yigymqpb {
|
|
|
|
> .img {
|
|
|
|
display: block;
|
|
|
|
height: 64px;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|