update related work sets

This commit is contained in:
Michael Becker 2025-01-17 22:46:34 -05:00
parent ebbccef6b9
commit f8d8e7d752
3 changed files with 29 additions and 21 deletions

View File

@ -64,6 +64,29 @@ public class ElementCommand : InstanceCommand
} }
else else
{ {
// update related work sets
foreach (KeyValuePair<string, string> kvp in e.Context.Request.Form)
{
if (kvp.Key == "relatedInstance")
{
object? v = oms.ParseValue(kvp.Value);
InstanceHandle relatedWorkSet = oms.GetRelatedInstance(ProcessingInstance, oms.GetInstance(KnownRelationshipGuids.Task__has_related__Work_Set));
if (relatedWorkSet != InstanceHandle.Empty)
{
ctx.SetWorkData(relatedWorkSet, v);
}
ctx.SetWorkData(oms.GetInstance(KnownInstanceGuids.WorkSets.TaskRelatedInstance), v);
}
else
{
if (oms.TryParseInstanceRef(kvp.Key, out InstanceHandle h))
{
ctx.SetWorkData(h, oms.ParseValue(kvp.Value));
}
}
}
Renderer renderer = new Renderer(oms); Renderer renderer = new Renderer(oms);
if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Element))) if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Element)))
{ {
@ -97,27 +120,6 @@ public class ElementCommand : InstanceCommand
} }
else if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Task))) else if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Task)))
{ {
foreach (KeyValuePair<string, string> kvp in e.Context.Request.Form)
{
if (kvp.Key == "relatedInstance")
{
object? v = oms.ParseValue(kvp.Value);
InstanceHandle relatedWorkSet = oms.GetRelatedInstance(ProcessingInstance, oms.GetInstance(KnownRelationshipGuids.Task__has_related__Work_Set));
if (relatedWorkSet != InstanceHandle.Empty)
{
ctx.SetWorkData(relatedWorkSet, v);
}
}
else
{
if (oms.TryParseInstanceRef(kvp.Key, out InstanceHandle h))
{
ctx.SetWorkData(h, oms.ParseValue(kvp.Value));
}
}
}
RespndWithTask(oms, sw, e.Context, ctx, ProcessingInstance); RespndWithTask(oms, sw, e.Context, ctx, ProcessingInstance);
} }
else else

View File

@ -490,5 +490,9 @@ namespace Mocha.Core
public static Guid OOP { get; } = new Guid("{818dfe8d-96ea-4339-8d18-a0e9a5f50908}"); public static Guid OOP { get; } = new Guid("{818dfe8d-96ea-4339-8d18-a0e9a5f50908}");
public static Guid OOPMethodExamples { get; } = new Guid("{5017c102-c154-4ef0-b117-e42bd1c756c1}"); public static Guid OOPMethodExamples { get; } = new Guid("{5017c102-c154-4ef0-b117-e42bd1c756c1}");
} }
public static class WorkSets
{
public static Guid TaskRelatedInstance { get; } = new Guid("{d3860252-491e-469e-939e-702d56d88063}");
}
} }
} }

View File

@ -50,6 +50,8 @@ public class Text : Widget
} }
else else
{ {
// context.SetWorkData(OMS.GetInstance(KnownInstanceGuids.WorkSets.TaskRelatedInstance), TargetInstance);
InstanceHandle workData = OMS.Execute(context, ParentInstance); InstanceHandle workData = OMS.Execute(context, ParentInstance);
object? val = context.GetWorkData(workData); object? val = context.GetWorkData(workData);
value = val?.ToString(); value = val?.ToString();