Merge branch 'update1'

This commit is contained in:
Michael Becker 2024-05-20 23:49:07 -04:00
commit f466be1eb4
10 changed files with 589 additions and 97 deletions

View File

@ -50,6 +50,7 @@ class KnownClassGuids
const MethodBinding = "CB36098EB9BF4D2287FA4186EC632C89"; const MethodBinding = "CB36098EB9BF4D2287FA4186EC632C89";
const ReturnAttributeMethodBinding = "30FB6BA62BBB41D2B91A709C00A07790"; const ReturnAttributeMethodBinding = "30FB6BA62BBB41D2B91A709C00A07790";
const ReturnInstanceSetMethodBinding = "AADC20F97559429BAEF097E059295C76"; const ReturnInstanceSetMethodBinding = "AADC20F97559429BAEF097E059295C76";
const ProcessUpdatesMethodBinding = "{a7eb8676-2e47-4981-96a7-f20158660d26}";
const Executable = "6A1F66F78EA643D1B2AF198F63B84710"; const Executable = "6A1F66F78EA643D1B2AF198F63B84710";
const ExecutableReturningAttribute = "50b2db7a36234be4b40d98fab89d3ff5"; const ExecutableReturningAttribute = "50b2db7a36234be4b40d98fab89d3ff5";
@ -151,6 +152,9 @@ class KnownClassGuids
const SelectFromInstanceSetMethod = "{130637B4-17A7-4394-8F4D-E83A79114E6C}"; const SelectFromInstanceSetMethod = "{130637B4-17A7-4394-8F4D-E83A79114E6C}";
const ConditionalSelectFromInstanceSetMethod = "{ffea8e52-06e5-4e95-8c40-da3ba54ce95f}"; const ConditionalSelectFromInstanceSetMethod = "{ffea8e52-06e5-4e95-8c40-da3ba54ce95f}";
const AssignRelationshipMethod = "{3791fc36-3c5c-4ba0-83f4-70c050fa33a7}";
const AssignAttributeMethod = "{3312A789-3B7A-4478-B329-4FF781504F9C}";
const BinarySwitchLayout = "{248d781d-3d2f-4377-acc4-38112cf2f9d1}"; const BinarySwitchLayout = "{248d781d-3d2f-4377-acc4-38112cf2f9d1}";
const RotarySwitchLayout = "{ea52446a-6332-49f7-baa9-4c78bea4faab}"; const RotarySwitchLayout = "{ea52446a-6332-49f7-baa9-4c78bea4faab}";
} }

View File

@ -334,6 +334,9 @@ class KnownRelationshipGuids
const Assign_Attribute_Method__uses__Executable_returning_Attribute = "{9313f96e-58af-416f-852e-ef83725057fc}"; const Assign_Attribute_Method__uses__Executable_returning_Attribute = "{9313f96e-58af-416f-852e-ef83725057fc}";
const Assign_Attribute_Method__assigns__Attribute = "{74061875-8a27-403b-9456-02e52cfd13b2}"; const Assign_Attribute_Method__assigns__Attribute = "{74061875-8a27-403b-9456-02e52cfd13b2}";
const Assign_Relationship_Method__assigns__Relationship = "{cd689fdf-2754-458f-be1e-d4ea98c37335}";
const Assign_Relationship_Method__uses__Executable_returning_Instance_Set = "{e5615121-0a72-408b-8ae4-f880841e74ba}";
const Get_Instances_Method__returns__Work_Set = "{7d0f93b1-8c93-464e-a44d-d674f910b589}"; const Get_Instances_Method__returns__Work_Set = "{7d0f93b1-8c93-464e-a44d-d674f910b589}";
const Get_Instances_Method__selects_instances_of__Class = "{c0b85d90-de8c-44c2-9420-c5e724ccdf2c}"; const Get_Instances_Method__selects_instances_of__Class = "{c0b85d90-de8c-44c2-9420-c5e724ccdf2c}";

View File

@ -658,7 +658,8 @@
$retval = $methodImplementation->execute($this, $context, $inst, $parms); // $this->executeMethod($context, $inst, $parms); $retval = $methodImplementation->execute($this, $context, $inst, $parms); // $this->executeMethod($context, $inst, $parms);
} }
else if ($instParent->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::ReturnAttributeMethodBinding)) else if ($instParent->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::ReturnAttributeMethodBinding))
|| ($instParent->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::ReturnInstanceSetMethodBinding)))) || ($instParent->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::ReturnInstanceSetMethodBinding)))
|| ($instParent->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::ProcessUpdatesMethodBinding))))
{ {
$methodBindingExecutesMethod = $this->getRelatedInstance($inst, KnownRelationshipGuids::Method_Binding__executes__Method); $methodBindingExecutesMethod = $this->getRelatedInstance($inst, KnownRelationshipGuids::Method_Binding__executes__Method);
if ($methodBindingExecutesMethod === null) if ($methodBindingExecutesMethod === null)

View File

@ -17,6 +17,8 @@
{ {
protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms) protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms)
{ {
echo ("<!-- exec system routine method, '" . $method->GlobalIdentifier->__toString() . "' -->");
$instSystemRoutine = $oms->getRelatedInstance($method, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Attribute_by_System_Routine_Method__uses__System_Attribute_Routine)); $instSystemRoutine = $oms->getRelatedInstance($method, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Attribute_by_System_Routine_Method__uses__System_Attribute_Routine));
$returnsWorkData = $oms->getRelatedInstance($method, KnownRelationshipGuids::Get_Attribute_by_System_Routine_Method__returns__Attribute); $returnsWorkData = $oms->getRelatedInstance($method, KnownRelationshipGuids::Get_Attribute_by_System_Routine_Method__returns__Attribute);
$singular = false; // $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular)); $singular = false; // $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular));
@ -27,13 +29,25 @@
( (
"Method" => $method "Method" => $method
)); ));
echo ("<!-- system routine not set -->");
return null; return null;
} }
if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemAttributeRoutine_GetGlobalIdentifier))) if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemAttributeRoutine_GetGlobalIdentifier)))
{ {
// get instance text // get instance text
$context->setWorkData($returnsWorkData, $context->getWorkData(KnownClassGuids::Instance)->GlobalIdentifier->__toString()); $inst = $context->getWorkData(KnownInstanceGuids::WorkSet__RelatedInstance);
if ($inst === null)
{
echo("<!-- work data instance is null -->");
}
else
{
$gid = $inst->GlobalIdentifier->__toStringFormat(false, "", "");
echo ("<!-- setting WorkData '" . $returnsWorkData->GlobalIdentifier->__toString() . "' to '" . $gid . "' -->");
echo ("<!-- Instance is '" . $inst->GlobalIdentifier->__toString() . "' -->");
$context->setWorkData($returnsWorkData, $gid);
}
} }
else if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemAttributeRoutine_GetInstanceText))) else if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemAttributeRoutine_GetInstanceText)))
{ {

View File

@ -3,6 +3,7 @@
use Mocha\Core\InstanceReference; use Mocha\Core\InstanceReference;
use Mocha\Core\KnownAttributeGuids; use Mocha\Core\KnownAttributeGuids;
use Mocha\Core\KnownClassGuids;
use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\KnownRelationshipGuids;
use Mocha\Core\OmsContext; use Mocha\Core\OmsContext;
use Mocha\Oms\Oms; use Mocha\Oms\Oms;
@ -14,6 +15,7 @@
protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms) protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms)
{ {
echo("executing PRU...");
$classForPRU = $oms->getRelatedInstance($method, KnownRelationshipGuids::Process_Related_Updates_Method__processes_for__Class); $classForPRU = $oms->getRelatedInstance($method, KnownRelationshipGuids::Process_Related_Updates_Method__processes_for__Class);
if ($classForPRU === null) if ($classForPRU === null)
{ {
@ -27,37 +29,83 @@
{ {
} }
//!HACK! // //!HACK!
$instForPRU = $oms->getNthInstanceOf($classForPRU, 1); // $instForPRU = $oms->getNthInstanceOf($classForPRU, 1);
echo ("class for PRU: " . $classForPRU->InstanceKey);
$instForPRU = $context->getWorkData($classForPRU);
if ($instForPRU !== null) if ($instForPRU !== null)
{ {
//echo("current work data for '" . $instForPRU->GlobalIdentifier . "' = '" . $context->getWorkData($instForPRU->GlobalIdentifier->__toString()) . "'"); echo("current work data for '" . $classForPRU->InstanceKey . "' = '" . $instForPRU->InstanceKey . "'");
}
else
{
echo ("inst for PRU class [" . $classForPRU->InstanceKey . "] is null");
} }
$instExecutablesForPUMB = $oms->getRelatedInstances($method, KnownRelationshipGuids::Process_Related_Updates_Method__uses__Executable_for_PUMB); $instExecutablesForPUMB = $oms->getRelatedInstances($method, KnownRelationshipGuids::Process_Related_Updates_Method__uses__Executable_for_PUMB);
foreach ($instExecutablesForPUMB as $instExecutableForPUMB) foreach ($instExecutablesForPUMB as $instExecutableForPUMB)
{ {
if ($instExecutableForPUMB !== null) echo ("pumb exec: " . $instExecutableForPUMB->GlobalIdentifier . "<br />");
if ($oms->is_a($instExecutableForPUMB, KnownClassGuids::AssignAttributeMethod))
{ {
$assignsAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__assigns__Attribute); $assignsAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__assigns__Attribute);
$usesExecutableReturningAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__uses__Executable_returning_Attribute); $usesExecutableReturningAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__uses__Executable_returning_Attribute);
//$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute); //$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute);
//echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'"); echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'");
$value = $context->getWorkData($usesExecutableReturningAttribute->GlobalIdentifier->__toString()); $value = $context->getWorkData($usesExecutableReturningAttribute);
if ($value instanceof InstanceReference) if ($value instanceof InstanceReference)
{ {
//echo ("the value from work data is ##IS#'" . $value->GlobalIdentifier . "'##"); echo ("the value from work data is ##IS#'" . $value->GlobalIdentifier . "'##");
} }
else else
{ {
echo ("the value from work data is '" . $value . "'");
$oms->setAttributeValue($instForPRU, $assignsAttribute, $value); $oms->setAttributeValue($instForPRU, $assignsAttribute, $value);
} }
} }
else if ($oms->is_a($instExecutableForPUMB, KnownClassGuids::AssignRelationshipMethod))
{
echo ("execute method: " . $instExecutableForPUMB->GlobalIdentifier);
$forClass = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Method__for__Class);
echo ("for class: " . $forClass->InstanceKey);
$forClassInstance = $context->getWorkData($forClass);
$assignsRelationship = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Relationship_Method__assigns__Relationship);
$usesExecutableReturningInstanceSet = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Relationship_Method__uses__Executable_returning_Instance_Set);
//$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute);
//echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'");
echo("assigns rel: " . $assignsRelationship);
if ($assignsRelationship instanceof InstanceReference)
{
$value = $context->getWorkData($usesExecutableReturningInstanceSet);
echo ("assign val: " . $value);
if ($value instanceof InstanceReference)
{
echo ("assign relationship: " . $forClassInstance->InstanceKey . " . " . $assignsRelationship->InstanceKey . " = " . $value->InstanceKey);
}
else
{
//echo( "the value from work data [" . $usesExecutableReturningInstanceSet->InstanceKey . "] is '" . $value . "'");
}
$singular = $oms->getAttributeValue($assignsRelationship, KnownAttributeGuids::Singular, false);
if ($singular)
{
//!HACK! but this breaks multi instances in other places, so no good...
$oms->removeRelationshipInstances($forClassInstance, $assignsRelationship);
}
$oms->assignRelationship($forClassInstance, $assignsRelationship, $value);
}
}
else else
{ {
echo ("executable for PUMB is null"); echo ("unknown class for executable for PUMB");
} }
} }
} }

View File

@ -134,6 +134,10 @@
$displayOptions = $oms->getRelatedInstances($elementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option); $displayOptions = $oms->getRelatedInstances($elementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option);
$this->renderRichTextAttributeEC($parentElementContents, $elementContent, $ecInst, $value); $this->renderRichTextAttributeEC($parentElementContents, $elementContent, $ecInst, $value);
}); });
$this->registerEditor($oms->getInstanceByGlobalIdentifier(KnownClassGuids::MethodBinding), $genericViewFunc, function($oms, $parentElementContents, $elementContent, $ecInst, $value)
{
});
} }
/** /**
@ -168,7 +172,7 @@
return \implode('', $pieces); return \implode('', $pieces);
} }
public function getElementContentId(array $parentElementContents, ?InstanceReference $elementContent) public function getElementContentId(array $parentElementContents, ?InstanceReference $elementContent, $index = null)
{ {
$fullyQualifiedECID = ""; $fullyQualifiedECID = "";
$count = count($parentElementContents); $count = count($parentElementContents);
@ -194,8 +198,13 @@
if ($count > 0) if ($count > 0)
{ {
$fullyQualifiedECID = $fullyQualifiedECID . ":"; $fullyQualifiedECID = $fullyQualifiedECID . ":";
} }
$fullyQualifiedECID .= $elementContent->InstanceKey->__toString(); $idx = "";
if (is_int($index))
{
$idx = $index . ":";
}
$fullyQualifiedECID .= $idx . $elementContent->InstanceKey->__toString();
} }
return $fullyQualifiedECID; return $fullyQualifiedECID;
} }
@ -264,6 +273,40 @@
$this->renderEndTag("div"); $this->renderEndTag("div");
} }
public function renderTaskStep2(&$parentElementContents, InstanceReference $usesElement)
{
/**
* @var MySQLDatabaseOms
*/
$oms = mocha_get_oms();
$title = $oms->getInstanceText($usesElement);
$label = $oms->getAttributeValue($usesElement, KnownAttributeGuids::Label);
if ($label !== null)
{
$title = $label;
}
$workDataRelatedInstance = $this->Context->getWorkData(KnownInstanceGuids::WorkSet__RelatedInstance);
if ($workDataRelatedInstance !== null)
{
$this->TargetInstance = $oms->getInstanceByKey(InstanceKey::Parse($workDataRelatedInstance));
}
$this->renderBeginPage();
echo ("<input type=\"hidden\" name=\"task_step\" value=\"2\" />");
echo ("<input type=\"hidden\" name=\"target_inst_id\" value=\"" . $this->TargetInstance->InstanceKey . "\" />");
$this->renderPageHeader($title, $this->TargetInstance);
echo ("work data!");
print_r($this->Context->workData);
$this->renderBeginTag("div", [ ], [ "uwt-page-content" ]);
$this->renderElement($parentElementContents, $usesElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ]);
$this->renderEndTag("div");
$this->renderEndForm();
$this->renderEndPage();
}
public function renderTask(InstanceReference $task, ?InstanceReference $relatedInstance = null) public function renderTask(InstanceReference $task, ?InstanceReference $relatedInstance = null)
{ {
/** /**
@ -272,6 +315,7 @@
$oms = mocha_get_oms(); $oms = mocha_get_oms();
$taskName = $oms->getAttributeValue($task, KnownAttributeGuids::Name); $taskName = $oms->getAttributeValue($task, KnownAttributeGuids::Name);
array_push($this->Context->CallStack, $task);
$this->Context->setWorkData(KnownInstanceGuids::WorkSet__TaskRelatedInstance, $relatedInstance); $this->Context->setWorkData(KnownInstanceGuids::WorkSet__TaskRelatedInstance, $relatedInstance);
$this->renderBeginPage($taskName); $this->renderBeginPage($taskName);
@ -297,7 +341,7 @@
$this->Context->setWorkData($riParentClass, $relatedInstance); $this->Context->setWorkData($riParentClass, $relatedInstance);
} }
} }
echo ("<!-- task: " . $task->InstanceKey . " {" . $task->GlobalIdentifier . "} -->"); echo ("<!-- task: " . $task->InstanceKey . " " . $task->GlobalIdentifier . "\ncall stack trace: " . $oms->getStackTrace($this->Context->CallStack) . " -->");
$parentClass = $oms->getParentClass($task); $parentClass = $oms->getParentClass($task);
$allElementsAreReadonly = true; $allElementsAreReadonly = true;
@ -407,13 +451,15 @@ EOF
$this->renderEndPage(); $this->renderEndPage();
} }
private function updateWorkDataWithElementContents(array $parentElementContents, InstanceReference $element) private function updateWorkDataWithElementContents(array $parentElementContents, InstanceReference $element, $singular = true, $i = 0)
{ {
/** /**
* @var MySQLDatabaseOms * @var MySQLDatabaseOms
*/ */
$oms = mocha_get_oms(); $oms = mocha_get_oms();
//print_r($_POST);die();
if ($element !== null) if ($element !== null)
{ {
$elementContents = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content); $elementContents = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content);
@ -430,12 +476,15 @@ EOF
} }
else else
{ {
$ecid = $this->getElementContentId($parentElementContents, $ec); $ecid = $this->getElementContentId($parentElementContents, $ec, ($singular ? null : $i));
if (isset($_POST["ec_" . $ecid])) if (isset($_POST["ec_" . $ecid]))
{ {
$value = $_POST["ec_" . $ecid]; $value = $_POST["ec_" . $ecid];
$value_str = $value;
//!FIXME: refactor out the casting of POST values to actual instances or primitive literals //!FIXME: refactor out the casting of POST values to actual instances or primitive literals
if ($oms->is_a($ecInst, KnownClassGuids::Clasz)) if ($oms->is_a($ecInst, KnownClassGuids::Clasz)
|| $oms->is_a($ecInst, KnownClassGuids::WorkSet)
|| $oms->is_a($ecInst, KnownClassGuids::Relationship))
{ {
if ($value == "") if ($value == "")
{ {
@ -449,10 +498,18 @@ EOF
echo ("invalid ik: " . $value); echo ("invalid ik: " . $value);
} }
$value = $oms->getInstanceByKey($ik); $value = $oms->getInstanceByKey($ik);
$value_str = "`" . $ik . "`";
} }
} }
echo ("updateWorkDataWithElementContents: setting work data `" . $ecInst->InstanceKey . "` from EC `" . $ecid . "` to value '" . $value_str . "'<br />");
$this->Context->setWorkData($ecInst, $value); $this->Context->setWorkData($ecInst, $value);
} }
else
{
echo ("updateWorkDataWithElementContents: not setting work data `" . $ecInst->InstanceKey . "` from EC `" . $ecid . "`, not present in POST<br />");
}
} }
} }
} }
@ -587,8 +644,69 @@ EOF
$pru = $oms->getRelatedInstance($element, KnownRelationshipGuids::Element__processed_by__Process_Related_Updates_Method); $pru = $oms->getRelatedInstance($element, KnownRelationshipGuids::Element__processed_by__Process_Related_Updates_Method);
if ($pru !== null) if ($pru !== null)
{ {
echo ("<!-- executing pru for " . $element->InstanceKey . " -->"); //? BEGIN: stolen from default implementation of PRU
$oms->execute($this->Context, $pru);
//!FIXME: in a sequence task, the Initiating Element may just be a stepping stone
//! on the way to the next step. In this case we don't really want to save
//! any data, just store it in memory (work data) to be used by the next step...
$elementProcessedByCT = $oms->getRelatedInstance($element, KnownRelationshipGuids::Element__processed_by__Control_Transaction_Method);
if ($elementProcessedByCT !== null)
{
}
$relatedECs = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content);
$classParent = null;
if (count($relatedECs) > 0)
{
$classParent = $oms->getRelatedInstance($relatedECs[0], KnownRelationshipGuids::Element_Content__has__Instance);
echo ("class parent : " . $classParent->InstanceKey);
}
if ($parentElementContent !== null)
{
$parentECFullyQualifiedECID = $this->getElementContentId($parentElementContents, null);
$ecid_count = "ec_" . $parentECFullyQualifiedECID . "_count";
if (isset($_POST[$ecid_count]))
{
// nonsingular
if ($this->DebugMode)
{
echo ("paren ec: " . $parentElementContent);
}
$subelementInstances = $this->getSubelementInstances($parentElementContent);
$count = $_POST[$ecid_count];
if ($count != count($subelementInstances))
{
echo ("WARN: count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); //die();
}
for ($i = 0; $i < $count; $i++)
{
$targetRelatedInstance = $subelementInstances[$i];
if ($i >= count($subelementInstances))
{
// we are creating a new instance of the class of the subelement (element content #0)
echo ("creating instance of " . $classParent->InstanceKey);
$targetRelatedInstance = $oms->createInstanceOf($classParent);
}
else
{
}
echo ("target rel inst: " . $targetRelatedInstance->InstanceKey);
$this->updateWorkDataWithElementContents($parentElementContents, $element, false, $i);
echo ("class parent: " . $classParent->InstanceKey . " = " . $targetRelatedInstance->InstanceKey . "<br />");
$this->Context->setWorkData($classParent, $targetRelatedInstance);
echo ("executing pru '" . $pru->GlobalIdentifier . "' for " . $element->InstanceKey);
$oms->execute($this->Context, $pru);
}
}
}
//? END: stolen from default implementation of PRU
return true; return true;
} }
else else
@ -606,9 +724,19 @@ EOF
$relatedECs = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content); $relatedECs = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content);
$classParent = null;
if (count($relatedECs) > 0)
{
$classParent = $oms->getRelatedInstance($relatedECs[0], KnownRelationshipGuids::Element_Content__has__Instance);
echo ("class parent : " . $classParent->InstanceKey);
}
if ($parentElementContent !== null) if ($parentElementContent !== null)
{ {
$ecid_count = "ec_" . $parentElementContent->InstanceKey . "_count"; $parentECFullyQualifiedECID = $this->getElementContentId($parentElementContents, null);
$ecid_count = "ec_" . $parentECFullyQualifiedECID . "_count";
// $ecid_count = "ec_" . $parentElementContent->InstanceKey . "_count";
if (isset($_POST[$ecid_count])) if (isset($_POST[$ecid_count]))
{ {
// nonsingular // nonsingular
@ -621,13 +749,22 @@ EOF
if ($count != count($subelementInstances)) if ($count != count($subelementInstances))
{ {
echo ("ERR count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); die(); echo ("WARN: count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); //die();
} }
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
$targetRelatedInstance = $subelementInstances[$i]; $targetRelatedInstance = $subelementInstances[$i];
// echo ("target rel inst: " . $targetRelatedInstance->InstanceKey); if ($i >= count($subelementInstances))
{
// we are creating a new instance of the class of the subelement (element content #0)
echo ("creating instance of " . $classParent->InstanceKey);
$targetRelatedInstance = $oms->createInstanceOf($classParent);
}
else
{
}
echo ("target rel inst: " . $targetRelatedInstance->InstanceKey);
array_push($parentElementContents, $i); array_push($parentElementContents, $i);
$relatedECCount = count($relatedECs); $relatedECCount = count($relatedECs);
@ -657,7 +794,7 @@ EOF
if ($this->DebugMode) if ($this->DebugMode)
{ {
echo ("update EC: " . $relatedECInst->InstanceKey . " = '" . $value . "'<br/>"); echo ("update EC `" . $fullyQualifiedECID . "`: " . $relatedECInst->InstanceKey . " = '" . $value . "'<br/>");
} }
$this->updateElementContentInstance($parentElementContents, $targetRelatedInstance, $relatedECInst, $value); $this->updateElementContentInstance($parentElementContents, $targetRelatedInstance, $relatedECInst, $value);
array_pop($parentElementContents); array_pop($parentElementContents);
@ -787,6 +924,7 @@ EOF
$processedByControlTransaction = $oms->getRelatedInstance($element, KnownRelationshipGuids::Element__processed_by__Control_Transaction_Method); $processedByControlTransaction = $oms->getRelatedInstance($element, KnownRelationshipGuids::Element__processed_by__Control_Transaction_Method);
if ($processedByControlTransaction !== null) if ($processedByControlTransaction !== null)
{ {
echo ("procesed by CT: " . $processedByControlTransaction->InstanceKey);
if ($_POST["task_step"] == "1") if ($_POST["task_step"] == "1")
{ {
// selection step // selection step
@ -810,20 +948,13 @@ EOF
$ecInst0 = $oms->getRelatedInstance($usesElementContents[0], KnownRelationshipGuids::Element_Content__has__Instance); $ecInst0 = $oms->getRelatedInstance($usesElementContents[0], KnownRelationshipGuids::Element_Content__has__Instance);
$this->TargetInstance = $this->Context->getWorkData($ecInst0); $this->TargetInstance = $this->Context->getWorkData($ecInst0);
$this->renderBeginPage(); $this->renderTaskStep2($parentElementContents, $usesElement);
echo ("<input type=\"hidden\" name=\"task_step\" value=\"2\" />");
echo ("<input type=\"hidden\" name=\"target_inst_id\" value=\"" . $this->TargetInstance->InstanceKey . "\" />");
$this->renderPageHeader($oms->getInstanceText($usesElement), $this->TargetInstance);
$this->renderBeginTag("div", [ ], [ "uwt-page-content" ]);
$this->renderElement($parentElementContents, $usesElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ]);
$this->renderEndTag("div");
$this->renderEndForm();
$this->renderEndPage();
} }
exit(); exit();
} }
else if ($_POST["task_step"] == "2") else if ($_POST["task_step"] == "2")
{ {
echo ("task step 2<br />");
// edit step // edit step
$usesBRMB = $oms->getRelatedInstance($processedByControlTransaction, KnownRelationshipGuids::Control_Transaction_Method__uses__Build_Response_Method_Binding); $usesBRMB = $oms->getRelatedInstance($processedByControlTransaction, KnownRelationshipGuids::Control_Transaction_Method__uses__Build_Response_Method_Binding);
$executesMethod = $oms->getRelatedInstance($usesBRMB, KnownRelationshipGuids::Method_Binding__executes__Method); $executesMethod = $oms->getRelatedInstance($usesBRMB, KnownRelationshipGuids::Method_Binding__executes__Method);
@ -845,7 +976,7 @@ EOF
if (isset($_POST["target_inst_id"])) if (isset($_POST["target_inst_id"]))
{ {
$targetInstance = $oms->getInstanceByKey(InstanceKey::Parse($_POST["target_inst_id"])); $targetInstance = $oms->getInstanceByKey(InstanceKey::Parse($_POST["target_inst_id"]));
$this->TargetInstance = $oms->getInstanceByKey(InstanceKey::Parse($_POST["target_inst_id"])); $this->TargetInstance = $targetInstance;
} }
} }
} }
@ -1035,6 +1166,16 @@ EOF
// Executable returning Attribute // Executable returning Attribute
else if ($oms->is_a($ecInst, KnownClassGuids::ExecutableReturningAttribute)) else if ($oms->is_a($ecInst, KnownClassGuids::ExecutableReturningAttribute))
{ {
if (!$oms->is_a($ecInst, KnownClassGuids::Attribute))
{
$attr = $oms->executeReturningAttribute($this->Context, $ecInst);
if ($attr !== null)
{
// $value = $this->Context->getWorkData($attr);
return ($attr == "");
}
return true;
}
return $oms->getAttributeValue($relatedInstance, $ecInst) == "" && $oms->getAttributeValue($ecInst, KnownAttributeGuids::Value) == ""; return $oms->getAttributeValue($relatedInstance, $ecInst) == "" && $oms->getAttributeValue($ecInst, KnownAttributeGuids::Value) == "";
} }
// Executable returning Attribute // Executable returning Attribute
@ -1398,7 +1539,16 @@ EOF
} }
else else
{ {
if ($this->DebugMode)
{
echo ("related instance: " . $relatedInstance->InstanceKey);
echo ("<br />ec inst: " . $ecInst->InstanceKey);
}
$value = $oms->getRelatedInstances($relatedInstance, $ecInst); $value = $oms->getRelatedInstances($relatedInstance, $ecInst);
if ($this->DebugMode)
{
echo ("<br />value: " . $oms->getInstanceKeysString($value));
}
} }
$validClasses = [ $oms->getRelatedInstance($ecInst, KnownRelationshipGuids::Relationship__has_destination__Class) ]; $validClasses = [ $oms->getRelatedInstance($ecInst, KnownRelationshipGuids::Relationship__has_destination__Class) ];
@ -1437,11 +1587,13 @@ EOF
// Executable returning Attribute // Executable returning Attribute
else if ($oms->is_a($ecInst, KnownClassGuids::ExecutableReturningAttribute)) else if ($oms->is_a($ecInst, KnownClassGuids::ExecutableReturningAttribute))
{ {
echo ("<!-- is a Executable returning Attribute -->");
$this->renderExecutableReturningAttribute($parentElementContents, $elementContent, $ecInst, $relatedInstance, $renderNotEnterable); $this->renderExecutableReturningAttribute($parentElementContents, $elementContent, $ecInst, $relatedInstance, $renderNotEnterable);
} }
// Executable returning Attribute // Executable returning Attribute
else if ($oms->is_a($ecInst, KnownClassGuids::ReturnAttributeMethodBinding)) else if ($oms->is_a($ecInst, KnownClassGuids::ReturnAttributeMethodBinding))
{ {
echo ("<!-- is a RAMB -->");
// I *THINK* Return Attribute Method Bindings aren't supposed to return // I *THINK* Return Attribute Method Bindings aren't supposed to return
// just strings, they're supposed to actually return *attributes* that // just strings, they're supposed to actually return *attributes* that
// can then be edited in the Element Content. // can then be edited in the Element Content.
@ -1455,6 +1607,40 @@ EOF
echo ("ERR: attribute ( from method " . $ecInst->InstanceKey . " ) is null"); echo ("ERR: attribute ( from method " . $ecInst->InstanceKey . " ) is null");
} }
} }
else if ($oms->is_a($ecInst, KnownClassGuids::WorkSet))
{
$targetInstance = $ecInst;
if ($this->Context !== null)
{
$targetInstance = $this->Context->getWorkData($ecInst);
}
$adw = new InstanceBrowser();
if ($title !== null)
{
$adw->Title = $title;
}
$adw->Name = "ec_" . $fullyQualifiedECID;
$adw->Attributes[] = new WebControlAttribute("data-ecid", $elementContent->InstanceKey);
$adw->Editable = !($renderNotEnterable || $oms->instanceSetContains($displayOptions, $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__NotEnterable)));
//$adw->ValidClasses[] = $;
$insts = $this->Context->getWorkData($ecInst);
$singular = !is_array($insts); // $oms->getAttributeValue($ecInst, KnownAttributeGuids::Singular, false);
if ($insts !== null)
{
if ($singular)
{
$adw->SelectedInstances = [ $insts ];
}
else
{
$adw->SelectedInstances = $insts;
}
}
$adw->Title = $title;
$adw->Render();
}
else if ($oms->is_a($ecInst, KnownClassGuids::Clasz)) else if ($oms->is_a($ecInst, KnownClassGuids::Clasz))
{ {
$targetInstance = $ecInst; $targetInstance = $ecInst;
@ -1555,34 +1741,54 @@ EOF
$displayOptions = $oms->getRelatedInstances($elementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option); $displayOptions = $oms->getRelatedInstances($elementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option);
// fill in the value from the target instance // fill in the value from the target instance
$targetInstance = $relatedInstance; $value = null;
if ($targetInstance === null) if (!$oms->is_a($ecInst, KnownClassGuids::Attribute))
{ {
$targetInstance = $this->TargetInstance; $attr = $oms->executeReturningAttribute($this->Context, $ecInst);
if ($attr !== null)
$firstElementContent = $oms->getNthRelatedInstance($this->__renderingElement, KnownRelationshipGuids::Element__has__Element_Content, 0); {
$firstElementContentInst = $oms->getRelatedInstance($firstElementContent, KnownRelationshipGuids::Element_Content__has__Instance); echo ("<!-- attr is '" . $attr . "' -->");
// $value = $this->Context->getWorkData($attr);
$targetInstance = $oms->getNthInstanceOf($firstElementContentInst, 1); $value = $attr;
} }
if ($targetInstance !== null) else
{ {
$value = $oms->getAttributeValue($targetInstance, $ecInst); echo ("<!-- executeReturningAttribute returned NULL attribute -->");
}
} }
if ($value === null) if ($value === null)
{ {
$value = $oms->getAttributeValue($ecInst, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Value)); $targetInstance = $relatedInstance;
} if ($targetInstance === null)
{
$targetInstance = $this->TargetInstance;
$ecid = "ec_" . $this->getElementContentId($parentElementContents, $elementContent); $firstElementContent = $oms->getNthRelatedInstance($this->__renderingElement, KnownRelationshipGuids::Element__has__Element_Content, 0);
if ($this->IsPostback && isset($_POST[$ecid])) $firstElementContentInst = $oms->getRelatedInstance($firstElementContent, KnownRelationshipGuids::Element_Content__has__Instance);
{
// fill in the value from the postback $targetInstance = $oms->getNthInstanceOf($firstElementContentInst, 1);
$value = $_POST[$ecid]; }
if ($targetInstance !== null)
{
$value = $oms->getAttributeValue($targetInstance, $ecInst);
}
if ($value === null)
{
$value = $oms->getAttributeValue($ecInst, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Value));
}
$ecid = "ec_" . $this->getElementContentId($parentElementContents, $elementContent);
if ($this->IsPostback && isset($_POST[$ecid]))
{
// fill in the value from the postback
$value = $_POST[$ecid];
}
} }
$editor = $this->getEditor($ecInst); $editor = $this->getEditor($ecInst);
if ($oms->instanceSetContains($displayOptions, $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__NotEnterable)) || $renderNotEnterable) if ($oms->instanceSetContains($displayOptions, $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__NotEnterable)) || $renderNotEnterable)
{ {
if ($editor !== null) if ($editor !== null)
@ -1603,7 +1809,14 @@ EOF
{ {
// $adw = new InstanceBrowser(array($rambAttribute)); // $adw = new InstanceBrowser(array($rambAttribute));
// $adw->Render(); // $adw->Render();
echo($context->getWorkData($attr)); if (is_string($attr))
{
echo($attr);
}
else
{
echo($context->getWorkData($attr));
}
} }
public function renderTextAttributeEC(array $parentElementContents, InstanceReference $ec, InstanceReference $inst, $password = false, $value = null) public function renderTextAttributeEC(array $parentElementContents, InstanceReference $ec, InstanceReference $inst, $password = false, $value = null)
@ -2201,10 +2414,6 @@ EOF
$contents = $oms->getRelatedInstances($element, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Element__has__Element_Content)); $contents = $oms->getRelatedInstances($element, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Element__has__Element_Content));
if (count($contents) > 0) if (count($contents) > 0)
{ {
if ($this->DebugMode)
{
echo ("contents is not empty .. ");
}
$ecInst0 = $oms->getRelatedInstance($contents[0], KnownRelationshipGuids::Element_Content__has__Instance); $ecInst0 = $oms->getRelatedInstance($contents[0], KnownRelationshipGuids::Element_Content__has__Instance);
if ($ecInst0 !== null) if ($ecInst0 !== null)
{ {
@ -2395,7 +2604,7 @@ EOF
$parentECDisplayOptions = $oms->getRelatedInstances($parentElementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option); $parentECDisplayOptions = $oms->getRelatedInstances($parentElementContent, KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option);
$listviewClasses = [ "uwt-listview", "mcx-element" ]; $listviewClasses = [ "uwt-listview", "mcx-element", "mcx-elementcontent" ];
if (!($renderingNotEnterable || $renderNotEnterable || $oms->instanceSetContains($parentECDisplayOptions, $oms->normalizeInstanceReference(KnownInstanceGuids::DisplayOption__NotEnterable)) || $oms->instanceSetContains($parentECDisplayOptions, $oms->normalizeInstanceReference(KnownInstanceGuids::DisplayOption__RowsNotEditable)))) if (!($renderingNotEnterable || $renderNotEnterable || $oms->instanceSetContains($parentECDisplayOptions, $oms->normalizeInstanceReference(KnownInstanceGuids::DisplayOption__NotEnterable)) || $oms->instanceSetContains($parentECDisplayOptions, $oms->normalizeInstanceReference(KnownInstanceGuids::DisplayOption__RowsNotEditable))))
{ {
$listviewClasses[] = "mcx-editable"; $listviewClasses[] = "mcx-editable";
@ -2417,7 +2626,7 @@ EOF
$mcx_classes[] = "mcx-empty"; $mcx_classes[] = "mcx-empty";
} }
$this->renderBeginTag("div", [ "data-instance-id" => $element->InstanceKey ], $mcx_classes); $this->renderBeginTag("div", [ "data-instance-id" => $element->InstanceKey ], $mcx_classes);
$this->renderBeginTag("table", [ "data-ecid" => $parentElementContent->InstanceKey, "data-instance-id" => $element->InstanceKey ], $listviewClasses); $this->renderBeginTag("table", [ "data-ecid" => $parentElementContent->InstanceKey, "data-fqecid" => $this->getElementContentId($parentElementContents, null), "data-instance-id" => $element->InstanceKey ], $listviewClasses);
// $this->renderBeginTag("div", [ "data-instance-id" => $element->InstanceKey ], [ "uwt-listview", "mcx-element", "uwt-listview-view-details", "uwt-gridlines", "uwt-hottracking" ]); // $this->renderBeginTag("div", [ "data-instance-id" => $element->InstanceKey ], [ "uwt-listview", "mcx-element", "uwt-listview-view-details", "uwt-gridlines", "uwt-hottracking" ]);
@ -2493,11 +2702,11 @@ EOF
$this->renderEndTag("thead"); $this->renderEndTag("thead");
//$this->renderEndTag("div"); //$this->renderEndTag("div");
//! TBODY *must* be rendered for Add Row button to work in JS
$this->renderBeginTag("tbody");
if ($instances !== null) if ($instances !== null)
{ {
//$this->renderBeginTag("div", [], [ "uwt-listview-items" ]); //$this->renderBeginTag("div", [], [ "uwt-listview-items" ]);
$this->renderBeginTag("tbody");
for ($i = 0; $i < $rowCount; $i++) for ($i = 0; $i < $rowCount; $i++)
{ {
$rowInst = $instances[$i]; $rowInst = $instances[$i];
@ -2538,10 +2747,10 @@ EOF
} }
//$this->renderEndTag("div"); //$this->renderEndTag("div");
$this->renderEndTag("tbody");
//$this->renderEndTag("div"); //$this->renderEndTag("div");
} }
$this->renderEndTag("tbody");
$this->renderEndTag("table"); $this->renderEndTag("table");

View File

@ -5,6 +5,8 @@ function McxElementListView(parentElement)
this.HeaderElement = this.ParentElement.children[1]; this.HeaderElement = this.ParentElement.children[1];
this.HeaderRowElement = this.HeaderElement.children[0]; this.HeaderRowElement = this.HeaderElement.children[0];
this.CountInput = this.ParentElement.parentElement.parentElement.children[0];
this.HeaderAddRowButton = this.HeaderRowElement.children[0].children[0]; this.HeaderAddRowButton = this.HeaderRowElement.children[0].children[0];
this.HeaderAddRowButton.NativeObject = this; this.HeaderAddRowButton.NativeObject = this;
this.HeaderAddRowButton.addEventListener("click", function(e) this.HeaderAddRowButton.addEventListener("click", function(e)
@ -18,13 +20,21 @@ function McxElementListView(parentElement)
}); });
this.BodyElement = this.ParentElement.children[2]; this.BodyElement = this.ParentElement.children[2];
this.setEmpty = function(value)
this.buildRow = function()
{ {
var lvInstId = this.ParentElement.getAttribute("data-ecid"); if (value)
{
System.ClassList.Add(this.ParentElement.parentElement, "mcx-empty");
}
else
{
System.ClassList.Remove(this.ParentElement.parentElement, "mcx-empty");
}
};
var tr = document.createElement("tr"); this.buildRow = function(callback, callback_parms)
tr.appendChild(this.createAddRemoveColumn()); {
var lvInstId = this.ParentElement.getAttribute("data-fqecid");
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var url = System.ExpandRelativePath("~/" + System.TenantName + "/flowController.htmld"); var url = System.ExpandRelativePath("~/" + System.TenantName + "/flowController.htmld");
@ -36,42 +46,116 @@ function McxElementListView(parentElement)
"sessionSecureToken": "7733ad40-edf6-4dc9-aa90-85bcf93cc8f0", "sessionSecureToken": "7733ad40-edf6-4dc9-aa90-85bcf93cc8f0",
"clientRequestID" : "9af7ce5bc51348a6981539a98b267072" "clientRequestID" : "9af7ce5bc51348a6981539a98b267072"
}; };
xhr.send(JSON.stringify(h)); xhr.__callback = callback;
xhr.__this = this;
for (var i = 1; i < this.HeaderRowElement.children.length; i++) xhr.onreadystatechange = function(e)
{ {
var colInstId = this.HeaderRowElement.children[i].getAttribute("data-ecid"); if (this.readyState === 4)
var fqecid = lvInstId + ":*:" + colInstId; {
responseJSON = JSON.parse(this.responseText);
if (responseJSON.result == "success")
{
if (responseJSON.item.widget == "row")
{
// !!! `this` is now XHR, not McxElementListView !!!
var tr = document.createElement("tr");
tr.appendChild(this.__this.createAddRemoveColumn());
var td = document.createElement("td"); var newRowIndex = this.__this.BodyElement.children.length;
var input = document.createElement("input"); this.__this.CountInput.value = this.__this.BodyElement.children.length + 1;
input.id = "ec_" + fqecid;
input.name = "ec_" + fqecid;
input.setAttribute("data-ecid", "ec_" + fqecid);
input.type = "text";
td.appendChild(input);
tr.appendChild(td); for (var i = 1; i < this.__this.HeaderRowElement.children.length; i++)
} {
return tr; // ! BEGIN HACK !
var columnOffset = 0;
if (this.__this.HeaderRowElement.children.length != responseJSON.item.contents.length)
{
columnOffset = 1;
}
var td = document.createElement("td");
var rowDefinition = responseJSON.item.contents[i - columnOffset];
if (typeof(rowDefinition) !== "undefined")
{
// var colInstId = this.__this.HeaderRowElement.children[i].getAttribute("data-ecid");
var colInstId = rowDefinition.ecid;
var colWidget = rowDefinition.widget;
var fqecid = lvInstId + ":" + newRowIndex + ":" + colInstId;
if (colWidget === "text")
{
var input = document.createElement("input");
input.id = "ec_" + fqecid;
input.name = "ec_" + fqecid;
input.setAttribute("data-ecid", "ec_" + fqecid);
input.type = "text";
td.appendChild(input);
}
else if (colWidget === "checkbox")
{
var input = document.createElement("input");
input.id = "ec_" + fqecid;
input.name = "ec_" + fqecid;
input.setAttribute("data-ecid", "ec_" + fqecid);
input.type = "checkbox";
td.appendChild(input);
//! must be called after appendChild since it needs to finagle the DOM
new CheckBox(input);
}
else if (colWidget === "monikerListInput")
{
var multiselect = false;
if (rowDefinition.multiselect === true)
{
multiselect = true;
}
var moniker = McxInstanceBrowser.create({ "multiselect": multiselect, "fullyQualifiedECID": fqecid, "ecid": rowDefinition.ecid, "validClassIds": [ rowDefinition.ecdt ], "autocompleteUrl": "~/prompt/c0/" + rowDefinition.ecdt });
if (moniker)
{
td.appendChild(moniker);
}
}
}
else
{
td.innerHTML = "undefined row def at index " + i;
}
tr.appendChild(td);
}
this.__callback(tr, callback_parms);
}
}
}
};
xhr.send(JSON.stringify(h));
}; };
this.addRowBefore = function(beforeIndex) this.addRowBefore = function(beforeIndex)
{ {
var tr = this.buildRow(); this.buildRow(function(tr, parms)
this.BodyElement.insertBefore(tr, this.BodyElement.children[beforeIndex]); {
parms[0].BodyElement.insertBefore(tr, parms[0].BodyElement.children[parms[1]]);
}, [ this, beforeIndex ]);
this.setEmpty(false);
}; };
this.addRowAfter = function(afterElement) this.addRowAfter = function(afterElement)
{ {
var tr = this.buildRow(); this.buildRow(function(tr, parms)
this.BodyElement.insertAfter(tr, afterElement); {
parms[0].BodyElement.insertAfter(tr, parms[1]);
}, [ this, afterElement ]);
this.setEmpty(false);
}; };
this.removeRow = function(row) this.removeRow = function(row)
{ {
row.remove(); row.remove();
this.setEmpty(this.BodyElement.children.length == 0);
}; };
this.removeRowAt = function(index) this.removeRowAt = function(index)
{ {
this.BodyElement.children[index].remove(); this.BodyElement.children[index].remove();
this.setEmpty(this.BodyElement.children.length == 0);
}; };
this.createAddRemoveColumn = function() this.createAddRemoveColumn = function()
@ -83,9 +167,13 @@ function McxElementListView(parentElement)
aAdd.className = "uwt-listview-row-add"; aAdd.className = "uwt-listview-row-add";
aAdd.href = "#"; aAdd.href = "#";
aAdd.NativeObject = this; aAdd.NativeObject = this;
aAdd.addEventListener("click", function() aAdd.addEventListener("click", function(e)
{ {
this.NativeObject.addRowAfter(this.parentElement); this.NativeObject.addRowAfter(this.parentElement);
e.preventDefault();
e.stopPropagation();
return false;
}); });
td.appendChild(aAdd); td.appendChild(aAdd);
@ -93,9 +181,13 @@ function McxElementListView(parentElement)
aRemove.className = "uwt-listview-row-remove"; aRemove.className = "uwt-listview-row-remove";
aRemove.href = "#"; aRemove.href = "#";
aRemove.NativeObject = this; aRemove.NativeObject = this;
aRemove.addEventListener("click", function() aRemove.addEventListener("click", function(e)
{ {
this.NativeObject.removeRow(this.parentElement.parentElement); this.NativeObject.removeRow(this.parentElement.parentElement);
e.preventDefault();
e.stopPropagation();
return false;
}); });
td.appendChild(aRemove); td.appendChild(aRemove);

View File

@ -16,6 +16,7 @@ function McxElementContent(parentElement)
this.updateElementContentsWithFlowController = function(value, changes) this.updateElementContentsWithFlowController = function(value, changes)
{ {
alert("update elements");
for (var i = 0; i < changes.length; i++) for (var i = 0; i < changes.length; i++)
{ {
var ecid = changes[i].ecid; var ecid = changes[i].ecid;

View File

@ -397,6 +397,82 @@ function McxInstanceBrowser(parentElement)
} }
} }
McxInstanceBrowser.create = function(parms)
{
var div = document.createElement("DIV");
div.className = "mcx-instancebrowser mcx-editable";
if (parms.multiselect === true)
{
System.ClassList.Add(div, "mcx-multiselect");
}
var value = null;
if (parms.ecid)
{
div.setAttribute("data-ecid", parms.ecid);
}
if (typeof(parms.selectedInstanceIds) === "object")
{
value = parms.selectedInstanceIds.join(";");
div.setAttribute("data-instance-ids", value);
}
if (typeof(parms.validClassIds) === "object")
{
div.setAttribute("data-valid-class-ids", parms.validClassIds.join(";"));
}
if (parms.autocompleteUrl)
{
div.setAttribute("data-autocomplete-url", parms.autocompleteUrl);
}
var divTitle = document.createElement("DIV");
if (parms.title)
{
divTitle.innerHTML = title;
}
div.appendChild(divTitle);
var inputHidden = document.createElement("INPUT");
inputHidden.type = "hidden";
inputHidden.name = "ec_" + parms.fullyQualifiedECID;
if (value !== null)
{
inputHidden.value = value;
}
div.appendChild(inputHidden);
var input = document.createElement("INPUT");
input.type = "text";
div.appendChild(input);
var ul = document.createElement("UL");
ul.className = "mcx-selected-items";
div.appendChild(ul);
var divSearchResults = document.createElement("DIV");
divSearchResults.className = "uwt-popup mcx-search-results";
var ulSearchResults = document.createElement("UL");
ulSearchResults.className = "uwt-menu uwt-multiselect uwt-highlight";
divSearchResults.appendChild(ulSearchResults);
var divSpinner = document.createElement("DIV");
divSpinner.className = "uwt-spinner";
divSearchResults.appendChild(divSpinner);
var divPlaceholder = document.createElement("DIV");
divPlaceholder.className = "uwt-placeholder";
divPlaceholder.innerText = "type to search the list";
divSearchResults.appendChild(divPlaceholder);
div.appendChild(divSearchResults);
new McxInstanceBrowser(div);
return div;
};
window.addEventListener("load", function() window.addEventListener("load", function()
{ {
var items = document.getElementsByClassName("mcx-instancebrowser"); var items = document.getElementsByClassName("mcx-instancebrowser");

View File

@ -2,7 +2,10 @@
namespace Mocha\UI\Pages; namespace Mocha\UI\Pages;
use Mocha\Core\KnownAttributeGuids;
use Mocha\Oms\Oms;
use Mocha\Core\InstanceKey; use Mocha\Core\InstanceKey;
use Mocha\Core\InstanceReference;
use Mocha\Core\KnownClassGuids; use Mocha\Core\KnownClassGuids;
use Mocha\Core\KnownInstanceGuids; use Mocha\Core\KnownInstanceGuids;
use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\KnownRelationshipGuids;
@ -14,6 +17,50 @@
class FlowControllerPage extends WebPage class FlowControllerPage extends WebPage
{ {
private function buildElementContentJSON(Oms $oms, InstanceReference $subEC)
{
$ecDataType = $oms->getRelatedInstance($subEC, KnownRelationshipGuids::Element_Content__has__Instance);
$ary = array
(
"ecid" => $subEC->InstanceKey->__toString()
);
$widget = "";
if ($ecDataType != null)
{
$dataTypeClass = $oms->getParentClass($ecDataType);
$ary["ecdt"] = $ecDataType->InstanceKey->__toString();
if
(
$dataTypeClass->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::TextAttribute))
|| $dataTypeClass->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::NumericAttribute))
|| $dataTypeClass->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::DateAttribute))
)
{
$widget = "text";
}
else if ($dataTypeClass->GlobalIdentifier->__is_equal(UUID::parse(KnownClassGuids::BooleanAttribute)))
{
$widget = "checkbox";
}
else if ($oms->is_a($dataTypeClass, UUID::parse(KnownClassGuids::Clasz)))
{
$widget = "monikerListInput";
if (($oms->getAttributeValue($subEC, KnownAttributeGuids::Singular))
|| ($oms->getAttributeValue($ecDataType, KnownAttributeGuids::Singular)))
{
$ary["multiselect"] = false;
}
else
{
$ary["multiselect"] = true;
}
}
}
$ary["widget"] = $widget;
return $ary;
}
protected function OnInitializing(\Phast\CancelEventArgs $e) protected function OnInitializing(\Phast\CancelEventArgs $e)
{ {
header("Content-Type: application/json"); header("Content-Type: application/json");
@ -68,10 +115,7 @@
$elementContents = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content); $elementContents = $oms->getRelatedInstances($element, KnownRelationshipGuids::Element__has__Element_Content);
foreach ($elementContents as $subEC) foreach ($elementContents as $subEC)
{ {
$contents[] = array $contents[] = $this->buildElementContentJSON($oms, $subEC);
(
"ecid" => $subEC->InstanceKey->__toString()
);
} }
} }
else if ($oms->is_a($element, KnownClassGuids::BooleanAttribute)) else if ($oms->is_a($element, KnownClassGuids::BooleanAttribute))