Creating a generic UI error handling mechanism

This commit is contained in:
Bruno Alves de Faria committed 2018-02-27 07:12:23 -03:00
1 parent 3c1e4c51cd
commit 798b197d4a
13 files changed
+81 -9

No files matched your search

@@ -4,9 +4,23 @@
{{#form class=(concat 'modal-content ' this.formClass) hideValidationBox=true
api=(extend instance.api instance.data.api) schema=this.schema
}}
{{>dialogHeader this}}
{{#if or this.title (hasSection 'dialogHeader')}}
{{>dialogHeader this}}
{{/if}}
<div class="modal-body">
{{this.bodyText}}
<div class="messages">
{{#each message in this.messages}}
<div class="message">{{{message}}}</div>
{{else}}
{{#if isError}}
{{>pageError (extend this error=this.details)}}
{{else}}
{{#let message=(choose this.bodyText this.reason this.message 'An error has ocurred.')}}
<div class="message">{{message}}</div>
{{/let}}
{{/if}}
{{/each}}
</div>
{{>UI.contentBlock}}
</div>
<div class="modal-footer">
@@ -105,3 +105,10 @@ Template.dialogForm.events({
}
}
});
Template.dialogForm.helpers({
isError() {
const data = Template.instance().data;
return data instanceof Error || (data && data.error instanceof Error);
}
});
@@ -1,7 +1,7 @@
<template name="dialogHeader">
<div class="modal-header">
{{>section 'dialogHeader'}}
{{#if this.title}}
{{#if or this.title (hasSection 'dialogHeader')}}
{{#button class='close' action='cancel'
tagAttributes=(extend this.tagAttributes
data-dismiss='modal' aria-label='Close'
@@ -6,7 +6,7 @@
{{#each message in this.messages}}
<div class="message">{{{message}}}</div>
{{else}}
{{#if eq this.errorType 'Meteor.Error'}}
{{#if isError}}
{{>pageError (extend this error=this.details)}}
{{else}}
{{#let message=(choose this.reason this.message 'An error has ocurred.')}}
@@ -7,3 +7,10 @@ Template.dialogInfo.onRendered(() => {
$modal.one('hidden.bs.modal', () => instance.data.promiseResolve());
});
Template.dialogInfo.helpers({
isError() {
const data = Template.instance().data;
return data instanceof Error || (data && data.error instanceof Error);
}
});