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 (optionsobject) → 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: object
    • titlestring

      Dialog title (will be translated using UB.i18n)

    • msgstring

      Dialog message. Text of HTML string. Will be translated using UB.i18n. Support "magic" hyperlink - see magicLinks

    • buttonsobject

    • typestring

      Type of icon. Can be any available el-icon-[type]. For example error will show el-icon-error. Recommended types are: error, info, question

    • isDevInfoboolean

      If 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 (entitystring, instanceDataoptobject) → Promise.<boolean> inner

Shows deletion confirmation message.

Arguments:
  • entity: string

    Entity code

  • instanceData: object

    Instance data needed to determine description attribute value

# dialogError (msgstring, titleoptstring, isDevInfooptboolean) → 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

Arguments:
  • msg: string
  • title = 'error': string

    title

  • isDevInfo = false: boolean

    If true adds "Copy to clipboard" button

# dialogInfo (msgstring, titleoptstring) → 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

Arguments:

# dialogYesNo (titlestring, msgstring) → Promise.<boolean> inner

Confirmation dialog. Title & message are translated using UB.i18n

Return:

user choice true or false

Arguments:
  
      const choice = await $App.dialogYesNo('makeChangesSuccessfulTitle', 'makeChangesSuccessfulBody')
if (choice){
  // do something on Yes answer
} else {
  // do something on No answer
 }
  

# errorReporter (errMsgString, errCode, entityCode, detailstring) inner

Vue based error reported. To be used by ub-pub.setErrorReporter

Arguments:

# install (VueVue) inner

Inject $dialog into Vue prototype. Called in adminui-vue model initialisation. Injects:

  • $dialog
  • $dialogError
  • $dialogInfo
  • $dialogYesNo
  • $dialogDeleteRecord
  • $errorReporter

Arguments: