Modal dialogs (message boxes) for showing errors, information and confirmation
// valid usage
const uDialogs = require('@unitybase/adminui-vue').uDialogs
// WRONG usage
// const uDialogs = require('@unitybase/adminui-vue/utils/uDialogs')
const answer = await uDialogs.dialogDeleteRecord(entityName, item)
Methods
# dialog (options: object) → Promise.<string> inner
Show modal dialog with 3 optional button and text/html content
Return:
Promise resolved to one of 'yes', 'no' 'cancel' depending on button clicked.
If dialog is closed using Esc key or by pressing window "close" button result is cancel
Arguments:
options
: objecttitle
: stringDialog title (will be translated using UB.i18n)
msg
: stringDialog message. Text of HTML string. Will be translated using UB.i18n. Support "magic" hyperlink - see magicLinks
buttons
: objecttype
: stringType of icon. Can be any available el-icon-[type]. For example
error
will showel-icon-error
. Recommended types are:error
,info
,question
isDevInfo
: booleanIf true adds "Copy to clipboard" button
const resp = await $App.uDialogs.dialog({
title: 'scan',
msg: 'noPaperInScanner',
type: 'warning',
buttons: {yes: 'tryAgain', cancel: 'stopScan'}
})
// here `resp` is either 'yes' or 'cancel'
# dialogDeleteRecord (entity: string, instanceDataopt: object) → Promise.<boolean> inner
Shows deletion confirmation message.
# dialogError (msg: string, titleopt: string, isDevInfoopt: boolean) → Promise.<boolean> inner
Show error dialog. Title & message are translated using UB.i18n
Return:
resolved to true when user press OK button, in other case (Esc) - false
# dialogInfo (msg: string, titleopt: string) → Promise.<boolean> inner
Show information dialog. Title & message are translated using UB.i18n
Injected into Vue prototype as $dialogInfo
Return:
resolved to true then user click OK in other case - false
# dialogYesNo (title: string, msg: string) → Promise.<boolean> inner
Confirmation dialog. Title & message are translated using UB.i18n
Return:
user choice true or false
const choice = await $App.dialogYesNo('makeChangesSuccessfulTitle', 'makeChangesSuccessfulBody')
if (choice){
// do something on Yes answer
} else {
// do something on No answer
}
# errorReporter (errMsg: String, errCode, entityCode, detail: string) inner
Vue based error reported. To be used by ub-pub.setErrorReporter
# install (Vue: Vue) inner
Inject $dialog into Vue prototype. Called in adminui-vue
model initialisation.
Injects:
- $dialog
- $dialogError
- $dialogInfo
- $dialogYesNo
- $dialogDeleteRecord
- $errorReporter
Arguments:
Vue
: Vue