This commit is contained in:
Michael Becker 2025-07-16 18:08:21 -04:00
parent 70a9255d1e
commit 62f717eda5
9 changed files with 90 additions and 30 deletions

View File

@ -146,7 +146,7 @@
$retval = array();
foreach ($ary as $inst)
{
$retval[] = new InstanceReference(null, InstanceKey::parse($inst["iid"]), UUID::parse($inst["globalIdentifier"]));
$retval[] = new InstanceReference(null, InstanceKey::parse($inst["iid"]), UUID::parse($inst["globalIdentifier"]), $inst["text"]);
}
return $retval;
}
@ -360,8 +360,18 @@
public function getResponse($element, InstanceReference|null $relatedInstance = null) // , array|null $workData = null)
{
$url = "/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element";
echo ("getResponse (' " . $url . " ');<br />");
if ($relatedInstance !== null)
{
// related instance is passed in by:
// UI Task.has Related Menu Item
// -> Related Menu Item.uses object of Class
//
// the parm for that class type is then set to the value of the relatedInstance URL parm
// or as WD calls, an Instance Set
$workDataPost = array("relatedInstance" => $relatedInstance->InstanceKey);
/*
$workDataPost = array();
@ -370,10 +380,10 @@
$workDataPost[UUID::parse($key)->__toString()] = strval($value);
}
*/
$json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element", HttpRequestMethod::POST, $workDataPost);
$json = $this->curl_request_json($url, HttpRequestMethod::POST, $workDataPost);
return $json;
}
$json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element");
$json = $this->curl_request_json($url);
return $json;
}
@ -410,7 +420,12 @@
public function processElement(InstanceReference $element, array $values) : array
{
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->GlobalIdentifier . "/element", HttpRequestMethod::POST, $values);
$url = "/tenants/" . $this->getTenantName() . "/instances/" . $element->GlobalIdentifier . "/element";
echo ("<br /><br />POST " . $url . "<br />Values:<br />");
echo ("<br /><br />");
print_r($values);
echo ("<br /><br />");
$result = $this->curl_request_json($url, HttpRequestMethod::POST, $values);
return $result;
}

View File

@ -41,6 +41,8 @@
*/
public $Context;
public $CodeBehindFileName;
/**
* Run in debug mode (prints log to screen and then dies at end).
*/
@ -2277,6 +2279,7 @@ EOF
$this->_stopwatch->stop();
$this->logRequestSuccess($this->_stopwatch->getElapsedTime());
echo ("<!-- code behind: " . $this->CodeBehindFileName . " -->");
}
public function renderInitialElement(InstanceReference $element)

View File

@ -25,8 +25,6 @@
*/
$oms = mocha_get_oms();
echo ("postbakc!");
$values = array();
foreach ($_POST as $key => $value)
{
@ -36,15 +34,19 @@
$values[$fqecid] = $value;
}
}
$array = $this->OMS->processElement($element, $values);
if ($array["result"] === "failure")
{
echo ("failed at processElement");
print_r($array);
return false;
}
//*** DO NOT DELETE, WE STILL USE THIS FOR LOGIN ***//
if (is_callable($this->ProcessPostbackFunction))
{
echo ("calling user function");
// call user-defined ProcessPostbackFunction
return call_user_func($this->ProcessPostbackFunction, $this, $element, $array);
}
@ -53,6 +55,8 @@
$dummy = [ ];
if (!$this->processRelatedPostback($dummy, $element))
{
echo ("failed at processRelatedPostback");
print_r($array);
return false;
}
}
@ -65,6 +69,14 @@
echo ("debug mode done");
die();
}
if ($array["result"] == "success" && $array["type"] == "redirect")
{
System::Redirect($array["destinationUrl"]);
return true;
}
print_r($array); die();
if (isset($_POST["ReturnToURL"]))
{
@ -80,7 +92,7 @@
$this->renderResponse($json["value"]);
}
public function renderResponse(array $json)
public function renderResponse(array $json, $subtitle = null)
{
$title = "";
if (array_key_exists("title", $json))
@ -99,7 +111,7 @@
if (!array_key_exists("visible", $json["title"]) || $json["title"]["visible"] === true)
{
$this->renderPageHeader($title, null);
$this->renderPageHeader($title, $subtitle);
}
$this->renderBeginContent();
@ -120,8 +132,8 @@
{
// FIXME: pass in work data parms as array e.g.
//? getResponse($task, array( RELATED_INSTANCE => $relatedInstance ))
$workData = null;
/*
$workData = null;
if ($relatedInstance !== null)
{
$workData = array
@ -131,10 +143,11 @@
}
*/
$json = $this->OMS->getResponse($task, $relatedInstance);
// print_r($json);
if ($json["result"] == "success") {
$title = $json["value"]["title"]["label"];
$this->renderResponse($json["value"]);
$this->renderResponse($json["value"], $relatedInstance);
}
else
@ -359,6 +372,18 @@
echo (" />");
}
}
else if ($json["widget"] == "checkbox")
{
if ($json["enabled"] === false)
{
echo ("<span data-ecid=\"" . $json["ecid"] . "\">" . $json["value"] . "</span>");
}
else
{
echo ("<input id=\"ec_" . $fqecid . "\" name=\"ec_" . $fqecid . "\" type=\"checkbox\" value=\"" . $json["value"] . "\"");
echo (" />");
}
}
else if ($json["widget"] == "obscuredText")
{
echo ("<input id=\"ec_" . $fqecid . "\" name=\"ec_" . $fqecid . "\" type=\"password\" value=\"" . $json["value"] . "\" />");
@ -366,6 +391,7 @@
else if ($json["widget"] == "monikerList")
{
$adw = new InstanceBrowser();
$adw->Name = "ec_" . $fqecid;
$adw->Attributes[] = new WebControlAttribute("data-ecid", $json["ecid"]);
if (isset($json["enabled"]) && $json["enabled"] == false)
{

View File

@ -43,6 +43,7 @@
// $renderer = new HTMLRenderer($context);
$renderer = new HTMLRenderer2($context);
$renderer->CodeBehindFileName = "HomePage";
$renderer->IsPostback = $this->Page->IsPostback;
if ($this->Page->IsPostback)
{

View File

@ -40,14 +40,19 @@
{
$htmlRenderer = new HTMLRenderer($ctx);
}
$htmlRenderer->CodeBehindFileName = "InstancePage";
$instkey = InstanceKey::parse($this->Page->GetPathVariableValue("instid"));
$castkey = InstanceKey::parse($this->Page->GetPathVariableValue("castinstid"));
echo ("@ getInstanceByKey<br />");
$inst = $oms->getInstanceByKey($instkey);
echo ("@ getResponse<br />");
$json = $oms->getResponse($inst, $inst);
// print_r($json);
echo ("@ renderResponse<br />");
print_r($json);
$htmlRenderer->renderResponse($json["value"]);
return;

View File

@ -130,23 +130,24 @@
{
echo (" - instance: '" . $this->zqGetClassName($ir) . "'\n");
}
echo (" name: '" . $ir->Text . "'");
//$attrs = $oms->getRelatedInstances($ir, KnownRelationshipGuids::Class__has__Attribute);
$attrs = $oms->getAttributes($ir);
if (count($attrs) > 0)
{
echo (" - attributes:\n");
echo (" attributes:\n");
foreach ($attrs as $attr)
{
echo (" - instance: '" . $attr->GlobalIdentifier . "'\n");
echo (" - value: '" . $oms->getAttributeValue($ir, $attr) . "'\n");
echo (" value: '" . $oms->getAttributeValue($ir, $attr) . "'\n");
}
}
$rels = $oms->getRelationships($ir);
if (count($rels) > 0)
{
echo (" - relationships:\n");
echo (" relationships:\n");
foreach ($rels as $rel)
{
$gid = $rel->GlobalIdentifier->__toString();
@ -168,7 +169,7 @@
$iid = "&" . $this->EntityDefinitions2[$targ->GlobalIdentifier->__toStringFormat(false, "", "")] . ";";
}
echo (" = instance: '" . $iid . "'\n");
echo (" - instance: '" . $iid . "'\n");
}
}
}
@ -177,13 +178,13 @@
$defaultTask = $oms->getRelatedInstance($ir, KnownRelationshipGuids::Class__has_default__Task);
if ($defaultTask !== null)
{
echo (" - defaultTask: '" . $defaultTask->GlobalIdentifier . "'\n");
echo (" defaultTask: '" . $defaultTask->GlobalIdentifier . "'\n");
}
$relTasks = $oms->getRelatedINstances($ir, KnownRelationshipGuids::Class__has_related__Task);
if (count($relTasks) > 0)
{
echo (" - relatedTasks:\n");
echo (" relatedTasks:\n");
foreach ($relTasks as $relTask)
{
echo (" - instance: '" . $relTask->GlobalIdentifier . "'\n");
@ -203,7 +204,7 @@
$ct = count($instances);
for ($i = 0; $i < $ct; $i++)
{
print("{ \"name\": \"mocha:inst" . $i . "\", \"title\": \"" . $oms->getInstanceText($instances[$i]) . "\", \"type\": \"class\", \"instanceId\": \"" . $instances[$i]->InstanceKey . "\" }");
print("{ \"name\": \"mocha:inst" . $i . "\", \"title\": \"" . $instances[$i]->Text . "\", \"type\": \"class\", \"instanceId\": \"" . $instances[$i]->InstanceKey . "\" }");
if ($i < $ct - 1)
{
print(", ");
@ -212,7 +213,7 @@
print("] }");
print("] }");
return;
exit();
}
}
}

View File

@ -39,16 +39,21 @@
$taskRenderer = new HTMLRenderer($context);
$taskRenderer->TargetInstance = $instance;
$taskRenderer->IsPostback = $this->Page->IsPostback;
if ($this->Page->IsPostback)
{
$taskRenderer->processPostback(element: $initiatingElement);
}
*/
$context = new OmsContext();
$taskRenderer = new HTMLRenderer2($context);
$taskRenderer->renderTask($relatedTaskInstance, $instance);
$taskRenderer->CodeBehindFileName = "RelatedTaskPage";
$taskRenderer->IsPostback = $this->Page->IsPostback;
if ($this->Page->IsPostback)
{
$initiatingElement = $oms->getRelatedInstance($relatedTaskInstance, KnownRelationshipGuids::Task__has_initiating__Element);
$taskRenderer->processPostback(element: $initiatingElement);
}
else
{
$taskRenderer->renderTask($relatedTaskInstance, $instance);
}
exit();
}

View File

@ -27,7 +27,7 @@
$initiatingElement = $oms->getRelatedInstance($taskInstance, KnownRelationshipGuids::Task__has_initiating__Element);
$context = new OmsContext();
if ($_GET["legacy"] == "1")
if (isset($_GET["legacy"]) && $_GET["legacy"] == "1")
{
$taskRenderer = new HTMLRenderer($context);
}
@ -37,11 +37,15 @@
}
//$taskRenderer->TargetInstance = $instance;
$taskRenderer->IsPostback = $this->Page->IsPostback;
$taskRenderer->CodeBehindFileName = "TaskPage";
if ($this->Page->IsPostback)
{
$taskRenderer->processPostback(element: $initiatingElement);
}
$taskRenderer->renderTask($taskInstance);
else
{
$taskRenderer->renderTask($taskInstance);
}
exit();
}

2
phast

@ -1 +1 @@
Subproject commit 2374310056c7ea727839cfea04f7bdf2df34760b
Subproject commit ac7561660f08060b4685e10f08e7dd6ab84f96f2