2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2021-11-28 12:07:37 +01:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FromSlot class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.reactionSettingDescription }}</template>
|
2021-11-28 12:07:37 +01:00
|
|
|
<div v-panel style="border-radius: 6px;">
|
2022-12-21 03:04:49 +01:00
|
|
|
<Sortable :list="reactions" class="zoaiodol" :item-key="item => item" :options="{ animation: 150, delay: 100, delayOnTouchOnly: true }" @end="onSorted">
|
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>
|
2022-12-19 11:01:30 +01:00
|
|
|
<button class="_button add" @click="chooseEmoji"><i class="ti ti-plus"></i></button>
|
2020-11-14 06:32:01 +01:00
|
|
|
</template>
|
2022-12-21 03:04:49 +01:00
|
|
|
</Sortable>
|
|
|
|
<!-- TODO: https://github.com/MaxLeiter/sortablejs-vue3/issues/52 が実装されたら消す -->
|
|
|
|
<button class="_button add" @click="chooseEmoji"><i class="ti ti-plus"></i></button>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #caption>{{ i18n.ts.reactionSettingDescription2 }} <button class="_textButton" @click="preview">{{ i18n.ts.preview }}</button></template>
|
2021-11-28 12:07:37 +01:00
|
|
|
</FromSlot>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
2022-02-11 05:38:47 +01:00
|
|
|
<FormRadios v-model="reactionPickerSize" class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.size }}</template>
|
|
|
|
<option :value="1">{{ i18n.ts.small }}</option>
|
|
|
|
<option :value="2">{{ i18n.ts.medium }}</option>
|
|
|
|
<option :value="3">{{ i18n.ts.large }}</option>
|
2020-11-25 13:31:34 +01:00
|
|
|
</FormRadios>
|
2022-02-11 05:38:47 +01:00
|
|
|
<FormRadios v-model="reactionPickerWidth" class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.numberOfColumn }}</template>
|
2022-02-11 05:38:47 +01:00
|
|
|
<option :value="1">5</option>
|
|
|
|
<option :value="2">6</option>
|
|
|
|
<option :value="3">7</option>
|
2022-02-11 05:53:02 +01:00
|
|
|
<option :value="4">8</option>
|
|
|
|
<option :value="5">9</option>
|
2022-02-11 05:38:47 +01:00
|
|
|
</FormRadios>
|
2021-11-28 12:07:37 +01:00
|
|
|
<FormRadios v-model="reactionPickerHeight" class="_formBlock">
|
2022-07-20 15:24:26 +02:00
|
|
|
<template #label>{{ i18n.ts.height }}</template>
|
|
|
|
<option :value="1">{{ i18n.ts.small }}</option>
|
|
|
|
<option :value="2">{{ i18n.ts.medium }}</option>
|
|
|
|
<option :value="3">{{ i18n.ts.large }}</option>
|
|
|
|
<option :value="4">{{ i18n.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">
|
2022-07-20 15:24:26 +02:00
|
|
|
{{ i18n.ts.useDrawerReactionPickerForMobile }}
|
|
|
|
<template #caption>{{ i18n.ts.needReloadToApply }}</template>
|
2021-12-18 06:56:15 +01:00
|
|
|
</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;">
|
2022-12-19 11:01:30 +01:00
|
|
|
<FormButton inline @click="preview"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</FormButton>
|
2022-12-20 00:35:49 +01:00
|
|
|
<FormButton inline danger @click="setDefault"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</FormButton>
|
2021-12-17 08:14:31 +01:00
|
|
|
</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>
|
2022-05-01 15:51:07 +02:00
|
|
|
import { defineAsyncComponent, watch } from 'vue';
|
2022-12-21 03:04:49 +01:00
|
|
|
import { Sortable } from 'sortablejs-vue3';
|
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';
|
2022-09-06 11:21:49 +02:00
|
|
|
import FormButton from '@/components/MkButton.vue';
|
2021-11-28 12:07:37 +01:00
|
|
|
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';
|
2022-01-28 04:30:59 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-11-17 01:31:07 +01:00
|
|
|
import { deepClone } from '@/scripts/clone';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-11-17 01:31:07 +01:00
|
|
|
let reactions = $ref(deepClone(defaultStore.state.reactions));
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-02-11 05:38:47 +01:00
|
|
|
const reactionPickerSize = $computed(defaultStore.makeGetterSetter('reactionPickerSize'));
|
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-12-21 03:04:49 +01:00
|
|
|
function onSorted(event) {
|
|
|
|
const item = reactions.splice(event.oldIndex, 1)[0];
|
|
|
|
reactions.splice(event.newIndex, 0, item);
|
|
|
|
}
|
|
|
|
|
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);
|
2022-06-20 10:38:49 +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) {
|
2022-08-30 17:24:33 +02:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
2022-01-28 04:30:59 +01:00
|
|
|
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-11-17 01:31:07 +01:00
|
|
|
reactions = deepClone(defaultStore.def.reactions.default);
|
2022-01-28 04:30:59 +01:00
|
|
|
}
|
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, {
|
2022-06-20 10:38:49 +02:00
|
|
|
showPinned: false,
|
2022-01-28 04:30:59 +01:00
|
|
|
}).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-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.reaction,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-mood-happy',
|
2022-06-20 10:38:49 +02:00
|
|
|
action: {
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-eye',
|
2022-06-20 10:38:49 +02:00
|
|
|
handler: preview,
|
2022-01-28 04:30:59 +01:00
|
|
|
},
|
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>
|