support returning multiple instances from elements built by Build Element Methods
This commit is contained in:
parent
1cdfb21bdd
commit
7beeffd9ad
@ -172,54 +172,64 @@ public class Element : Widget
|
||||
|
||||
InstanceHandle workSet = OMS.Execute(context, loopExecutable);
|
||||
object? obj = context.GetWorkData(workSet);
|
||||
if (obj is IEnumerable<InstanceHandle> list)
|
||||
|
||||
IEnumerable<InstanceHandle> list;
|
||||
if (obj is IEnumerable<InstanceHandle> list2)
|
||||
{
|
||||
JsonArray ary = new JsonArray();
|
||||
foreach (InstanceHandle ih in list)
|
||||
{
|
||||
JsonObject jo = new JsonObject();
|
||||
jo.Add("widget", "row");
|
||||
jo.Add("ecid", "");
|
||||
jo.Add("iid", "");
|
||||
|
||||
JsonObject cellMap = new JsonObject();
|
||||
int i = 1;
|
||||
foreach (InstanceHandle ec in contents)
|
||||
{
|
||||
InstanceHandle ecinst = OMS.GetRelatedInstance(ec, OMS.GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
|
||||
Widget parsed = Renderer.Parse(context, ecinst, ec, InstanceHandle.Empty, ih);
|
||||
|
||||
JsonObject cell;
|
||||
if (parsed == null)
|
||||
{
|
||||
cell = new JsonObject();
|
||||
cell.Add("widget", JsonValue.Create("error"));
|
||||
cell.Add("text", JsonValue.Create("could not create EC"));
|
||||
cell.Add("ecid", JsonValue.Create(OMS.GetInstanceKey(ec).ToString()));
|
||||
cell.Add("iid", JsonValue.Create(OMS.GetInstanceKey(OMS.GetRelatedInstance(ec, OMS.GetInstance(KnownRelationshipGuids.Element_Content__has__Instance))).ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = parsed.ToJSONObject(context);
|
||||
if (disabled)
|
||||
{
|
||||
if (cell.ContainsKey("enabled"))
|
||||
{
|
||||
cell.Remove("enabled");
|
||||
}
|
||||
cell.Add("enabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
cellMap.Add(String.Format("{0}.{1}", gridId, i), cell);
|
||||
i++;
|
||||
}
|
||||
jo.Add("cellsMap", cellMap);
|
||||
ary.Add(jo);
|
||||
}
|
||||
return ary;
|
||||
list = list2;
|
||||
}
|
||||
else if (obj is InstanceHandle)
|
||||
{
|
||||
list = new InstanceHandle[] { (InstanceHandle)obj };
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new InstanceHandle[0];
|
||||
}
|
||||
|
||||
JsonArray ary = new JsonArray();
|
||||
foreach (InstanceHandle ih in list)
|
||||
{
|
||||
JsonObject jo = new JsonObject();
|
||||
jo.Add("widget", "row");
|
||||
jo.Add("ecid", "");
|
||||
jo.Add("iid", "");
|
||||
|
||||
return null;
|
||||
JsonObject cellMap = new JsonObject();
|
||||
int i = 1;
|
||||
foreach (InstanceHandle ec in contents)
|
||||
{
|
||||
InstanceHandle ecinst = OMS.GetRelatedInstance(ec, OMS.GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
|
||||
Widget parsed = Renderer.Parse(context, ecinst, ec, InstanceHandle.Empty, ih);
|
||||
|
||||
JsonObject cell;
|
||||
if (parsed == null)
|
||||
{
|
||||
cell = new JsonObject();
|
||||
cell.Add("widget", JsonValue.Create("error"));
|
||||
cell.Add("text", JsonValue.Create("could not create EC"));
|
||||
cell.Add("ecid", JsonValue.Create(OMS.GetInstanceKey(ec).ToString()));
|
||||
cell.Add("iid", JsonValue.Create(OMS.GetInstanceKey(OMS.GetRelatedInstance(ec, OMS.GetInstance(KnownRelationshipGuids.Element_Content__has__Instance))).ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = parsed.ToJSONObject(context);
|
||||
if (disabled)
|
||||
{
|
||||
if (cell.ContainsKey("enabled"))
|
||||
{
|
||||
cell.Remove("enabled");
|
||||
}
|
||||
cell.Add("enabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
cellMap.Add(String.Format("{0}.{1}", gridId, i), cell);
|
||||
i++;
|
||||
}
|
||||
jo.Add("cellsMap", cellMap);
|
||||
ary.Add(jo);
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user