From c7778e198779e5c723ba4a73df578c42e836e501 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Tue, 30 May 2017 23:02:42 -0400 Subject: [PATCH 1/9] modifying cover to optionally have up/down and tilt controls in regular state card --- src/components/ha-cover-tilt-controls.html | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/components/ha-cover-tilt-controls.html diff --git a/src/components/ha-cover-tilt-controls.html b/src/components/ha-cover-tilt-controls.html new file mode 100644 index 000000000000..adffb4a1ebe5 --- /dev/null +++ b/src/components/ha-cover-tilt-controls.html @@ -0,0 +1,110 @@ + + + + + + + + + + + + + From e9a7258c6f9f66749bf8c6e08c5dfaf0f02c7178 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Tue, 30 May 2017 23:06:48 -0400 Subject: [PATCH 2/9] missed these --- src/more-infos/more-info-cover.html | 28 ------------------------- src/state-summary/state-card-cover.html | 6 +++++- 2 files changed, 5 insertions(+), 29 deletions(-) mode change 100755 => 100644 src/more-infos/more-info-cover.html diff --git a/src/more-infos/more-info-cover.html b/src/more-infos/more-info-cover.html old mode 100755 new mode 100644 index c4a3eff2ae3e..2ddf75cc68b2 --- a/src/more-infos/more-info-cover.html +++ b/src/more-infos/more-info-cover.html @@ -15,9 +15,6 @@ overflow: hidden; } .has-current_position .current_position, - .has-open_tilt .tilt, - .has-close_tilt .tilt, - .has-stop_tilt .tilt, .has-set_tilt_position .tilt, .has-current_tilt_position .tilt { @@ -42,17 +39,6 @@
Tilt position
- - - diff --git a/src/state-summary/state-card-cover.html b/src/state-summary/state-card-cover.html index 07f691acf5b5..df22d14d89a0 100644 --- a/src/state-summary/state-card-cover.html +++ b/src/state-summary/state-card-cover.html @@ -5,6 +5,7 @@ + From 67739e7d12dc9fbe87a8b6feabe2d2eea3cd65d4 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 10:58:50 -0400 Subject: [PATCH 3/9] linting --- src/components/ha-cover-tilt-controls.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ha-cover-tilt-controls.html b/src/components/ha-cover-tilt-controls.html index adffb4a1ebe5..fa727b821605 100644 --- a/src/components/ha-cover-tilt-controls.html +++ b/src/components/ha-cover-tilt-controls.html @@ -93,17 +93,17 @@ }, onOpenTiltTap: function (ev) { - ev.stopPropagation(); + ev.stopPropagation(); this.entityObj.openCoverTilt(); }, onCloseTiltTap: function (ev) { - ev.stopPropagation(); + ev.stopPropagation(); this.entityObj.closeCoverTilt(); }, onStopTiltTap: function (ev) { - ev.stopPropagation(); + ev.stopPropagation(); this.entityObj.stopCoverTilt(); }, }); From 88a46705078b728f6a40efef9cb08ced689ce8c0 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 12:05:59 -0400 Subject: [PATCH 4/9] making only one set of controls show up with preference to up/down --- src/components/ha-cover-tilt-controls.html | 20 +-------------- src/more-infos/more-info-cover.html | 3 +++ src/state-summary/state-card-cover.html | 30 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 21 deletions(-) mode change 100644 => 100755 src/components/ha-cover-tilt-controls.html mode change 100644 => 100755 src/more-infos/more-info-cover.html mode change 100644 => 100755 src/state-summary/state-card-cover.html diff --git a/src/components/ha-cover-tilt-controls.html b/src/components/ha-cover-tilt-controls.html old mode 100644 new mode 100755 index fa727b821605..ce993f8c64a1 --- a/src/components/ha-cover-tilt-controls.html +++ b/src/components/ha-cover-tilt-controls.html @@ -10,21 +10,8 @@ @@ -61,19 +56,6 @@ return entity; }, - featureClassNames: { - 16: 'has-open_tilt', - 32: 'has-close_tilt', - 64: 'has-stop_tilt', - }, - - computeClassNames: function (stateObj) { - var classes = [ - window.hassUtil.featureClassNames(stateObj, this.featureClassNames), - ]; - return classes.join(' ').trim(); - }, - onOpenTiltTap: function (ev) { ev.stopPropagation(); this.entityObj.openCoverTilt(); diff --git a/src/more-infos/more-info-cover.html b/src/more-infos/more-info-cover.html old mode 100755 new mode 100644 index 4669a2cdfb10..e23afa995808 --- a/src/more-infos/more-info-cover.html +++ b/src/more-infos/more-info-cover.html @@ -40,7 +40,8 @@
Tilt position
- + +
- - + +
@@ -44,31 +44,20 @@ type: Object, }, + entityObj: { + type: Object, + computed: 'computeEntityObj(hass, stateObj)', + }, + }, - tiltFeatureClassNames: { - 16: 'has-open_tilt', - 32: 'has-close_tilt', - 64: 'has-stop_tilt', + isTiltOnly: function(entityObj) { + return entityObj.computeOnlyTilt(); }, - - openFeatureClassNames: { - 1: 'has-open', - 2: 'has-close', - 4: 'has-support_set_position', - 8: 'has-support-stop', + computeEntityObj: function (hass, stateObj) { + var entity = new window.CoverEntity(hass, stateObj); + return entity; }, - - computeOnlyTilt: function(stateObj) { - var tiltClasses = [ - window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), - ]; - var tiltClassString = tiltClasses.join(' ').trim(); - var openClasses = [ - window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), - ]; - var openClassString = openClasses.join(' ').trim(); - return tiltClassString != '' && openClassString == ''; - } + }); diff --git a/src/util/cover-model.html b/src/util/cover-model.html index 7c039c940390..9462e593b0fc 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -101,6 +101,32 @@ this.callService('set_cover_tilt_position', { tilt_position: tiltPosition }); }, + tiltFeatureClassNames: { + 16: 'has-open_tilt', + 32: 'has-close_tilt', + 64: 'has-stop_tilt', + }, + + openFeatureClassNames: { + 1: 'has-open', + 2: 'has-close', + 4: 'has-support_set_position', + 8: 'has-support-stop', + }, + + computeOnlyTilt: function() { + var stateObj = this.stateObj; + var tiltClasses = [ + window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), + ]; + var tiltClassString = tiltClasses.join(' ').trim(); + var openClasses = [ + window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), + ]; + var openClassString = openClasses.join(' ').trim(); + return tiltClassString != '' && openClassString == ''; + }, + // helper method callService(service, data) { From 4696832206cf9e1f1fa248261d93f2c2c5f12dec Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 12:54:08 -0400 Subject: [PATCH 6/9] appeasing Travis --- src/more-infos/more-info-cover.html | 2 +- src/state-summary/state-card-cover.html | 6 +++--- src/util/cover-model.html | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/more-infos/more-info-cover.html b/src/more-infos/more-info-cover.html index e23afa995808..b31ace6698c1 100644 --- a/src/more-infos/more-info-cover.html +++ b/src/more-infos/more-info-cover.html @@ -84,7 +84,7 @@ }, - isTiltOnly: function(entityObj) { + isTiltOnly: function (entityObj) { return entityObj.computeOnlyTilt(); }, diff --git a/src/state-summary/state-card-cover.html b/src/state-summary/state-card-cover.html index 0b89fab649c4..97470bcaf9d5 100644 --- a/src/state-summary/state-card-cover.html +++ b/src/state-summary/state-card-cover.html @@ -51,13 +51,13 @@ }, - isTiltOnly: function(entityObj) { - return entityObj.computeOnlyTilt(); + isTiltOnly: function (entityObj) { + return entityObj.computeOnlyTilt(); }, computeEntityObj: function (hass, stateObj) { var entity = new window.CoverEntity(hass, stateObj); return entity; }, - + }); diff --git a/src/util/cover-model.html b/src/util/cover-model.html index 9462e593b0fc..901476c51521 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -106,7 +106,7 @@ 32: 'has-close_tilt', 64: 'has-stop_tilt', }, - + openFeatureClassNames: { 1: 'has-open', 2: 'has-close', @@ -114,7 +114,7 @@ 8: 'has-support-stop', }, - computeOnlyTilt: function() { + computeOnlyTilt: function () { var stateObj = this.stateObj; var tiltClasses = [ window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), @@ -124,7 +124,7 @@ window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), ]; var openClassString = openClasses.join(' ').trim(); - return tiltClassString != '' && openClassString == ''; + return tiltClassString !== '' && openClassString === ''; }, // helper method From 0790ad98aabcd6591cf6816d87d0b3ee9814b5fd Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 13:19:48 -0400 Subject: [PATCH 7/9] DRYer still --- src/more-infos/more-info-cover.html | 6 +----- src/state-summary/state-card-cover.html | 7 ++----- src/util/cover-model.html | 26 ++++++++++++------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/more-infos/more-info-cover.html b/src/more-infos/more-info-cover.html index b31ace6698c1..5f8ac8677751 100644 --- a/src/more-infos/more-info-cover.html +++ b/src/more-infos/more-info-cover.html @@ -40,7 +40,7 @@
Tilt position
- +
- - + +
@@ -51,9 +51,6 @@ }, - isTiltOnly: function (entityObj) { - return entityObj.computeOnlyTilt(); - }, computeEntityObj: function (hass, stateObj) { var entity = new window.CoverEntity(hass, stateObj); return entity; diff --git a/src/util/cover-model.html b/src/util/cover-model.html index 901476c51521..e366a0a7d667 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -66,6 +66,19 @@ return (this.stateObj.attributes.supported_features & 128) !== 0; }); + addGetter('isTiltOnly', function () { + var stateObj = this.stateObj; + var tiltClasses = [ + window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), + ]; + var tiltClassString = tiltClasses.join(' ').trim(); + var openClasses = [ + window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), + ]; + var openClassString = openClasses.join(' ').trim(); + return tiltClassString !== '' && openClassString === ''; + }); + /* eslint-enable no-bitwise */ Object.assign(window.CoverEntity.prototype, { @@ -114,19 +127,6 @@ 8: 'has-support-stop', }, - computeOnlyTilt: function () { - var stateObj = this.stateObj; - var tiltClasses = [ - window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), - ]; - var tiltClassString = tiltClasses.join(' ').trim(); - var openClasses = [ - window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), - ]; - var openClassString = openClasses.join(' ').trim(); - return tiltClassString !== '' && openClassString === ''; - }, - // helper method callService(service, data) { From 693143ac9e768acd86ca04280ff24ce80517a21f Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 15:08:20 -0400 Subject: [PATCH 8/9] reusing utility functions --- src/util/cover-model.html | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/util/cover-model.html b/src/util/cover-model.html index e366a0a7d667..354ecc1841f1 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -68,15 +68,9 @@ addGetter('isTiltOnly', function () { var stateObj = this.stateObj; - var tiltClasses = [ - window.hassUtil.featureClassNames(stateObj, this.tiltFeatureClassNames), - ]; - var tiltClassString = tiltClasses.join(' ').trim(); - var openClasses = [ - window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames), - ]; - var openClassString = openClasses.join(' ').trim(); - return tiltClassString !== '' && openClassString === ''; + var supportsCover = this.supportsOpen || this.supportsClose || this.supportsStop; + var supportsTilt = this.supportsOpenTilt || this.supportsCloseTilt || this.supportsStopTilt; + return supportsTilt && !supportsCover; }); /* eslint-enable no-bitwise */ @@ -114,19 +108,6 @@ this.callService('set_cover_tilt_position', { tilt_position: tiltPosition }); }, - tiltFeatureClassNames: { - 16: 'has-open_tilt', - 32: 'has-close_tilt', - 64: 'has-stop_tilt', - }, - - openFeatureClassNames: { - 1: 'has-open', - 2: 'has-close', - 4: 'has-support_set_position', - 8: 'has-support-stop', - }, - // helper method callService(service, data) { From 5fe01016f1b3f4f501641e1cbbcd2f71ea079189 Mon Sep 17 00:00:00 2001 From: Brian Cribbs Date: Wed, 31 May 2017 15:24:05 -0400 Subject: [PATCH 9/9] appeasing the build master --- src/util/cover-model.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/cover-model.html b/src/util/cover-model.html index 354ecc1841f1..4880fc03cfa1 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -67,7 +67,6 @@ }); addGetter('isTiltOnly', function () { - var stateObj = this.stateObj; var supportsCover = this.supportsOpen || this.supportsClose || this.supportsStop; var supportsTilt = this.supportsOpenTilt || this.supportsCloseTilt || this.supportsStopTilt; return supportsTilt && !supportsCover;