2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2020-11-25 13:31:34 +01:00
|
|
|
<FormBase>
|
|
|
|
<div class="_formItem">
|
|
|
|
<div class="_formLabel">{{ $t('reactionSettingDescription') }}</div>
|
|
|
|
<div class="_formPanel">
|
2020-12-05 04:50:09 +01:00
|
|
|
<XDraggable class="zoaiodol" v-model="reactions" :item-key="item => item" animation="150" delay="100" delay-on-touch-only="true">
|
|
|
|
<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>
|
2020-12-05 04:50:09 +01:00
|
|
|
<button class="_button add" @click="chooseEmoji"><Fa :icon="faPlus"/></button>
|
2020-11-14 06:32:01 +01:00
|
|
|
</template>
|
|
|
|
</XDraggable>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2020-12-05 04:50:09 +01:00
|
|
|
<div class="_formCaption">{{ $t('reactionSettingDescription2') }} <button class="_textButton" @click="preview">{{ $t('preview') }}</button></div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2020-11-25 13:31:34 +01:00
|
|
|
|
|
|
|
<FormRadios v-model="reactionPickerWidth">
|
|
|
|
<template #desc>{{ $t('width') }}</template>
|
|
|
|
<option :value="1">{{ $t('small') }}</option>
|
|
|
|
<option :value="2">{{ $t('medium') }}</option>
|
|
|
|
<option :value="3">{{ $t('large') }}</option>
|
|
|
|
</FormRadios>
|
|
|
|
<FormRadios v-model="reactionPickerHeight">
|
|
|
|
<template #desc>{{ $t('height') }}</template>
|
|
|
|
<option :value="1">{{ $t('small') }}</option>
|
|
|
|
<option :value="2">{{ $t('medium') }}</option>
|
|
|
|
<option :value="3">{{ $t('large') }}</option>
|
|
|
|
</FormRadios>
|
|
|
|
<FormButton @click="preview"><Fa :icon="faEye"/> {{ $t('preview') }}</FormButton>
|
|
|
|
<FormButton danger @click="setDefault"><Fa :icon="faUndo"/> {{ $t('default') }}</FormButton>
|
|
|
|
</FormBase>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faLaugh, faSave, faEye } from '@fortawesome/free-regular-svg-icons';
|
2020-12-05 04:50:09 +01:00
|
|
|
import { faUndo, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import XDraggable from 'vuedraggable';
|
2020-11-25 13:31:34 +01:00
|
|
|
import FormInput from '@/components/form/input.vue';
|
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
|
|
|
import FormBase from '@/components/form/base.vue';
|
|
|
|
import FormButton from '@/components/form/button.vue';
|
2020-10-17 13:12:00 +02:00
|
|
|
import * as os from '@/os';
|
2020-12-19 02:55:52 +01:00
|
|
|
import { defaultStore } from '@/store';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 13:31:34 +01:00
|
|
|
FormInput,
|
|
|
|
FormButton,
|
|
|
|
FormBase,
|
|
|
|
FormRadios,
|
2020-12-05 04:50:09 +01:00
|
|
|
XDraggable,
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 12:36:12 +01:00
|
|
|
title: this.$t('reaction'),
|
2020-11-25 13:31:34 +01:00
|
|
|
icon: faLaugh,
|
|
|
|
action: {
|
|
|
|
icon: faEye,
|
|
|
|
handler: this.preview
|
|
|
|
}
|
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-12-05 04:50:09 +01:00
|
|
|
faLaugh, faSave, faEye, faUndo, faPlus
|
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() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
|
|
|
os.modalMenu([{
|
|
|
|
text: this.$t('remove'),
|
|
|
|
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) {
|
2020-11-14 03:47:30 +01:00
|
|
|
os.popup(import('@/components/emoji-picker.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() {
|
|
|
|
const { canceled } = await os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('resetAreYouSure'),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
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 {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .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>
|