mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
Merge pull request #7 from persandstrom/alarm_control_hide_buttons
Alarm Control Panel: Hide unusable buttons
This commit is contained in:
commit
6b38462967
@ -9,9 +9,9 @@
|
|||||||
<paper-input label='code' value='[[entered_code]]' pattern='[0-9]*' type='password' on-change='enteredCodeChanged'></paper-input>
|
<paper-input label='code' value='[[entered_code]]' pattern='[0-9]*' type='password' on-change='enteredCodeChanged'></paper-input>
|
||||||
</div>
|
</div>
|
||||||
<div class='layout horizontal'>
|
<div class='layout horizontal'>
|
||||||
<paper-button on-tap='handleDisarmTap'>Disarm</paper-button>
|
<paper-button on-tap='handleDisarmTap' hidden$='[[!disarm_button_enabled]]'>Disarm</paper-button>
|
||||||
<paper-button on-tap='handleHomeTap'>Arm Home</paper-button>
|
<paper-button on-tap='handleHomeTap' hidden$='[[!arm_home_button_enabled]]'>Arm Home</paper-button>
|
||||||
<paper-button on-tap='handleAwayTap'>Arm Away</paper-button>
|
<paper-button on-tap='handleAwayTap' hidden$='[[!arm_away_button_enabled]]'>Arm Away</paper-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@ -14,14 +14,39 @@ export default new Polymer({
|
|||||||
this.callService('alarm_arm_away', {code: this.entered_code});
|
this.callService('alarm_arm_away', {code: this.entered_code});
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
|
stateObj: {
|
||||||
|
type: Object,
|
||||||
|
observer: 'stateObjChanged',
|
||||||
|
},
|
||||||
entered_code: {
|
entered_code: {
|
||||||
type: String,
|
type: String,
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
|
disarm_button_enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
arm_home_button_enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
arm_away_button_enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
enteredCodeChanged(ev) {
|
enteredCodeChanged(ev) {
|
||||||
this.entered_code = ev.target.value;
|
this.entered_code = ev.target.value;
|
||||||
},
|
},
|
||||||
|
stateObjChanged(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.disarm_button_enabled = newVal.state === 'armed_home' || newVal.state === 'armed_away';
|
||||||
|
this.arm_home_button_enabled = newVal.state === 'disarmed';
|
||||||
|
this.arm_away_button_enabled = newVal.state === 'disarmed';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.async(() => this.fire('iron-resize'), 500);
|
||||||
|
},
|
||||||
callService(service, data) {
|
callService(service, data) {
|
||||||
const serviceData = data || {};
|
const serviceData = data || {};
|
||||||
serviceData.entity_id = this.stateObj.entityId;
|
serviceData.entity_id = this.stateObj.entityId;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user