From d8563c33ebbefddd94761be446d53358c1fbc80b Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Mon, 10 Jul 2023 23:53:12 +0530 Subject: [PATCH] [req-changes] Fixed JS issue --- openwisp_controller/config/static/config/js/widget.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openwisp_controller/config/static/config/js/widget.js b/openwisp_controller/config/static/config/js/widget.js index 1d2c932a0..66fd155a2 100644 --- a/openwisp_controller/config/static/config/js/widget.js +++ b/openwisp_controller/config/static/config/js/widget.js @@ -37,8 +37,14 @@ // If the contextValue was set by a template or group, then // override the value. (prevDefaultValues.hasOwnProperty(key) && prevDefaultValues[key] !== defaultValues[key]) || - // Gives precedence to device's context (saved in database) and SystemContextValue - (!contextValue.hasOwnProperty(key) && !systemContextValue.hasOwnProperty(key)) + // Gives precedence to device's context (saved in database) + (!contextValue.hasOwnProperty(key) && + // Gives precedence to systemContextValue. + // But if the default value is equal to the system context value, + // then add the variable in the contextValue. This allows users + // to override the value. + (!systemContextValue.hasOwnProperty(key) || systemContextValue[key] === defaultValues[key]) + ) ) { contextValue[key] = defaultValues[key]; }