@@ -755,7 +755,7 @@ function main () {
// Show device icon as it changes
$('#txtIcon').on('change input', function() {
- updateIconPreview('#txtIcon')
+ updateIconPreview(this)
});
@@ -1136,7 +1136,7 @@ function initializeCalendar () {
showSpinner()
} else {
setTimeout(() => {
- updateIconPreview('#txtIcon')
+ updateIconPreview($('#txtIcon'))
}, 500);
hideSpinner()
@@ -1667,7 +1667,7 @@ function addAsBase64 () {
$('#txtIcon').val(iconHtmlBase64);
- updateIconPreview('#txtIcon')
+ updateIconPreview($('#txtIcon'))
}
diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js
index cc832160..3399ba0a 100755
--- a/front/js/settings_utils.js
+++ b/front/js/settings_utils.js
@@ -667,7 +667,11 @@ const handleElementOptions = (codeName, elementOptions, transformers, val) => {
let valRes = val;
let sourceIds = [];
let getStringKey = "";
- let onClick = "alert('Not implemented');";
+ let onClick = "console.log('onClick - Not implemented');";
+ let onChange = "console.log('onChange - Not implemented');";
+ let customParams = "";
+ let customId = "";
+
elementOptions.forEach((option) => {
if (option.prefillValue) {
@@ -711,6 +715,15 @@ const handleElementOptions = (codeName, elementOptions, transformers, val) => {
if (option.onClick) {
onClick = option.onClick;
}
+ if (option.onChange) {
+ onChange = option.onChange;
+ }
+ if (option.customParams) {
+ customParams = option.customParams;
+ }
+ if (option.customId) {
+ customId = option.customId;
+ }
});
if (transformers.includes("sha256")) {
@@ -731,6 +744,9 @@ const handleElementOptions = (codeName, elementOptions, transformers, val) => {
valRes,
getStringKey,
onClick,
+ onChange,
+ customParams,
+ customId
};
};
diff --git a/front/js/ui_components.js b/front/js/ui_components.js
index df9e6da9..087fe2d3 100755
--- a/front/js/ui_components.js
+++ b/front/js/ui_components.js
@@ -68,23 +68,66 @@ function initDeviceSelectors(devicesListAll_JSON) {
}
-// -----------------------------------------------------------------------------
+// ----------------------------------------------
// Updates the icon preview
-function updateIconPreview (inputId) {
- // update icon
- iconInput = $(inputId)
+function updateIconPreview(elem) {
+ // Retrieve and parse custom parameters from the element
+ let params = $(elem).attr("my-customparams")?.split(',').map(param => param.trim());
- value = iconInput.val()
+ // console.log(params);
- iconInput.on('change input', function() {
- $('#txtIconFA').html(atob(value))
- });
+ if (params && params.length >= 2) {
+ var inputElementID = params[0];
+ var targetElementID = params[1];
+ } else {
+ console.error("Invalid parameters passed to updateIconPreview function");
+ return;
+ }
- $('#txtIconFA').html(atob(value))
-
+ // Get the input element using the inputElementID
+ let iconInput = $("#" + inputElementID);
+
+ if (iconInput.length === 0) {
+ console.error("Icon input element not found");
+ return;
+ }
+
+ // Get the initial value and update the target element
+ let value = iconInput.val();
+ if (!value) {
+ console.error("Input value is empty or not defined");
+ return;
+ }
+
+ if (!targetElementID) {
+ targetElementID = "txtIcon";
+ }
+
+ // Check if the target element exists, if not find an element with matching custom attribute
+ let targetElement = $('#' + targetElementID);
+ if (targetElement.length === 0) {
+ // Look for an element with my-custom-id attribute equal to targetElementID
+ targetElement = $('[my-customid="' + targetElementID + '"]');
+ if (targetElement.length === 0) {
+ console.error("Neither target element with ID nor element with custom attribute found");
+ return;
+ }
+ }
+
+ // Update the target element with decoded base64 value
+ targetElement.html(atob(value));
+
+ // Add event listener to update the icon on input change
+ iconInput.on('change input', function () {
+ let newValue = $(this).val();
+ $('#' + targetElementID).html(atob(newValue));
+ });
}
+
+
+
// -----------------------------------------------------------------------------
// Generic function to copy text to clipboard
function copyToClipboard(buttonElement) {
diff --git a/front/multiEditCore.php b/front/multiEditCore.php
index c901c30d..df1a4cb0 100755
--- a/front/multiEditCore.php
+++ b/front/multiEditCore.php
@@ -101,19 +101,20 @@
for (let j = i * elementsPerColumn; j < Math.min((i + 1) * elementsPerColumn, columns.length); j++) {
const setTypeObject = JSON.parse(columns[j].Type.replace(/'/g, '"'));
- // console.log(setTypeObject); 🔽
- // const lastElementObj = setTypeObject.elements[setTypeObject.elements.length - 1]
// get the element with the input value(s)
- let elementsWithInputValue = setTypeObject.elements.filter(element => element.elementHasInputValue === 1);
+ let elements = setTypeObject.elements.filter(element => element.elementHasInputValue === 1);
// if none found, take last
- if(elementsWithInputValue.length == 0)
+ if(elements.length == 0)
{
- elementsWithInputValue = setTypeObject.elements[setTypeObject.elements.length - 1]
+ elementWithInputValue = setTypeObject.elements[setTypeObject.elements.length - 1]
+ } else
+ {
+ elementWithInputValue = elements[0]
}
- const { elementType, elementOptions = [], transformers = [] } = elementsWithInputValue;
+ const { elementType, elementOptions = [], transformers = [] } = elementWithInputValue;
const {
inputType,
readOnly,
@@ -127,26 +128,28 @@
editable,
valRes,
getStringKey,
- onClick
+ onClick,
+ onChange,
+ customParams,
+ customId
} = handleElementOptions('none', elementOptions, transformers, val = "");
- // console.log(setTypeObject);
- // console.log(inputType);
-
// render based on element type
- if (elementsWithInputValue.elementType === 'select') {
+ if (elementType === 'select') {
targetLocation = columns[j].Code_Name + "_generateSetOptions"
generateOptionsOrSetOptions(columns[j].Code_Name, [], targetLocation, generateOptions)
- // Handle Icons as tehy need a preview
+ console.log(columns[j].Code_Name)
+ // Handle Icons as they need a preview
if(columns[j].Code_Name == 'NEWDEV_dev_Icon')
{
input = `
-
+