From 1d1a90d101be73ca41abe57c53c1cf1e24b5b121 Mon Sep 17 00:00:00 2001 From: mbronk Date: Tue, 20 Sep 2022 23:32:22 +0200 Subject: [PATCH] Thing "actions" config param handling made generic For Main UI's Thing-Details view. Fixes #1491 Signed-off-by: Mateusz Bronk --- .../pages/settings/things/thing-details.vue | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue b/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue index 7bf64a6b5b..e186740ea3 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/things/thing-details.vue @@ -107,12 +107,12 @@ - + - Z-Wave + Actions - - + + @@ -276,7 +276,7 @@ export default { channelTypes: {}, configDescriptions: {}, configStatusInfo: [], - zwaveActions: {}, + configActions: [], thingEnabled: true, codePopupOpened: false, zwaveNetworkPopupOpened: false, @@ -371,10 +371,12 @@ export default { this.configDirty = false this.thingDirty = false - // special treatment for Z-Wave actions - if (this.thingType.UID.indexOf('zwave') === 0) { - this.zwaveActions = this.configDescriptions.parameters.filter((p) => p.groupName === 'actions') - this.configDescriptions.parameters = this.configDescriptions.parameters.filter((p) => p.groupName !== 'actions') + // special treatment for actions (heuristic match by group name/label) + if (this.configDescriptions.parameterGroups.filter((pg) => pg.name === 'actions').every((pg) => pg.label === 'Actions' && pg.description === 'Actions')) { + this.configActions = this.configDescriptions.parameters.filter((p) => p.groupName === 'actions' && p.type === 'BOOLEAN') + } + if (this.configActions.length > 0) { + this.configDescriptions.parameters = this.configDescriptions.parameters.filter((p) => this.configActions.every((action) => action.name !== p.name)) } if (!this.eventSource) this.startEventSource() @@ -443,12 +445,12 @@ export default { }).open() }) }, - doZWaveAction (action) { + doConfigAction (action) { let thing = this.thing let save = this.save if (action.type !== 'BOOLEAN') return this.$f7.dialog.confirm( - `${action.label}?`, + `${action.description ?? action.label}?${action.verify ? '

WARNING: This action may be dangerous!

' : ''}`, this.thing.label, () => { thing.configuration[action.name] = true