support instance previews delivered from .NET OMS

This commit is contained in:
Michael Becker 2024-12-21 00:25:27 -05:00
parent b289d26c89
commit 4312da2f00
5 changed files with 54 additions and 5 deletions

View File

@ -109,6 +109,11 @@
*/ */
public abstract function getInstanceByGlobalIdentifier(UUID|string $inst) : ?InstanceReference; public abstract function getInstanceByGlobalIdentifier(UUID|string $inst) : ?InstanceReference;
/**
* Gets the instance with the specified instance key.
*/
public abstract function getInstanceByKey(InstanceKey $inst) : ?InstanceReference;
/** /**
* Indices are 1-based * Indices are 1-based
*/ */
@ -487,6 +492,11 @@
} }
public function getInstancePreview(InstanceReference $inst) : array
{
return [ ];
}
public function getRelatedTasks(InstanceReference $inst) public function getRelatedTasks(InstanceReference $inst)
{ {
$instParent = $this->getParentClass($inst); $instParent = $this->getParentClass($inst);

View File

@ -347,6 +347,12 @@
return null; return null;
} }
public function getInstancePreview(InstanceReference $inst) : array
{
$json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $inst->GlobalIdentifier->__toString() . "/preview");
return $json;
}
public function getResponse($element) public function getResponse($element)
{ {
$json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element"); $json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element");
@ -356,7 +362,7 @@
/** /**
* Gets the instance with the specified instance key. * Gets the instance with the specified instance key.
*/ */
public function getInstanceByKey(InstanceKey|string $key) : ?InstanceReference public function getInstanceByKey(InstanceKey $key) : ?InstanceReference
{ {
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $key); $result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $key);
return new InstanceReference(null, InstanceKey::parse($result["iid"]), UUID::parse($result["globalIdentifier"])); return new InstanceReference(null, InstanceKey::parse($result["iid"]), UUID::parse($result["globalIdentifier"]));

View File

@ -79,7 +79,16 @@
public function renderResponse(array $json) public function renderResponse(array $json)
{ {
$this->renderBeginPage("Test App"); $title = "";
if (array_key_exists("title", $json))
{
if (array_key_exists("label", $json["title"]))
{
$title = $json["title"]["label"];
}
}
$this->renderBeginPage($title);
$this->renderBeginContent(); $this->renderBeginContent();
$this->renderFragment($json); $this->renderFragment($json);

View File

@ -1,3 +1,21 @@
function flattenUri(uri)
{
var strUri = uri;
var strUriParts = strUri.split('/');
var strUriParts2 = [ ];
for (var i = 0; i < strUriParts.length; i++)
{
strUriParts2.push(strUriParts[i]);
if (i == 1)
{
strUriParts2.push('d');
}
}
strUri = strUriParts2.join("/");
strUri = strUri + ".htmld";
return strUri;
}
function McxMoniker(parentElement) function McxMoniker(parentElement)
{ {
this.ParentElement = parentElement; this.ParentElement = parentElement;
@ -242,7 +260,8 @@ function McxMoniker(parentElement)
li2.className = "uwt-menu-item-command uwt-visible"; li2.className = "uwt-menu-item-command uwt-visible";
var a2 = document.createElement("a"); var a2 = document.createElement("a");
a2.href = tgsecondary.uri;
a2.href = flattenUri(tgsecondary.uri);
var span2 = document.createElement("span"); var span2 = document.createElement("span");
span2.className = "uwt-title"; span2.className = "uwt-title";

View File

@ -135,7 +135,6 @@
protected function OnRendering(RenderingEventArgs $re) protected function OnRendering(RenderingEventArgs $re)
{ {
/** @var \Mocha\Oms\MySQLDatabaseOMS */
$oms = mocha_get_oms(); $oms = mocha_get_oms();
if ($oms->getCurrentUser() === null) if ($oms->getCurrentUser() === null)
@ -159,6 +158,9 @@
$inst = $oms->getInstanceByKey(InstanceKey::parse($iid)); $inst = $oms->getInstanceByKey(InstanceKey::parse($iid));
$instParent = $oms->getParentClass($inst); $instParent = $oms->getParentClass($inst);
$jsonPreview = $oms->getInstancePreview($inst);
/*
$tasks = $oms->getRelatedTasks($inst); $tasks = $oms->getRelatedTasks($inst);
$taskGroupsDefs = [ ]; $taskGroupsDefs = [ ];
@ -197,6 +199,9 @@
"title" => $oms->getInstanceText($inst) "title" => $oms->getInstanceText($inst)
) )
); );
*/
$json = $jsonPreview["relatedTasks"];
/*
$previewElement = $oms->getRelatedInstance($instParent, KnownRelationshipGuids::Class__uses_preview__Executable_returning_Element); $previewElement = $oms->getRelatedInstance($instParent, KnownRelationshipGuids::Class__uses_preview__Executable_returning_Element);
if ($previewElement !== null) if ($previewElement !== null)
@ -208,7 +213,7 @@
$previewContent = $r->renderElementAsString($parentECs, $previewElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ], true); $previewContent = $r->renderElementAsString($parentECs, $previewElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ], true);
$json["preview"] = $previewContent; $json["preview"] = $previewContent;
} }
*/
$json["result"] = "success"; $json["result"] = "success";