Implement settings dialog and password changes.

This commit is contained in:
2023-11-20 19:26:51 +00:00
parent 907fdb9baf
commit dfd4a15cc9
11 changed files with 228 additions and 36 deletions
+28 -14
View File
@@ -1,32 +1,46 @@
<template>
<dialog ref="dialog">
<dialog v-if="store.dialog === name" ref="dialog" :id=props.name @keydown.escape=close>
<h1 v-if="props.title">{{ props.title }}</h1>
<div>
<slot>
Dialog with no content
<button onclick="dialog.close()">OK</button>
<button @click=close>OK</button>
</slot>
</div>
</dialog>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, watchEffect, nextTick } from 'vue'
import { useMainStore } from '@/stores/main'
const dialog = ref<HTMLDialogElement | null>(null)
const store = useMainStore()
const props = withDefaults(
defineProps<{
title: string
}>(),
{
title: ''
}
)
const show = () => {
dialog.value!.showModal()
const close = () => {
dialog.value!.close()
store.dialog = ''
}
defineExpose({ show })
const props = defineProps<{
title: string,
name: typeof store.dialog,
}>()
const show = () => {
store.dialog = props.name
setTimeout(() => {
dialog.value!.showModal()
nextTick(() => {
const input = dialog.value!.querySelector('input')
if (input) input.focus()
})
}, 0)
}
defineExpose({ show, close })
watchEffect(() => {
if (dialog.value) show()
})
onMounted(() => {
show()
})