@@ -143,7 +143,7 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
function setFocus() {
for (const input of inputs) {
- const element = document.getElementById(input.name);
+ const element = document.getElementById(input.key);
if (input.focus) {
element.focus();
}
@@ -170,12 +170,12 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
const input = getInputByName(e.target.id);
if (input.required) {
const currentValue = e.target.value?.toString();
- inputsRequiredStatus[input.name] = (currentValue?.toString()?.length > 0);
+ inputsRequiredStatus[input.key] = (currentValue?.toString()?.length > 0);
setInputsRequiredStatus(current => ({...inputsRequiredStatus}));
}
if (input.type === "email") {
const currentValue = e.target.value?.toString();
- inputsRequiredStatus[input.name] = isValidEmail(currentValue);
+ inputsRequiredStatus[input.key] = isValidEmail(currentValue);
setInputsRequiredStatus(current => ({...inputsRequiredStatus}));
}
//
@@ -191,7 +191,7 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
const dependentInputs = getInputDependencies(input);
for (const dependentInput of dependentInputs) {
if (typeof(dependentInput.value) === "function") {
- const dependentElement = document.getElementById(dependentInput.name);
+ const dependentElement = document.getElementById(dependentInput.key);
if (dependentElement) {
const dependentValue = dependentInput.value(e.target.value?.toString());
if (dependentValue !== undefined) {
@@ -207,7 +207,7 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
function getInputDependencies(input) {
const results = [];
if (input) {
- const inputName = input.name;
+ const inputName = input.key;
for (const input of inputs) {
if (input.dependsOn === inputName) {
results.push(input);
@@ -217,9 +217,9 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
return results;
}
- function getInputByName(name) {
+ function getInputByName(key) {
for (const input of inputs) {
- if (input.name === name) {
+ if (input.key === key) {
return input;
}
}
@@ -232,7 +232,7 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
continue;
}
const originalValue = valueOf(input);
- const element = document.getElementById(input.name);
+ const element = document.getElementById(input.key);
const currentValue = element.value?.toString();
if (originalValue?.toString() !== currentValue?.toString()) {
return true;
@@ -243,7 +243,7 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
function resetInputValuesToOriginal() {
for (const input of inputs) {
- const element = document.getElementById(input.name);
+ const element = document.getElementById(input.key);
if (element) {
element.value = valueOf(input);
}
@@ -254,12 +254,12 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
function gatherCurrentInputValues() {
const values = {}
for (const input of inputs) {
- let value = document.getElementById(input.name).value;
+ let value = document.getElementById(input.key).value;
if (!input.readonly || (input.readonlyOverridableOnCreate && Str.HasValue(value))) {
if (input.type === "boolean") {
value = (value.toString().toLowerCase() === "true") ? true : false;
}
- values[input.name] = value;
+ values[input.key] = value;
}
}
return values;
@@ -291,17 +291,17 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
const inputsRequiredStatus = {};
for (const input of inputs) {
if (input.required) {
- inputsRequiredStatus[input.name] = document.getElementById(input.name)?.value?.toString()?.length > 0;
+ inputsRequiredStatus[input.key] = document.getElementById(input.key)?.value?.toString()?.length > 0;
}
if (input.type === "email") {
- inputsRequiredStatus[input.name] = isValidEmail(document.getElementById(input.name)?.value?.toString());
+ inputsRequiredStatus[input.key] = isValidEmail(document.getElementById(input.key)?.value?.toString());
}
}
setInputsRequiredStatus(inputsRequiredStatus);
}
function inputRequiredIndicatorColor(input) {
- return inputsRequiredStatus[input.name] ? "green" : "red";
+ return inputsRequiredStatus[input.key] ? "green" : "red";
}
function allowSubmit() {
@@ -332,14 +332,14 @@ const EditBox = ({ inputs, setInputs, title, loading, onCreate, onUpdate, onDele
{ input.type === "boolean" ? <>
- |