fix: converted dialog.js to dialog.jsx
This commit is contained in:
parent
eb78de8f47
commit
50eaf854e0
@ -1,31 +0,0 @@
|
||||
import { Dialog, ErrorMessage } from 'frappe-ui'
|
||||
import { h, reactive, ref } from 'vue'
|
||||
|
||||
let dialogs = ref([])
|
||||
|
||||
export let Dialogs = {
|
||||
name: 'Dialogs',
|
||||
render() {
|
||||
return dialogs.value.map((dialog) => {
|
||||
return h(
|
||||
Dialog,
|
||||
{
|
||||
options: dialog,
|
||||
modelValue: dialog.show,
|
||||
'onUpdate:modelValue': (val) => (dialog.show = val),
|
||||
},
|
||||
() => [
|
||||
h('p', { class: 'text-p-base text-gray-700' }, dialog.message),
|
||||
h(ErrorMessage, { class: 'mt-2', message: dialog.error }),
|
||||
]
|
||||
)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export function createDialog(options) {
|
||||
let dialog = reactive(options)
|
||||
dialog.key = `dialog-${Math.random().toString(36).slice(2, 9)}`
|
||||
dialogs.value.push(dialog)
|
||||
dialog.show = true
|
||||
}
|
||||
41
frontend/src/utils/dialogs.jsx
Normal file
41
frontend/src/utils/dialogs.jsx
Normal file
@ -0,0 +1,41 @@
|
||||
import { Dialog, ErrorMessage } from 'frappe-ui'
|
||||
import { reactive, ref } from 'vue'
|
||||
|
||||
let dialogs = ref([])
|
||||
|
||||
export let Dialogs = {
|
||||
name: 'Dialogs',
|
||||
render() {
|
||||
return dialogs.value.map((dialog) => (
|
||||
<Dialog
|
||||
options={dialog}
|
||||
modelValue={dialog.show}
|
||||
onUpdate:modelValue={(val) => (dialog.show = val)}
|
||||
>
|
||||
{{
|
||||
'body-content': () => {
|
||||
return [
|
||||
dialog.message && (
|
||||
<p class="text-p-base text-gray-700">{dialog.message}</p>
|
||||
),
|
||||
dialog.html && (
|
||||
<div v-html={dialog.html} />
|
||||
),
|
||||
<ErrorMessage class="mt-2" message={dialog.error} />,
|
||||
]
|
||||
},
|
||||
}}
|
||||
</Dialog>
|
||||
))
|
||||
},
|
||||
}
|
||||
|
||||
export function createDialog(dialogOptions) {
|
||||
let dialog = reactive(dialogOptions)
|
||||
dialog.key = 'dialog-' + dialogs.value.length
|
||||
dialog.show = false
|
||||
setTimeout(() => {
|
||||
dialog.show = true
|
||||
}, 0)
|
||||
dialogs.value.push(dialog)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user