Ensure the input is typeField + clean up

This commit is contained in:
GogoVega 2023-12-02 13:51:07 +01:00
parent 26a4235028
commit 2fc950295c
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -230,28 +230,29 @@ RED.editor = (function() {
} }
} }
function validateNodeEditorProperty(node,defaults,property,prefix) { function validateNodeEditorProperty(node, defaults, property, prefix) {
var input = $("#"+prefix+"-"+property); let input = $("#"+prefix+"-"+property);
if (input.length > 0) { if (input.length > 0) {
var value = input.val(); let value = input.val();
if (defaults[property].hasOwnProperty("format") && defaults[property].format !== "" && input[0].nodeName === "DIV") { if (defaults[property].hasOwnProperty("format") && defaults[property].format !== "" && input[0].nodeName === "DIV") {
value = input.text(); value = input.text();
} }
const isTypeField = if (input.attr("type") === "hidden") { // Possible typeField
input.attr("type") === "hidden" && const typedInput = input.closest("div").find("input[class='red-ui-typedInput']");
input.css("display") === "none" && const typeField = typedInput.data("noderedTypedInput")?.typeField;
input.attr("class") !== "red-ui-typedInput" && const isTypeField = input.is(typeField);
input.closest("div").find("input").length >= 2; if (isTypeField) input = typedInput;
input = isTypeField ? input.closest("div").find("input[class='red-ui-typedInput']") : input; }
var valid = validateNodeProperty(node, defaults, property, value); const valid = validateNodeProperty(node, defaults, property, value);
if (((typeof valid) === "string") || !valid) { if (((typeof valid) === "string") || !valid) {
input.addClass("input-error"); input.addClass("input-error");
input.next(".red-ui-typedInput-container").addClass("input-error"); input.next(".red-ui-typedInput-container").addClass("input-error");
if ((typeof valid) === "string") { if ((typeof valid) === "string") {
var tooltip = input.data("tooltip"); let tooltip = input.data("tooltip");
if (tooltip) { if (tooltip) {
tooltip.setContent(valid); tooltip.setContent(valid);
} else { } else {
// If the input is typed => need the wrap to attach the tooltip
const typedInput = input.next(".red-ui-typedInput-container").find(".red-ui-typedInput-input-wrap"); const typedInput = input.next(".red-ui-typedInput-container").find(".red-ui-typedInput-input-wrap");
const target = typedInput.length > 0 ? typedInput : input; const target = typedInput.length > 0 ? typedInput : input;
tooltip = RED.popover.tooltip(target, valid); tooltip = RED.popover.tooltip(target, valid);
@ -261,7 +262,7 @@ RED.editor = (function() {
} else { } else {
input.removeClass("input-error"); input.removeClass("input-error");
input.next(".red-ui-typedInput-container").removeClass("input-error"); input.next(".red-ui-typedInput-container").removeClass("input-error");
var tooltip = input.data("tooltip"); const tooltip = input.data("tooltip");
if (tooltip) { if (tooltip) {
input.data("tooltip", null); input.data("tooltip", null);
tooltip.delete(); tooltip.delete();