2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2021-11-28 12:07:37 +01:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FromSlot class="_formBlock">
|
|
|
|
<template #label>{{ $ts.reactionSettingDescription }}</template>
|
|
|
|
<div v-panel style="border-radius: 6px;">
|
2021-11-19 11:36:12 +01:00
|
|
|
<XDraggable v-model="reactions" class="zoaiodol" :item-key="item => item" animation="150" delay="100" delay-on-touch-only="true">
|
2020-12-05 04:50:09 +01:00
|
|
|
<template #item="{element}">
|
|
|
|
<button class="_button item" @click="remove(element, $event)">
|
|
|
|
<MkEmoji :emoji="element" :normal="true"/>
|
|
|
|
</button>
|
|
|
|
</template>
|
2020-11-14 06:32:01 +01:00
|
|
|
<template #footer>
|
2021-04-20 16:22:59 +02:00
|
|
|
<button class="_button add" @click="chooseEmoji"><i class="fas fa-plus"></i></button>
|
2020-11-14 06:32:01 +01:00
|
|
|
</template>
|
|
|
|
</XDraggable>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2021-11-28 12:07:37 +01:00
|
|
|
<template #caption>{{ $ts.reactionSettingDescription2 }} <button class="_textButton" @click="preview">{{ $ts.preview }}</button></template>
|
|
|
|
</FromSlot>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2021-11-28 12:07:37 +01:00
|
|
|
<FormRadios v-model="reactionPickerWidth" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.width }}</template>
|
2020-12-26 02:47:36 +01:00
|
|
|
<option :value="1">{{ $ts.small }}</option>
|
|
|
|
<option :value="2">{{ $ts.medium }}</option>
|
|
|
|
<option :value="3">{{ $ts.large }}</option>
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormRadios>
|
2021-11-28 12:07:37 +01:00
|
|
|
<FormRadios v-model="reactionPickerHeight" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.height }}</template>
|
2020-12-26 02:47:36 +01:00
|
|
|
<option :value="1">{{ $ts.small }}</option>
|
|
|
|
<option :value="2">{{ $ts.medium }}</option>
|
|
|
|
<option :value="3">{{ $ts.large }}</option>
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormRadios>
|
2021-12-17 08:14:31 +01:00
|
|
|
|
2021-12-18 06:56:15 +01:00
|
|
|
<FormSwitch v-model="reactionPickerUseDrawerForMobile" class="_formBlock">
|
|
|
|
{{ $ts.useDrawerReactionPickerForMobile }}
|
|
|
|
<template #caption>{{ $ts.needReloadToApply }}</template>
|
|
|
|
</FormSwitch>
|
2021-12-17 08:14:31 +01:00
|
|
|
|
2021-11-28 12:07:37 +01:00
|
|
|
<FormSection>
|
2021-12-17 08:14:31 +01:00
|
|
|
<div style="display: flex; gap: var(--margin); flex-wrap: wrap;">
|
|
|
|
<FormButton inline @click="preview"><i class="fas fa-eye"></i> {{ $ts.preview }}</FormButton>
|
|
|
|
<FormButton inline danger @click="setDefault"><i class="fas fa-undo"></i> {{ $ts.default }}</FormButton>
|
|
|
|
</div>
|
2021-11-28 12:07:37 +01:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { watch } from 'vue';
|
2020-12-05 04:50:09 +01:00
|
|
|
import XDraggable from 'vuedraggable';
|
2021-11-28 12:07:37 +01:00
|
|
|
import FormInput from '@/components/form/input.vue';
|
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FromSlot from '@/components/form/slot.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-12-17 08:14:31 +01:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-01-28 04:30:59 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
let reactions = $ref(JSON.parse(JSON.stringify(defaultStore.state.reactions)));
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
const reactionPickerWidth = $computed(defaultStore.makeGetterSetter('reactionPickerWidth'));
|
|
|
|
const reactionPickerHeight = $computed(defaultStore.makeGetterSetter('reactionPickerHeight'));
|
|
|
|
const reactionPickerUseDrawerForMobile = $computed(defaultStore.makeGetterSetter('reactionPickerUseDrawerForMobile'));
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
function save() {
|
|
|
|
defaultStore.set('reactions', reactions);
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
function remove(reaction, ev: MouseEvent) {
|
|
|
|
os.popupMenu([{
|
|
|
|
text: i18n.ts.remove,
|
|
|
|
action: () => {
|
|
|
|
reactions = reactions.filter(x => x !== reaction);
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
2022-01-28 04:30:59 +01:00
|
|
|
}], ev.currentTarget ?? ev.target);
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
function preview(ev: MouseEvent) {
|
|
|
|
os.popup(import('@/components/emoji-picker-dialog.vue'), {
|
|
|
|
asReactionPicker: true,
|
|
|
|
src: ev.currentTarget ?? ev.target,
|
|
|
|
}, {}, 'closed');
|
|
|
|
}
|
2020-11-14 06:32:01 +01:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
async function setDefault() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.resetAreYouSure,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
reactions = JSON.parse(JSON.stringify(defaultStore.def.reactions.default));
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
function chooseEmoji(ev: MouseEvent) {
|
|
|
|
os.pickEmoji(ev.currentTarget ?? ev.target, {
|
|
|
|
showPinned: false
|
|
|
|
}).then(emoji => {
|
|
|
|
if (!reactions.includes(emoji)) {
|
|
|
|
reactions.push(emoji);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-11-14 06:32:01 +01:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
watch($$(reactions), () => {
|
|
|
|
save();
|
|
|
|
}, {
|
|
|
|
deep: true,
|
|
|
|
});
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-28 04:30:59 +01:00
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.ts.reaction,
|
|
|
|
icon: 'fas fa-laugh',
|
|
|
|
action: {
|
|
|
|
icon: 'fas fa-eye',
|
|
|
|
handler: preview,
|
|
|
|
},
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
},
|
2020-10-17 13:12:00 +02:00
|
|
|
});
|
|
|
|
</script>
|
2020-11-14 06:32:01 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zoaiodol {
|
2021-11-28 12:07:37 +01:00
|
|
|
padding: 12px;
|
|
|
|
font-size: 1.1em;
|
2020-11-14 06:32:01 +01:00
|
|
|
|
|
|
|
> .item {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
|
|
|
cursor: move;
|
|
|
|
}
|
2020-12-05 04:50:09 +01:00
|
|
|
|
|
|
|
> .add {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
|
|
|
}
|
2020-11-14 06:32:01 +01:00
|
|
|
}
|
|
|
|
</style>
|