Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyblasta committed Oct 23, 2024
1 parent 55d9278 commit 2e948f5
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/controls/editor/edithandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,26 +915,25 @@ function onAttributesSave(features, attrs) {
if (document.getElementById(`${attribute.elId}-0`).getAttribute('type') === 'checkbox') {
if (attribute.options && attribute.options.length > 0) {
Array.from(document.getElementsByName(attribute.name)).forEach((element) => {
if (element.tagName === 'INPUT' && element.getAttribute("type") === 'checkbox' && element.checked === true) {
if (element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox' && element.checked === true) {
// Check if this is a free text checkbox
if (element.nextElementSibling.getAttribute("type") === 'text') {
if (element.nextElementSibling.getAttribute('type') === 'text') {
checkboxValues.push(element.nextElementSibling.value.trim());
} else {
checkboxValues.push(element.getAttribute("value"));
checkboxValues.push(element.getAttribute('value'));
}
}
});

editEl[attribute.name] = checkboxValues.join('; ');
} else {
editEl[attribute.name] = $(attribute.elId).is(':checked') ? 1 : 0;
editEl[attribute.name] = document.getElementById(attribute.elId).checked ? 1 : 0;
}
}
} else { // Read value from input text, textarea or select
const checkedValue = (attribute.config && attribute.config.checkedValue) || 1;
const uncheckedValue = (attribute.config && attribute.config.uncheckedValue) || 0;
editEl[attribute.name] = document.getElementById(attribute.elId).checked ? checkedValue : uncheckedValue;
}
}
} else if (attribute.type === 'searchList') {
// SearchList may have its value in another place than the input element itself. Query the "Component" instead.
// Note that inputValue still contains the value of the input element, which is used to validate required.
Expand Down Expand Up @@ -1126,7 +1125,7 @@ function addListener() {

/**
* Returns a function that adds an event handler to enable/disable the textbox for a free text checkbox
*
*
* @function
* @name addCheckboxListener
* @kind function
Expand All @@ -1137,13 +1136,13 @@ function addCheckboxListener() {
const fn = (obj) => {
Array.from(document.getElementsByName(obj.name)).forEach((element) => {
// Add a listener on the checkbox if it has input text as next element
if (element.tagName === 'INPUT' && element.getAttribute("type") === 'checkbox' && element.nextElementSibling.getAttribute("type") === 'text') {
element.addEventListener('change', (e) => {
if (element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox' && element.nextElementSibling.getAttribute('type') === 'text') {
element.addEventListener('change', () => {
if (element.checked === true) {
element.nextElementSibling.disabled = false;
document.getElementById(element.nextElementSibling.id).disabled = false;
} else {
element.nextElementSibling.value = '';
element.nextElementSibling.disabled = true;
document.getElementById(element.nextElementSibling.id).value = '';
document.getElementById(element.nextElementSibling.id).disabled = true;
}
});
}
Expand Down Expand Up @@ -1298,7 +1297,7 @@ function editAttributes(feat) {
obj.isVisible = true;
obj.elId = `input-${obj.name}`;
obj.addListener = addCheckboxListener();
} else if (obj.type === 'image') {
} else if (obj.type === 'image') {
obj.isVisible = true;
obj.elId = `input-${currentLayer}-${obj.name}`;
obj.addListener = addImageListener();
Expand Down

0 comments on commit 2e948f5

Please sign in to comment.