From a102dd0d4f9e2f54ebe65f0114ef21c52e2e581f Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Mon, 16 Nov 2020 20:33:14 -0600 Subject: [PATCH] cleanup --- package.json | 2 +- src/boilerplate-card.ts | 12 ++++++++---- src/const.ts | 2 +- src/localize/languages/en.json | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 9513bf5..7c45a54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "boilerplate-card", - "version": "1.3.0", + "version": "1.3.1", "description": "Lovelace boilerplate-card", "keywords": [ "home-assistant", diff --git a/src/boilerplate-card.ts b/src/boilerplate-card.ts index 86497c4..626296e 100644 --- a/src/boilerplate-card.ts +++ b/src/boilerplate-card.ts @@ -59,7 +59,7 @@ export class BoilerplateCard extends LitElement { public setConfig(config: BoilerplateCardConfig): void { // TODO Check for required fields and that they are of the proper format - if (!config || config.show_error) { + if (!config) { throw new Error(localize('common.invalid_configuration')); } @@ -84,7 +84,11 @@ export class BoilerplateCard extends LitElement { protected render(): TemplateResult | void { // TODO Check for stateObj or other necessary things and render a warning if missing if (this.config.show_warning) { - return this.showWarning(localize('common.show_warning')); + return this._showWarning(localize('common.show_warning')); + } + + if (this.config.show_error) { + return this._showError(localize('common.show_error')); } return html` @@ -107,13 +111,13 @@ export class BoilerplateCard extends LitElement { } } - private showWarning(warning: string): TemplateResult { + private _showWarning(warning: string): TemplateResult { return html` ${warning} `; } - private showError(error: string): TemplateResult { + private _showError(error: string): TemplateResult { const errorCard = document.createElement('hui-error-card'); errorCard.setConfig({ type: 'error', diff --git a/src/const.ts b/src/const.ts index a9321f1..2e8ce47 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1 +1 @@ -export const CARD_VERSION = '1.3.0'; +export const CARD_VERSION = '1.3.1'; diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index edfac26..e5a4b4d 100644 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -2,6 +2,7 @@ "common": { "version": "Version", "invalid_configuration": "Invalid configuration", - "show_warning": "Show Warning" + "show_warning": "Show Warning", + "show_error": "Show Error" } } \ No newline at end of file