mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-10 10:56:34 +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]]' />
|
||||
</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'>
|
||||
<paper-button raised on-click='submitClicked'
|
||||
hidden$='[[isConfiguring]]'>[[submitCaption]]</paper-button>
|
||||
|
@ -43,6 +43,10 @@ export default new Polymer({
|
||||
type: String,
|
||||
computed: 'computeSubmitCaption(stateObj)',
|
||||
},
|
||||
|
||||
fieldInput: {
|
||||
type: Object, value: {},
|
||||
},
|
||||
},
|
||||
|
||||
computeIsConfigurable(stateObj) {
|
||||
@ -53,11 +57,17 @@ export default new Polymer({
|
||||
return stateObj.attributes.submit_caption || 'Set configuration';
|
||||
},
|
||||
|
||||
fieldChanged(ev) {
|
||||
const el = ev.target;
|
||||
this.fieldInput[el.id] = el.value;
|
||||
},
|
||||
|
||||
submitClicked() {
|
||||
this.isConfiguring = true;
|
||||
|
||||
const data = {
|
||||
configure_id: this.stateObj.attributes.configure_id,
|
||||
fields: this.fieldInput,
|
||||
};
|
||||
|
||||
serviceActions.callService('configurator', 'configure', data).then(
|
||||
|
Loading…
x
Reference in New Issue
Block a user