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-11-28 12:07:37 +01:00
|
|
|
<FormSection>
|
|
|
|
<FormButton @click="preview"><i class="fas fa-eye"></i> {{ $ts.preview }}</FormButton>
|
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
|
|
|
<FormButton danger @click="setDefault"><i class="fas fa-undo"></i> {{ $ts.default }}</FormButton>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } 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-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 13:31:34 +01:00
|
|
|
FormInput,
|
|
|
|
FormButton,
|
2021-11-28 12:07:37 +01:00
|
|
|
FromSlot,
|
2020-11-25 13:31:34 +01:00
|
|
|
FormRadios,
|
2021-11-28 12:07:37 +01:00
|
|
|
FormSection,
|
2020-12-05 04:50:09 +01:00
|
|
|
XDraggable,
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 02:47:36 +01:00
|
|
|
title: this.$ts.reaction,
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-laugh',
|
2020-11-25 13:31:34 +01:00
|
|
|
action: {
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-eye',
|
2020-11-25 13:31:34 +01:00
|
|
|
handler: this.preview
|
2021-09-29 17:50:45 +02:00
|
|
|
},
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2020-12-19 02:55:52 +01:00
|
|
|
reactions: JSON.parse(JSON.stringify(this.$store.state.reactions)),
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-12-19 02:55:52 +01:00
|
|
|
reactionPickerWidth: defaultStore.makeGetterSetter('reactionPickerWidth'),
|
|
|
|
reactionPickerHeight: defaultStore.makeGetterSetter('reactionPickerHeight'),
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
reactions: {
|
|
|
|
handler() {
|
2020-11-14 06:32:01 +01:00
|
|
|
this.save();
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-10 05:54:12 +02:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
save() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.$store.set('reactions', this.reactions);
|
2020-11-14 06:32:01 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
remove(reaction, ev) {
|
2021-08-08 05:19:10 +02:00
|
|
|
os.popupMenu([{
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.remove,
|
2020-11-14 06:32:01 +01:00
|
|
|
action: () => {
|
|
|
|
this.reactions = this.reactions.filter(x => x !== reaction)
|
|
|
|
}
|
|
|
|
}], ev.currentTarget || ev.target);
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
2020-11-03 07:22:55 +01:00
|
|
|
preview(ev) {
|
2021-11-11 18:02:25 +01:00
|
|
|
os.popup(import('@/components/emoji-picker-dialog.vue'), {
|
2020-11-18 04:09:14 +01:00
|
|
|
asReactionPicker: true,
|
2020-11-14 03:47:30 +01:00
|
|
|
src: ev.currentTarget || ev.target,
|
|
|
|
}, {}, 'closed');
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
2020-11-14 06:32:01 +01:00
|
|
|
async setDefault() {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled } = await os.confirm({
|
2020-11-14 06:32:01 +01:00
|
|
|
type: 'warning',
|
2020-12-26 02:47:36 +01:00
|
|
|
text: this.$ts.resetAreYouSure,
|
2020-11-14 06:32:01 +01:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-12-19 02:55:52 +01:00
|
|
|
this.reactions = JSON.parse(JSON.stringify(this.$store.def.reactions.default));
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
2020-11-03 07:22:55 +01:00
|
|
|
chooseEmoji(ev) {
|
2020-11-14 06:32:01 +01:00
|
|
|
os.pickEmoji(ev.currentTarget || ev.target, {
|
|
|
|
showPinned: false
|
|
|
|
}).then(emoji => {
|
|
|
|
if (!this.reactions.includes(emoji)) {
|
|
|
|
this.reactions.push(emoji);
|
|
|
|
}
|
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>
|