mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Ensure the input is typeField + clean up
This commit is contained in:
parent
26a4235028
commit
2fc950295c
@ -230,28 +230,29 @@ RED.editor = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function validateNodeEditorProperty(node,defaults,property,prefix) {
|
||||
var input = $("#"+prefix+"-"+property);
|
||||
function validateNodeEditorProperty(node, defaults, property, prefix) {
|
||||
let input = $("#"+prefix+"-"+property);
|
||||
if (input.length > 0) {
|
||||
var value = input.val();
|
||||
let value = input.val();
|
||||
if (defaults[property].hasOwnProperty("format") && defaults[property].format !== "" && input[0].nodeName === "DIV") {
|
||||
value = input.text();
|
||||
}
|
||||
const isTypeField =
|
||||
input.attr("type") === "hidden" &&
|
||||
input.css("display") === "none" &&
|
||||
input.attr("class") !== "red-ui-typedInput" &&
|
||||
input.closest("div").find("input").length >= 2;
|
||||
input = isTypeField ? input.closest("div").find("input[class='red-ui-typedInput']") : input;
|
||||
var valid = validateNodeProperty(node, defaults, property, value);
|
||||
if (input.attr("type") === "hidden") { // Possible typeField
|
||||
const typedInput = input.closest("div").find("input[class='red-ui-typedInput']");
|
||||
const typeField = typedInput.data("noderedTypedInput")?.typeField;
|
||||
const isTypeField = input.is(typeField);
|
||||
if (isTypeField) input = typedInput;
|
||||
}
|
||||
const valid = validateNodeProperty(node, defaults, property, value);
|
||||
if (((typeof valid) === "string") || !valid) {
|
||||
input.addClass("input-error");
|
||||
input.next(".red-ui-typedInput-container").addClass("input-error");
|
||||
if ((typeof valid) === "string") {
|
||||
var tooltip = input.data("tooltip");
|
||||
let tooltip = input.data("tooltip");
|
||||
if (tooltip) {
|
||||
tooltip.setContent(valid);
|
||||
} 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 target = typedInput.length > 0 ? typedInput : input;
|
||||
tooltip = RED.popover.tooltip(target, valid);
|
||||
@ -261,7 +262,7 @@ RED.editor = (function() {
|
||||
} else {
|
||||
input.removeClass("input-error");
|
||||
input.next(".red-ui-typedInput-container").removeClass("input-error");
|
||||
var tooltip = input.data("tooltip");
|
||||
const tooltip = input.data("tooltip");
|
||||
if (tooltip) {
|
||||
input.data("tooltip", null);
|
||||
tooltip.delete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user