Fixed save load issues in the variable types of nodes
Some checks failed
Build / build (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
This commit is contained in:
@@ -59,12 +59,12 @@ namespace Nodify.Calculator
|
|||||||
case SystemOperationViewModel sys:
|
case SystemOperationViewModel sys:
|
||||||
nodeData.NodeType = "System";
|
nodeData.NodeType = "System";
|
||||||
nodeData.SystemOp = sys.SystemOperationType.ToString();
|
nodeData.SystemOp = sys.SystemOperationType.ToString();
|
||||||
// For GET_SET nodes, derive ClassName from title
|
// For GET_SET nodes, save ClassName and variable metadata
|
||||||
if (sys.SystemOperationType == SystemOperations.GET_SET)
|
if (sys.SystemOperationType == SystemOperations.GET_SET)
|
||||||
{
|
{
|
||||||
var title = sys.Title ?? "";
|
nodeData.ClassName = sys.ClassName ?? string.Empty;
|
||||||
if (title.StartsWith("GET ")) nodeData.ClassName = title.Substring(4).Trim();
|
nodeData.IsSimpleVariable = sys.IsSimpleVariable;
|
||||||
else if (title.StartsWith("SET ")) nodeData.ClassName = title.Substring(4).Trim();
|
nodeData.VariableType = sys.VariableType ?? string.Empty;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case APIOperationViewModel api:
|
case APIOperationViewModel api:
|
||||||
@@ -113,6 +113,20 @@ namespace Nodify.Calculator
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serialize function definitions from the left panel
|
||||||
|
foreach (var funcInfo in calculator.OperationsMenu.AvailableFunctions)
|
||||||
|
{
|
||||||
|
var funcDef = new FunctionDefinitionData
|
||||||
|
{
|
||||||
|
Name = funcInfo.Title ?? string.Empty
|
||||||
|
};
|
||||||
|
foreach (var inp in funcInfo.FunctionInputs)
|
||||||
|
funcDef.Inputs.Add(new FunctionParamData { Name = inp.Name, Type = inp.Type });
|
||||||
|
foreach (var outp in funcInfo.FunctionOutputs)
|
||||||
|
funcDef.Outputs.Add(new FunctionParamData { Name = outp.Name, Type = outp.Type });
|
||||||
|
graph.FunctionDefinitions.Add(funcDef);
|
||||||
|
}
|
||||||
|
|
||||||
// Save to LiteDB
|
// Save to LiteDB
|
||||||
using var db = new LiteDbHelper<SaveGraphModel>("Graph");
|
using var db = new LiteDbHelper<SaveGraphModel>("Graph");
|
||||||
db.DeleteMany(_ => true);
|
db.DeleteMany(_ => true);
|
||||||
@@ -138,6 +152,30 @@ namespace Nodify.Calculator
|
|||||||
calculator.Connections.Clear();
|
calculator.Connections.Clear();
|
||||||
calculator.Operations.Clear();
|
calculator.Operations.Clear();
|
||||||
|
|
||||||
|
// Restore function definitions to the left panel
|
||||||
|
opsMenu.AvailableFunctions.Clear();
|
||||||
|
if (graph.FunctionDefinitions != null)
|
||||||
|
{
|
||||||
|
foreach (var funcDef in graph.FunctionDefinitions)
|
||||||
|
{
|
||||||
|
var funcInfo = new OperationInfoViewModel
|
||||||
|
{
|
||||||
|
Title = funcDef.Name,
|
||||||
|
Type = OperationType.System,
|
||||||
|
sysOp = SystemOperations.FUNCTION,
|
||||||
|
IsFlowNode = true,
|
||||||
|
IsFunction = true,
|
||||||
|
FunctionInputs = new System.Collections.Generic.List<FunctionParameterInfo>(),
|
||||||
|
FunctionOutputs = new System.Collections.Generic.List<FunctionParameterInfo>()
|
||||||
|
};
|
||||||
|
foreach (var inp in funcDef.Inputs)
|
||||||
|
funcInfo.FunctionInputs.Add(new FunctionParameterInfo { Name = inp.Name, Type = inp.Type });
|
||||||
|
foreach (var outp in funcDef.Outputs)
|
||||||
|
funcInfo.FunctionOutputs.Add(new FunctionParameterInfo { Name = outp.Name, Type = outp.Type });
|
||||||
|
opsMenu.AvailableFunctions.Add(funcInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
calculator.IsLoading = true;
|
calculator.IsLoading = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -226,8 +264,14 @@ namespace Nodify.Calculator
|
|||||||
|
|
||||||
if (sysOp == SystemOperations.GET_SET && !string.IsNullOrEmpty(nd.ClassName))
|
if (sysOp == SystemOperations.GET_SET && !string.IsNullOrEmpty(nd.ClassName))
|
||||||
{
|
{
|
||||||
info.IsModelNode = true;
|
|
||||||
info.ClassName = nd.ClassName;
|
info.ClassName = nd.ClassName;
|
||||||
|
info.IsSimpleVariable = nd.IsSimpleVariable;
|
||||||
|
info.VariableType = nd.VariableType ?? string.Empty;
|
||||||
|
info.IsModelNode = true;
|
||||||
|
// Extract just "GET" or "SET" prefix so the factory doesn't re-append ClassName
|
||||||
|
var savedTitle = nd.Title ?? "";
|
||||||
|
if (savedTitle.StartsWith("GET ")) info.Title = "GET";
|
||||||
|
else if (savedTitle.StartsWith("SET ")) info.Title = "SET";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up inputs/outputs based on system operation type
|
// Set up inputs/outputs based on system operation type
|
||||||
@@ -263,6 +307,9 @@ namespace Nodify.Calculator
|
|||||||
case SystemOperations.KNOT:
|
case SystemOperations.KNOT:
|
||||||
// Knot nodes manage their own connectors; don't add any here
|
// Knot nodes manage their own connectors; don't add any here
|
||||||
break;
|
break;
|
||||||
|
case SystemOperations.GET_SET:
|
||||||
|
// GET_SET nodes build their own connectors in OperationFactory
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
info.Output.Add("");
|
info.Output.Add("");
|
||||||
info.IsFlowNode = true;
|
info.IsFlowNode = true;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Nodify.Calculator.Models
|
|||||||
public int Id { get; set; } = 1;
|
public int Id { get; set; } = 1;
|
||||||
public List<NodeData> Nodes { get; set; } = new List<NodeData>();
|
public List<NodeData> Nodes { get; set; } = new List<NodeData>();
|
||||||
public List<ConnectionData> Connections { get; set; } = new List<ConnectionData>();
|
public List<ConnectionData> Connections { get; set; } = new List<ConnectionData>();
|
||||||
|
public List<FunctionDefinitionData> FunctionDefinitions { get; set; } = new List<FunctionDefinitionData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NodeData
|
public class NodeData
|
||||||
@@ -29,6 +30,8 @@ namespace Nodify.Calculator.Models
|
|||||||
// System node properties
|
// System node properties
|
||||||
public string SystemOp { get; set; } = string.Empty;
|
public string SystemOp { get; set; } = string.Empty;
|
||||||
public string ClassName { get; set; } = string.Empty;
|
public string ClassName { get; set; } = string.Empty;
|
||||||
|
public bool IsSimpleVariable { get; set; }
|
||||||
|
public string VariableType { get; set; } = string.Empty;
|
||||||
|
|
||||||
// Auth node properties
|
// Auth node properties
|
||||||
public string AuthBaseUrl { get; set; } = string.Empty;
|
public string AuthBaseUrl { get; set; } = string.Empty;
|
||||||
@@ -74,6 +77,13 @@ namespace Nodify.Calculator.Models
|
|||||||
public string Type { get; set; } = string.Empty;
|
public string Type { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FunctionDefinitionData
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public List<FunctionParamData> Inputs { get; set; } = new List<FunctionParamData>();
|
||||||
|
public List<FunctionParamData> Outputs { get; set; } = new List<FunctionParamData>();
|
||||||
|
}
|
||||||
|
|
||||||
// Keep legacy for compatibility
|
// Keep legacy for compatibility
|
||||||
public class SaveNodes
|
public class SaveNodes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -554,7 +554,10 @@ namespace Nodify.Calculator
|
|||||||
var sysOp = new SystemOperationViewModel
|
var sysOp = new SystemOperationViewModel
|
||||||
{
|
{
|
||||||
Title = info.Title,
|
Title = info.Title,
|
||||||
SystemOperationType = info.sysOp
|
SystemOperationType = info.sysOp,
|
||||||
|
IsSimpleVariable = info.IsSimpleVariable,
|
||||||
|
VariableType = info.VariableType ?? string.Empty,
|
||||||
|
ClassName = info.ClassName ?? string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
if (info.sysOp == SystemOperations.COPY)
|
if (info.sysOp == SystemOperations.COPY)
|
||||||
|
|||||||
@@ -35,5 +35,9 @@ namespace Nodify.Calculator
|
|||||||
get => _systemOperation;
|
get => _systemOperation;
|
||||||
set => SetProperty(ref _systemOperation, value);
|
set => SetProperty(ref _systemOperation, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSimpleVariable { get; set; }
|
||||||
|
public string VariableType { get; set; } = string.Empty;
|
||||||
|
public string ClassName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user