/* eslint-disable max-params */ import $ from 'jquery' import { ModalOptions } from '../shims' import { trans } from './i18n' export function showAjaxError(error: Error): void { showModal(error.message.replace(/\n/g, '
'), trans('general.fatalError'), 'danger') } export function showModal( message: string, title = 'Message', type = 'default', options: ModalOptions = {} ): void { const btnType = type === 'default' ? 'btn-primary' : 'btn-outline' const btnText = options.btnText || 'OK' const onClick = options.callback === undefined ? 'data-dismiss="modal"' : `onclick="${options.callback}"` const destroyOnClose = options.destroyOnClose !== false const dom = ` ` $(dom) .on('hidden.bs.modal', /* istanbul ignore next */ function modal() { destroyOnClose && $(this).remove() }) // @ts-ignore .modal(options) } Object.assign(blessing, { notify: { showModal } })