Skip to content

Commit

Permalink
Config sheet: Always show advanced params only if changed from default (
Browse files Browse the repository at this point in the history
#2888)

Improve code from #2313.
Closes #2879.

---------

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Dec 3, 2024
1 parent d432f3b commit 1258cf0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bundles/org.openhab.ui/web/src/components/config/config-sheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default {
return this.parameters.length > 0 && this.parameters.some((p) => p.advanced)
},
displayedParameters () {
function notNullNotUndefined (value) {
return value !== null && value !== undefined
}
if (!this.parameters.length) return []
let finalParameters = [...this.parameters]
if (this.parameterGroups && this.parameterGroups.some((g) => g.context === 'action')) {
Expand All @@ -108,11 +112,13 @@ export default {
})
}
if (this.showAdvanced) return finalParameters // show all parameters
// exclude advanced parameters, if:
// - a default value is defined and the actual value differs from the default value
// - no default value is defined and the param has a value
return finalParameters.filter((p) => !p.advanced ||
(p.default !== undefined && this.configuration[p.name] !== undefined && this.configuration[p.name] !== null ? this.configuration[p.name].toString() !== p.default : this.configuration[p.name] !== undefined))
// exclude advanced parameters:
return finalParameters.filter((p) =>
// parameter is not advanced: always show
!p.advanced ||
// parameter is advanced: show only if default is defined and value is different from default
(notNullNotUndefined(p.default) && notNullNotUndefined(this.configuration[p.name]) && this.configuration[p.name].toString() !== p.default)
)
}
},
methods: {
Expand Down

0 comments on commit 1258cf0

Please sign in to comment.