wip
This commit is contained in:
parent
4c55cd6756
commit
5f3f9e2f8f
|
@ -3,7 +3,7 @@
|
||||||
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
||||||
<div class="bg _modalBg" @click="onBgClick" v-if="!closing"></div>
|
<div class="bg _modalBg" @click="onBgClick" v-if="!closing"></div>
|
||||||
</transition>
|
</transition>
|
||||||
<transition :name="$store.state.device.animation ? 'dialog' : ''" appear @after-leave="$emit('closed')">
|
<transition :name="$store.state.device.animation ? 'dialog' : ''" appear @after-leave="$store.commit('removeDialog', id)">
|
||||||
<div class="main" v-if="!closing">
|
<div class="main" v-if="!closing">
|
||||||
<template v-if="type == 'signin'">
|
<template v-if="type == 'signin'">
|
||||||
<mk-signin/>
|
<mk-signin/>
|
||||||
|
@ -59,8 +59,6 @@ import MkSignin from './signin.vue';
|
||||||
import parseAcct from '../../misc/acct/parse';
|
import parseAcct from '../../misc/acct/parse';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
emits: ['done', 'closed'],
|
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
MkButton,
|
MkButton,
|
||||||
MkInput,
|
MkInput,
|
||||||
|
@ -69,6 +67,9 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
id: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -117,14 +118,11 @@ export default defineComponent({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
closing: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
closing: false,
|
||||||
inputValue: this.input && this.input.default ? this.input.default : null,
|
inputValue: this.input && this.input.default ? this.input.default : null,
|
||||||
userInputValue: null,
|
userInputValue: null,
|
||||||
selectedValue: this.select ? this.select.default ? this.select.default : this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
|
selectedValue: this.select ? this.select.default ? this.select.default : this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
|
||||||
|
@ -150,7 +148,7 @@ export default defineComponent({
|
||||||
|
|
||||||
if (this.autoClose) {
|
if (this.autoClose) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$emit('done');
|
this.done(false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +160,11 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
done(canceled, result?) {
|
||||||
|
this.closing = true;
|
||||||
|
this.$store.commit('dialogDone', { id: this.id, result: { canceled, result } });
|
||||||
|
},
|
||||||
|
|
||||||
async ok() {
|
async ok() {
|
||||||
if (!this.canOk) return;
|
if (!this.canOk) return;
|
||||||
if (!this.showOkButton) return;
|
if (!this.showOkButton) return;
|
||||||
|
@ -169,19 +172,19 @@ export default defineComponent({
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
const user = await this.$root.api('users/show', parseAcct(this.userInputValue));
|
const user = await this.$root.api('users/show', parseAcct(this.userInputValue));
|
||||||
if (user) {
|
if (user) {
|
||||||
this.$emit('done', { canceled: false, result: user });
|
this.done(false, user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const result =
|
const result =
|
||||||
this.input ? this.inputValue :
|
this.input ? this.inputValue :
|
||||||
this.select ? this.selectedValue :
|
this.select ? this.selectedValue :
|
||||||
true;
|
true;
|
||||||
this.$emit('done', { canceled: false, result });
|
this.done(false, result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.$emit('done', { canceled: true });
|
this.done(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onBgClick() {
|
onBgClick() {
|
||||||
|
|
|
@ -107,7 +107,7 @@ export default defineComponent({
|
||||||
.form-enter-active, .form-leave-active {
|
.form-enter-active, .form-leave-active {
|
||||||
transition: opacity 0.3s, transform 0.3s !important;
|
transition: opacity 0.3s, transform 0.3s !important;
|
||||||
}
|
}
|
||||||
.form-enter, .form-leave-to {
|
.form-enter-from, .form-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: scale(0.9);
|
transform: scale(0.9);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ export default defineComponent({
|
||||||
.form-fade-enter-active, .form-fade-leave-active {
|
.form-fade-enter-active, .form-fade-leave-active {
|
||||||
transition: opacity 0.3s !important;
|
transition: opacity 0.3s !important;
|
||||||
}
|
}
|
||||||
.form-fade-enter, .form-fade-leave-to {
|
.form-fade-enter-from, .form-fade-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
<DeckUI v-if="deckmode"/>
|
<DeckUI v-if="deckmode"/>
|
||||||
<DefaultUI v-else/>
|
<DefaultUI v-else/>
|
||||||
|
|
||||||
<XDialog v-if="dialog" v-bind="dialog" :key="dialog.id"
|
<XPostFormDialog v-if="$store.state.postForm" v-bind="$store.state.postForm"
|
||||||
@done="onDialogDone" @closed="onDialogClosed"/>
|
@done="onDialogDone" @closed="onDialogClosed"/>
|
||||||
|
|
||||||
|
<XDialog v-if="dialog" v-bind="dialog" :key="dialog.id"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -56,14 +58,6 @@ export default defineComponent({
|
||||||
api(endpoint: string, data: Record<string, any> = {}, token?) {
|
api(endpoint: string, data: Record<string, any> = {}, token?) {
|
||||||
return this.$store.dispatch('api', { endpoint, data, token });
|
return this.$store.dispatch('api', { endpoint, data, token });
|
||||||
},
|
},
|
||||||
|
|
||||||
onDialogDone(result) {
|
|
||||||
this.$store.commit('dialogDone', { id: this.dialog.id, result });
|
|
||||||
},
|
|
||||||
|
|
||||||
onDialogClosed() {
|
|
||||||
this.$store.commit('removeDialog', this.dialog.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -270,7 +270,6 @@ export const store = createStore({
|
||||||
dialogDone(state, { id: dialogId, result }) {
|
dialogDone(state, { id: dialogId, result }) {
|
||||||
const dialog = state.dialogs.find(d => d.id === dialogId);
|
const dialog = state.dialogs.find(d => d.id === dialogId);
|
||||||
dialog.result = result;
|
dialog.result = result;
|
||||||
dialog.closing = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeDialog(state, dialogId) {
|
removeDialog(state, dialogId) {
|
||||||
|
|
Loading…
Reference in New Issue