mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 02:54:38 +00:00
dashboard: make sure widget options are set to the default if none of the options match
This commit is contained in:
parent
ecfa01b2fa
commit
b52055af0b
@ -68,6 +68,17 @@ class BaseWidget {
|
||||
(typeof(widget_config[key] === 'object') && Object.keys(widget_config[key]).length !== 0) &&
|
||||
(typeof(widget_config[key] === 'string') && widget_config[key].length !== 0)
|
||||
) {
|
||||
if (typeof(widget_config[key] === 'array')) {
|
||||
const optionsArr = value.options.map(v => v.value);
|
||||
if (!(widget_config[key].some(v => optionsArr.includes(v)))) {
|
||||
// if there is config data, but none of the
|
||||
// options match, set it to the default.
|
||||
// currently only implemented for the array case
|
||||
acc[key] = value.default;
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
|
||||
acc[key] = widget_config[key];
|
||||
} else {
|
||||
acc[key] = value.default;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user