Mercurial > hg > thermostat-ng > web-client
changeset 212:e1cc9561d3f5
Display error message when creating a multichart with empty name
Reviewed-by: jkang
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025074.html
author | Andrew Azores <aazores@redhat.com> |
---|---|
date | Fri, 15 Sep 2017 15:56:17 -0400 |
parents | 784310522116 |
children | c6f39f7d58e0 |
files | src/app/components/multichart/en.locale.yaml src/app/components/multichart/multichart.controller.js src/app/components/multichart/multichart.controller.spec.js |
diffstat | 3 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/components/multichart/en.locale.yaml Mon Sep 18 12:39:31 2017 -0400 +++ b/src/app/components/multichart/en.locale.yaml Fri Sep 15 15:56:17 2017 -0400 @@ -2,7 +2,7 @@ BREADCRUMB: Multicharts ERR_TITLE: Invalid chart name. - ERR_MESSAGE: Chart names may contain alphanumeric characters, underscores, and hyphens. + ERR_MESSAGE: Chart names may contain alphanumeric characters, underscores, and hyphens and must not be empty. form: NAME: Name
--- a/src/app/components/multichart/multichart.controller.js Mon Sep 18 12:39:31 2017 -0400 +++ b/src/app/components/multichart/multichart.controller.js Fri Sep 15 15:56:17 2017 -0400 @@ -40,7 +40,8 @@ createChart () { if (!this.newChartName) { - return false; + this.showErr = true; + return; } this.newChartName = this.newChartName.trim(); if (!this.isValid(this.newChartName)) { @@ -49,6 +50,10 @@ } this.showErr = false; this.svc.addChart(this.newChartName); + this.resetForm(); + } + + resetForm () { this.newChartName = ''; this.form.$setPristine(); this.form.$setUntouched();
--- a/src/app/components/multichart/multichart.controller.spec.js Mon Sep 18 12:39:31 2017 -0400 +++ b/src/app/components/multichart/multichart.controller.spec.js Fri Sep 15 15:56:17 2017 -0400 @@ -67,11 +67,11 @@ }); describe('createChart', () => { - it('should do nothing if chartName is undefined', () => { + it('should set showErr to true if newChartName is undefined', () => { svc.addChart.should.not.be.called(); ctrl.createChart(); svc.addChart.should.not.be.called(); - ctrl.showErr.should.be.false(); + ctrl.showErr.should.be.true(); }); it('should reset form and call to service on success', () => { @@ -92,7 +92,8 @@ }); it('should set showErr to false on success', () => { - ctrl.createChart('foo'); + ctrl.newChartName = 'foo'; + ctrl.createChart(); ctrl.showErr.should.be.false(); });