Save attribute checkbox state (#8010)

This commit is contained in:
Kendell R 2021-02-24 08:44:37 -08:00 committed by GitHub
parent f42c0a0717
commit 782b941531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,7 +169,7 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
<th>[[localize('ui.panel.developer-tools.tabs.states.state')]]</th> <th>[[localize('ui.panel.developer-tools.tabs.states.state')]]</th>
<th hidden$="[[narrow]]"> <th hidden$="[[narrow]]">
[[localize('ui.panel.developer-tools.tabs.states.attributes')]] [[localize('ui.panel.developer-tools.tabs.states.attributes')]]
<paper-checkbox checked="{{_showAttributes}}"></paper-checkbox> <paper-checkbox checked="{{_showAttributes}}" on-change="{{saveAttributeCheckboxState}}"></paper-checkbox>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -285,7 +285,7 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
_showAttributes: { _showAttributes: {
type: Boolean, type: Boolean,
value: true, value: JSON.parse(localStorage.getItem("devToolsShowAttributes") || true),
}, },
_entities: { _entities: {
@ -478,6 +478,14 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
return Array.isArray(value) ? value.join(", ") : value; return Array.isArray(value) ? value.join(", ") : value;
} }
saveAttributeCheckboxState(ev) {
try {
localStorage.setItem("devToolsShowAttributes", ev.target.checked);
} catch (e) {
// Catch for Safari private mode
}
}
_computeParsedStateAttributes(stateAttributes) { _computeParsedStateAttributes(stateAttributes) {
try { try {
return stateAttributes.trim() ? safeLoad(stateAttributes) : {}; return stateAttributes.trim() ? safeLoad(stateAttributes) : {};