updating how modals are done
This commit is contained in:
parent
2120fc8c4d
commit
e5c0eae622
@ -16,26 +16,19 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// computed properties
|
|
||||||
|
|
||||||
// watchers
|
|
||||||
|
|
||||||
// lifecycle hooks
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
function close() {
|
const close = (() {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
|
<Modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
|
||||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mx-auto shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
<div class="mx-auto shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||||
<svg class="h-6 w-6 text-red-600" stroke="currentColor" fill="none" viewBox="0 0 24 24">
|
<svg class="h-6 w-6 text-red-600" stroke="currentColor" fill="none" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -52,8 +45,7 @@ function close() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row justify-end px-6 py-4 bg-gray-100 text-right">
|
<div class="flex flex-row justify-end px-6 py-4 bg-gray-100 text-right">
|
||||||
<slot name="footer">
|
<slot name="footer"></slot>
|
||||||
</slot>
|
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
|
import DialogModal from './DialogModal.vue'
|
||||||
|
import InputElm from '@/Components/Input.vue'
|
||||||
|
import InputError from '@/Components/Input.vue'
|
||||||
|
|
||||||
const emit = defineEmits(['confirmed'])
|
const emit = defineEmits(['confirmed'])
|
||||||
|
|
||||||
@ -21,14 +24,8 @@ let form = {
|
|||||||
error: '',
|
error: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
// computed properties
|
|
||||||
|
|
||||||
// watchers
|
|
||||||
|
|
||||||
// lifecycle hooks
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
function startConfirmingPassword() {
|
const startConfirmingPassword = (() {
|
||||||
axios.get(route('password.confirmation')).then(resp => {
|
axios.get(route('password.confirmation')).then(resp => {
|
||||||
if (resp.data.confirmed) {
|
if (resp.data.confirmed) {
|
||||||
emit('confirmed')
|
emit('confirmed')
|
||||||
@ -37,10 +34,10 @@ function startConfirmingPassword() {
|
|||||||
setTimeout(() => $refs.password.focus(), 250)
|
setTimeout(() => $refs.password.focus(), 250)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
|
||||||
function confirmPassword() {
|
const confirmPassword = (() => {
|
||||||
form.processing = true;
|
form.processing = true
|
||||||
|
|
||||||
axios.post(route('password.confirm'), {
|
axios.post(route('password.confirm'), {
|
||||||
password: form.password,
|
password: form.password,
|
||||||
@ -53,49 +50,44 @@ function confirmPassword() {
|
|||||||
form.error = erro.response.data.errors.password[0]
|
form.error = erro.response.data.errors.password[0]
|
||||||
$refs.password.focus()
|
$refs.password.focus()
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
|
||||||
function closeModal() {
|
const closeModal = (() => {
|
||||||
confirmingPassword = false
|
confirmingPassword = false
|
||||||
form.password = ''
|
form.password = ''
|
||||||
form.error = ''
|
form.error = ''
|
||||||
}
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<span @click="startConfirmingPassword">
|
<span @click="startConfirmingPassword">
|
||||||
<slot />
|
<slot></slot>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<jet-dialog-modal :show="confirmingPassword" @close="closeModal">
|
<DialogModal :show="confirmingPassword" @close="closeModal">
|
||||||
<template #title>
|
<template #title>{{ title }}</template>
|
||||||
{{ title }}
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
{{ content }}
|
{{ content }}
|
||||||
|
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<jet-input type="password" class="mt-1 block w-3/4" placeholder="Password"
|
<InputElm type="password" class="mt-1 block w-3/4" placeholder="Password"
|
||||||
ref="password"
|
ref="password"
|
||||||
v-model="form.password"
|
v-model="form.password"
|
||||||
@keyup.enter="confirmPassword" />
|
@keyup.enter="confirmPassword"></InputElm>
|
||||||
|
|
||||||
<jet-input-error :message="form.error" class="mt-2" />
|
<InputError :message="form.error" class="mt-2"></InputError>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<jet-secondary-button @click="closeModal">
|
<button type="button" class="button button-gradient-secondary" @click="closeModal">Cancel</button>
|
||||||
Cancel
|
|
||||||
</jet-secondary-button>
|
|
||||||
|
|
||||||
<jet-button class="ml-3" @click="confirmPassword" :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
|
<button class="button button-gradient-primary ml-3" @click="confirmPassword" :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
|
||||||
{{ button }}
|
{{ button }}
|
||||||
</jet-button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
</jet-dialog-modal>
|
</DialogModal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -16,21 +16,14 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// computed properties
|
|
||||||
|
|
||||||
// watchers
|
|
||||||
|
|
||||||
// lifecycle hooks
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
function close() {
|
const close = (() {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
|
<Modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
|
||||||
<div class="px-6 py-4">
|
<div class="px-6 py-4">
|
||||||
<div class="text-lg">
|
<div class="text-lg">
|
||||||
<slot name="title"></slot>
|
<slot name="title"></slot>
|
||||||
@ -44,5 +37,5 @@ function close() {
|
|||||||
<div class="flex flex-row justify-end px-6 py-4 bg-gray-100 text-right">
|
<div class="flex flex-row justify-end px-6 py-4 bg-gray-100 text-right">
|
||||||
<slot name="footer"></slot>
|
<slot name="footer"></slot>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
@ -34,13 +34,6 @@ watch(() => props.show, (newShow) => {
|
|||||||
document.body.style.overflow = null
|
document.body.style.overflow = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
/*watch(props.show, (newShow) => {
|
|
||||||
if (newShow) {
|
|
||||||
document.body.style.overflow = 'hidden'
|
|
||||||
} else {
|
|
||||||
document.body.style.overflow = null
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
|
|
||||||
// lifecycle hooks
|
// lifecycle hooks
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
@ -53,18 +46,17 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
function close() {
|
const close = (() => {
|
||||||
if (props.closeable) {
|
if (props.closeable) {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
function closeOnEscape(e) {
|
const closeOnEscape = ((event) => {
|
||||||
if (e.key === 'Escape' && props.show) {
|
if (event.key === 'Escape' && props.show) {
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user