mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-11 11:26:35 +00:00
Merge pull request #10 from tomduijf/config_fields_support
configurator now supports fields
This commit is contained in:
commit
8fe314a75d
@ -38,6 +38,13 @@
|
|||||||
<img src='[[stateObj.attributes.description_image]]' />
|
<img src='[[stateObj.attributes.description_image]]' />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<template is='dom-repeat' items='[[stateObj.attributes.fields]]'>
|
||||||
|
<paper-input-container id='paper-input-fields-{{item.id}}'>
|
||||||
|
<label>{{item.name}}</label>
|
||||||
|
<input is="iron-input" type="{{item.type}}" id='{{item.id}}' on-change="fieldChanged"/>
|
||||||
|
</paper-input-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
<p class='submit'>
|
<p class='submit'>
|
||||||
<paper-button raised on-click='submitClicked'
|
<paper-button raised on-click='submitClicked'
|
||||||
hidden$='[[isConfiguring]]'>[[submitCaption]]</paper-button>
|
hidden$='[[isConfiguring]]'>[[submitCaption]]</paper-button>
|
||||||
|
@ -43,6 +43,10 @@ export default new Polymer({
|
|||||||
type: String,
|
type: String,
|
||||||
computed: 'computeSubmitCaption(stateObj)',
|
computed: 'computeSubmitCaption(stateObj)',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fieldInput: {
|
||||||
|
type: Object, value: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
computeIsConfigurable(stateObj) {
|
computeIsConfigurable(stateObj) {
|
||||||
@ -53,11 +57,17 @@ export default new Polymer({
|
|||||||
return stateObj.attributes.submit_caption || 'Set configuration';
|
return stateObj.attributes.submit_caption || 'Set configuration';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fieldChanged(ev) {
|
||||||
|
const el = ev.target;
|
||||||
|
this.fieldInput[el.id] = el.value;
|
||||||
|
},
|
||||||
|
|
||||||
submitClicked() {
|
submitClicked() {
|
||||||
this.isConfiguring = true;
|
this.isConfiguring = true;
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
configure_id: this.stateObj.attributes.configure_id,
|
configure_id: this.stateObj.attributes.configure_id,
|
||||||
|
fields: this.fieldInput,
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceActions.callService('configurator', 'configure', data).then(
|
serviceActions.callService('configurator', 'configure', data).then(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user