diff --git a/front/deviceDetailsEdit.php b/front/deviceDetailsEdit.php
index 19e51351..d2689866 100755
--- a/front/deviceDetailsEdit.php
+++ b/front/deviceDetailsEdit.php
@@ -339,7 +339,7 @@ function getDeviceData() {
- ${generateFormHtml(settingsData, setting, fieldData.toString(), fieldOptionsOverride, null)}
+ ${generateFormHtml(settingsData, setting, fieldData.toString(), fieldOptionsOverride, null, mac == "new")}
${inlineControl}
`;
diff --git a/front/js/common.js b/front/js/common.js
index 8ff405fd..da0f2cb8 100755
--- a/front/js/common.js
+++ b/front/js/common.js
@@ -181,7 +181,7 @@ function getSettingOptions (key) {
if (result == "")
{
- console.log(`Setting options with key "${key}" not found`)
+ // console.log(`Setting options with key "${key}" not found`)
result = []
}
@@ -197,10 +197,10 @@ function getSetting (key) {
result = getCache(`nax_set_${key}`, true);
- if (result == "")
- {
- console.log(`Setting with key "${key}" not found`)
- }
+ // if (result == "")
+ // {
+ // console.log(`Setting with key "${key}" not found`)
+ // }
return result;
}
diff --git a/front/js/modal.js b/front/js/modal.js
index d4024d02..0c4ec1fb 100755
--- a/front/js/modal.js
+++ b/front/js/modal.js
@@ -170,7 +170,8 @@ function showModalPopupForm(
curValue = null,
popupFormJson = null,
parentSettingKey = null,
- triggeredBy = null
+ triggeredBy = null,
+ populateFromOverrides = true
) {
// set captions
prefix = "modal-form";
@@ -229,7 +230,8 @@ function showModalPopupForm(
setObj,
null,
fieldOptionsOverride,
- null
+ null,
+ populateFromOverrides // is new entry
)}
diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js
index 2f713b73..dfafde44 100755
--- a/front/js/settings_utils.js
+++ b/front/js/settings_utils.js
@@ -321,7 +321,8 @@ function addViaPopupForm(element) {
null, // curValue
popupFormJson, // popupform
toId, // parentSettingKey
- element // triggeredBy
+ element, // triggeredBy
+ true // initialize defaut values
);
// flag something changes to prevent navigating from page
@@ -475,7 +476,8 @@ function initListInteractionOptions(element) {
curValue, // curValue
popupFormJson, // popupform
toId, // parentSettingKey
- this // triggeredBy
+ this, // triggeredBy
+ true // populate overrides
);
} else {
// Fallback to normal field input
@@ -1132,24 +1134,44 @@ function collectSetting(prefix, setCodeName, setType, settingsArray) {
// ------------------------------------------------------------------------------
// Generate the form control for setting
-function generateFormHtml(settingsData, set, overrideValue, overrideOptions, originalSetKey) {
+/**
+ * Generates the HTML string for form controls based on setting configurations.
+ * Supports various element types including select, input, button, textarea, span, and recursive datatables.
+ * * @param {Object} settingsData - The global settings object containing configuration for all available settings.
+ * @param {Object} set - The specific configuration object for the current setting.
+ * @param {string} set.setKey - Unique identifier for the setting.
+ * @param {string} set.setType - JSON string defining the UI components (dataType, elements, etc.).
+ * @param {string} [set.setValue] - The default value for the setting.
+ * @param {Array|string} [set.setEvents] - List of event triggers to be rendered as clickable icons.
+ * @param {any} overrideValue - The current value to be displayed in the form control.
+ * @param {any} overrideOptions - Custom options to override the default setting options (used primarily for dropdowns).
+ * @param {string} originalSetKey - The base key name (used to maintain reference when keys are modified for uniqueness in tables).
+ * @param {boolean} populateFromOverrides - Flag to determine if the value should be pulled from `set['setValue']` (true) or `overrideValue` (false).
+ * * @returns {string} A string of HTML containing the form elements and any associated event action icons.
+ * * @example
+ * const html = generateFormHtml(allSettings, currentSet, "DefaultVal", null, "my_key", false);
+ * $('#container').html(html);
+ */
+function generateFormHtml(settingsData, set, overrideValue, overrideOptions, originalSetKey, populateFromOverrides) {
let inputHtml = '';
// if override value is considered empty initialize from setting defaults
- overrideValue == null || overrideValue == undefined ? inVal = set['setValue'] : inVal = overrideValue
+ populateFromOverrides ? inVal = set['setValue'] : inVal = overrideValue;
+
const setKey = set['setKey'];
const setType = set['setType'];
- // if (setKey == 'NEWDEV_devParentMAC') {
+ // if (setKey == 'UNIFIAPI_site_name') {
- // console.log("==== DEBUG OUTPUT BELOW 1 ====");
- // console.log(setType);
- // console.log(setKey);
- // console.log(overrideValue);
- // console.log(inVal);
-
- // }
+ // console.log("==== DEBUG OUTPUT BELOW 1 ====");
+ // console.log("populateFromOverrides: " + populateFromOverrides);
+ // console.log(setType);
+ // console.log(setKey);
+ // console.log("overrideValue:" + overrideValue);
+ // console.log("inVal:" + inVal);
+ // console.log("set['setValue']:" + set['setValue']);
+ // }
// Parse the setType JSON string
// console.log(processQuotes(setType));
@@ -1189,15 +1211,14 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
// Override value
let val = valRes;
- // if (setKey == 'NEWDEV_devParentMAC') {
+ // if (setKey == 'UNIFIAPI_site_name') {
// console.log("==== DEBUG OUTPUT BELOW 2 ====");
// console.log(setType);
// console.log(setKey);
- // console.log(overrideValue);
- // console.log(inVal);
- // console.log(val);
-
+ // console.log("overrideValue:" + overrideValue);
+ // console.log("inVal:" + inVal);
+ // console.log("val:" + val);
// }
// Generate HTML based on elementType
@@ -1227,7 +1248,7 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
break;
case 'input':
- const checked = val === 'True' || val === 'true' || val === '1' ? 'checked' : '';
+ const checked = val === 'True' || val === 'true' || val === '1' || val == true ? 'checked' : '';
const inputClass = inputType === 'checkbox' ? 'checkbox' : 'form-control';
inputHtml += ` ${cellHtml}
`;
diff --git a/front/settings.php b/front/settings.php
index 899cdef0..2dc298bd 100755
--- a/front/settings.php
+++ b/front/settings.php
@@ -511,10 +511,10 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
}
// INPUT
- inputFormHtml = generateFormHtml(settingsData, set, valIn, null, null);
+ inputFormHtml = generateFormHtml(settingsData, set, valIn, null, null, false);
- // construct final HTML for the setting
- setHtml += inputFormHtml + overrideHtml + `
+ // construct final HTML for the setting
+ setHtml += inputFormHtml + overrideHtml + `
`