support instance previews delivered from .NET OMS
This commit is contained in:
parent
b289d26c89
commit
4312da2f00
@ -109,6 +109,11 @@
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -487,6 +492,11 @@
|
||||
|
||||
}
|
||||
|
||||
public function getInstancePreview(InstanceReference $inst) : array
|
||||
{
|
||||
return [ ];
|
||||
}
|
||||
|
||||
public function getRelatedTasks(InstanceReference $inst)
|
||||
{
|
||||
$instParent = $this->getParentClass($inst);
|
||||
|
||||
@ -347,6 +347,12 @@
|
||||
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)
|
||||
{
|
||||
$json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element");
|
||||
@ -356,7 +362,7 @@
|
||||
/**
|
||||
* 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);
|
||||
return new InstanceReference(null, InstanceKey::parse($result["iid"]), UUID::parse($result["globalIdentifier"]));
|
||||
|
||||
@ -79,7 +79,16 @@
|
||||
|
||||
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->renderFragment($json);
|
||||
|
||||
@ -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)
|
||||
{
|
||||
this.ParentElement = parentElement;
|
||||
@ -242,7 +260,8 @@ function McxMoniker(parentElement)
|
||||
li2.className = "uwt-menu-item-command uwt-visible";
|
||||
|
||||
var a2 = document.createElement("a");
|
||||
a2.href = tgsecondary.uri;
|
||||
|
||||
a2.href = flattenUri(tgsecondary.uri);
|
||||
|
||||
var span2 = document.createElement("span");
|
||||
span2.className = "uwt-title";
|
||||
|
||||
@ -135,7 +135,6 @@
|
||||
|
||||
protected function OnRendering(RenderingEventArgs $re)
|
||||
{
|
||||
/** @var \Mocha\Oms\MySQLDatabaseOMS */
|
||||
$oms = mocha_get_oms();
|
||||
|
||||
if ($oms->getCurrentUser() === null)
|
||||
@ -159,6 +158,9 @@
|
||||
$inst = $oms->getInstanceByKey(InstanceKey::parse($iid));
|
||||
$instParent = $oms->getParentClass($inst);
|
||||
|
||||
$jsonPreview = $oms->getInstancePreview($inst);
|
||||
|
||||
/*
|
||||
$tasks = $oms->getRelatedTasks($inst);
|
||||
$taskGroupsDefs = [ ];
|
||||
|
||||
@ -197,6 +199,9 @@
|
||||
"title" => $oms->getInstanceText($inst)
|
||||
)
|
||||
);
|
||||
*/
|
||||
$json = $jsonPreview["relatedTasks"];
|
||||
/*
|
||||
|
||||
$previewElement = $oms->getRelatedInstance($instParent, KnownRelationshipGuids::Class__uses_preview__Executable_returning_Element);
|
||||
if ($previewElement !== null)
|
||||
@ -208,7 +213,7 @@
|
||||
$previewContent = $r->renderElementAsString($parentECs, $previewElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ], true);
|
||||
$json["preview"] = $previewContent;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
$json["result"] = "success";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user