mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
Show validation errors in the UI when setting addon options
https://www.pivotaltracker.com/story/show/145323139
This commit is contained in:
parent
6d5a911cb5
commit
37526aca88
@ -13,21 +13,26 @@
|
|||||||
paper-card {
|
paper-card {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
.errors {
|
||||||
|
color: var(--google-red-500);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
iron-autogrow-textarea {
|
iron-autogrow-textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<paper-card heading='Options'>
|
<paper-card heading='Options'>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<template is='dom-if' if='[[errors]]'>
|
||||||
|
<div class='errors'>[[errors]]</div>
|
||||||
|
</template>
|
||||||
<iron-autogrow-textarea value="{{options}}"></iron-autogrow-textarea>
|
<iron-autogrow-textarea value="{{options}}"></iron-autogrow-textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-call-api-button
|
<paper-button
|
||||||
hass='[[hass]]'
|
on-tap='saveTapped'
|
||||||
disabled='[[!optionsParsed]]'
|
disabled='[[!optionsParsed]]'
|
||||||
data='[[computeOptionsData(optionsParsed)]]'
|
>Save</paper-button>
|
||||||
path="[[pathOptions(addon)]]"
|
|
||||||
>Save</ha-call-api-button>
|
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</paper-card>
|
||||||
</template>
|
</template>
|
||||||
@ -56,6 +61,11 @@ Polymer({
|
|||||||
computed: 'parseOptions(options)',
|
computed: 'parseOptions(options)',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
type: String,
|
||||||
|
value: null,
|
||||||
|
},
|
||||||
|
|
||||||
addonState: {
|
addonState: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: null,
|
value: null,
|
||||||
@ -75,6 +85,16 @@ Polymer({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveTapped: function () {
|
||||||
|
this.errors = null;
|
||||||
|
|
||||||
|
this.hass.callApi('post', 'hassio/addons/' + this.addon + '/options', {
|
||||||
|
options: this.optionsParsed
|
||||||
|
}).catch(function (resp) {
|
||||||
|
this.errors = resp.body.message;
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
computeOptionsData: function (optionsParsed) {
|
computeOptionsData: function (optionsParsed) {
|
||||||
return {
|
return {
|
||||||
options: optionsParsed,
|
options: optionsParsed,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user