mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 21:06:34 +00:00
Clean up and fix lock more info
This commit is contained in:
parent
a3b5484a7e
commit
bee75620fe
@ -4,13 +4,16 @@
|
|||||||
<link rel='import' href='../../bower_components/paper-input/paper-input.html'>
|
<link rel='import' href='../../bower_components/paper-input/paper-input.html'>
|
||||||
|
|
||||||
<dom-module id='more-info-lock'>
|
<dom-module id='more-info-lock'>
|
||||||
|
<style>
|
||||||
|
paper-input {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<template>
|
<template>
|
||||||
<div class='layout horizontal'>
|
<div hidden='[[!stateObj.attributes.codeFormat]]'>
|
||||||
<paper-input label='code' value='{{enteredCode}}' pattern='[[codeFormat]]' type='password' hidden='[[!codeInputVisible]]' disabled='[[!codeInputEnabled]]'></paper-input>
|
<paper-input label='code' value='{{enteredCode}}' pattern='[[stateObj.attributes.codeFormat]]' type='password'></paper-input>
|
||||||
</div>
|
<paper-button on-tap='handleUnlockTap' hidden$='[[!isLocked]]'>Unlock</paper-button>
|
||||||
<div class='layout horizontal'>
|
<paper-button on-tap='handleLockTap' hidden$=[[isLocked]]>Lock</paper-button>
|
||||||
<paper-button on-tap='handleUnlockTap' hidden='[[!codeInputVisible]]' disabled='[[!unlockButtonVisible]]'>Unlock</paper-button>
|
|
||||||
<paper-button on-tap='handleLockTap' hidden='[[!codeInputVisible]]' disabled=[[!lockButtonVisible]]>Lock</paper-button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@ -15,57 +15,23 @@ export default new Polymer({
|
|||||||
type: String,
|
type: String,
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
unlockButtonVisible: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
lockButtonVisible: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
codeInputVisible: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
codeInputEnabled: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
codeFormat: {
|
|
||||||
type: String,
|
|
||||||
value: '',
|
|
||||||
},
|
|
||||||
codeValid: {
|
|
||||||
type: Boolean,
|
|
||||||
computed: 'validateCode(enteredCode, codeFormat)',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleUnlockTap() {
|
handleUnlockTap() {
|
||||||
this.callService('unlock', { code: this.enteredCode });
|
this.callService('unlock', { code: this.enteredCode });
|
||||||
},
|
},
|
||||||
|
|
||||||
handleLockTap() {
|
handleLockTap() {
|
||||||
this.callService('lock', { code: this.enteredCode });
|
this.callService('lock', { code: this.enteredCode });
|
||||||
},
|
},
|
||||||
validateCode(code, format) {
|
|
||||||
const re = new RegExp(format);
|
|
||||||
if (format === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return re.test(code);
|
|
||||||
},
|
|
||||||
stateObjChanged(newVal) {
|
stateObjChanged(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this.codeFormat = newVal.attributes.code_format;
|
this.isLocked = newVal.state === 'locked';
|
||||||
this.codeInputVisible = this.codeFormat !== null;
|
|
||||||
this.codeInputEnabled = (
|
|
||||||
newVal.state === 'locked' ||
|
|
||||||
newVal.state === 'unlocked');
|
|
||||||
this.unlockButtonVisible = (
|
|
||||||
newVal.state === 'locked');
|
|
||||||
this.lockButtonVisible = newVal.state === 'unlocked';
|
|
||||||
}
|
}
|
||||||
this.async(() => this.fire('iron-resize'), 500);
|
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