2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<XModalWindow
|
|
|
|
ref="dialog"
|
|
|
|
:width="370"
|
|
|
|
:with-ok-button="true"
|
|
|
|
@close="$refs.dialog.close()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
@ok="ok()"
|
|
|
|
>
|
|
|
|
<template #header>:{{ emoji.name }}:</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="_monolithic_">
|
|
|
|
<div class="yigymqpb _section">
|
|
|
|
<img :src="emoji.url" class="img" />
|
|
|
|
<MkInput v-model="name" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput
|
|
|
|
v-model="category"
|
|
|
|
class="_formBlock"
|
|
|
|
:datalist="categories"
|
|
|
|
>
|
|
|
|
<template #label>{{ i18n.ts.category }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="aliases" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.ts.tags }}</template>
|
|
|
|
<template #caption>{{
|
|
|
|
i18n.ts.setMultipleBySeparatingWithSpace
|
|
|
|
}}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkTextarea v-model="license" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.ts.license }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
<MkButton danger @click="del()"
|
|
|
|
><i class="ph-trash ph-bold ph-lg"></i>
|
|
|
|
{{ i18n.ts.delete }}</MkButton
|
|
|
|
>
|
|
|
|
</div>
|
2021-04-21 05:06:02 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</XModalWindow>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import {} from "vue";
|
|
|
|
import XModalWindow from "@/components/MkModalWindow.vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import MkInput from "@/components/form/input.vue";
|
|
|
|
import MkTextarea from "@/components/form/textarea.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { unique } from "@/scripts/array";
|
|
|
|
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<{
|
2023-04-08 02:01:42 +02:00
|
|
|
emoji: any;
|
2022-05-15 15:20:01 +02:00
|
|
|
}>();
|
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);
|
2023-04-08 02:01:42 +02:00
|
|
|
let aliases: string = $ref(props.emoji.aliases.join(" "));
|
2022-05-15 15:20:01 +02:00
|
|
|
let categories: string[] = $ref(emojiCategories);
|
2023-04-08 02:01:42 +02:00
|
|
|
let license: string = $ref(props.emoji.license ?? "");
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-15 15:20:01 +02:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "done", v: { deleted?: boolean; updated?: any }): void;
|
|
|
|
(ev: "closed"): void;
|
2022-05-15 15:20:01 +02:00
|
|
|
}>();
|
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() {
|
2023-04-08 02:01:42 +02:00
|
|
|
await os.apiWithDialog("admin/emoji/update", {
|
2022-05-15 15:20:01 +02:00
|
|
|
id: props.emoji.id,
|
|
|
|
name,
|
|
|
|
category,
|
2023-04-08 02:01:42 +02:00
|
|
|
aliases: aliases.split(" "),
|
|
|
|
license: license === "" ? null : license,
|
2022-05-15 15:20:01 +02:00
|
|
|
});
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("done", {
|
2022-05-15 15:20:01 +02:00
|
|
|
updated: {
|
|
|
|
id: props.emoji.id,
|
|
|
|
name,
|
|
|
|
category,
|
2023-04-08 02:01:42 +02:00
|
|
|
aliases: aliases.split(" "),
|
|
|
|
license: license === "" ? null : license,
|
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({
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "warning",
|
|
|
|
text: i18n.t("removeAreYouSure", { x: name }),
|
2022-05-15 15:20:01 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-04-08 02:01:42 +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(() => {
|
2023-04-08 02:01:42 +02:00
|
|
|
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>
|