- New implementation of the UIExtKeyWidget that is no longer limited to editing an attribute of an object

- When needed the drop-down list of organizations is replaced by an autocomplete

SVN:trunk[1285]
This commit is contained in:
Denis Flaven
2011-06-15 17:06:46 +00:00
parent b4a7d0b86c
commit ddfc84db6a

View File

@@ -72,70 +72,73 @@ try
$oWidget->SearchObjectsToAdd($oPage, $sRemoteClass, $aAlreadyLinked); $oWidget->SearchObjectsToAdd($oPage, $sRemoteClass, $aAlreadyLinked);
break; break;
////////////////////////////////////////////////////////////
// ui.extkeywidget // ui.extkeywidget
case 'searchObjectsToSelect': case 'searchObjectsToSelect':
$sTargetClass = utils::ReadParam('sRemoteClass', ''); $sTargetClass = utils::ReadParam('sTargetClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$sSuffix = utils::ReadParam('sSuffix', ''); $sRemoteClass = utils::ReadParam('sRemoteClass', '');
$sFilter = utils::ReadParam('sFilter');
$sJson = utils::ReadParam('json', ''); $sJson = utils::ReadParam('json', '');
if (!empty($sJson)) if (!empty($sJson))
{ {
$oWizardHelper = WizardHelper::FromJSON($sJson); $oWizardHelper = WizardHelper::FromJSON($sJson);
$oObj = $oWizardHelper->GetTargetObject(); $oObj = $oWizardHelper->GetTargetObject();
$currentValue = $oObj->Get($sAttCode);
} }
else else
{ {
// Search form: no current object // Search form: no current object
$oObj = null; $oObj = null;
$currentValue = '';
} }
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, array('this' => $oObj)); $oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
$oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $oAllowedValues, $currentValue, $iInputId, false, $sSuffix, ''); $oWidget->SearchObjectsToSelect($oPage, $sFilter, $sRemoteClass, $oObj);
$oWidget->SearchObjectsToSelect($oPage, $sTargetClass); break;
// ui.extkeywidget: autocomplete
case 'ac_extkey':
$sTargetClass = utils::ReadParam('sTargetClass', '');
$iInputId = utils::ReadParam('iInputId', '');
$sFilter = utils::ReadParam('sFilter');
$sJson = utils::ReadParam('json', '');
$sContains = utils::ReadParam('q', '');
if (!empty($sJson))
{
$oWizardHelper = WizardHelper::FromJSON($sJson);
$oObj = $oWizardHelper->GetTargetObject();
}
else
{
// Search form: no current object
$oObj = null;
}
$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
$oWidget->AutoComplete($oPage, $sFilter, $oObj, $sContains);
break; break;
// ui.extkeywidget // ui.extkeywidget
case 'objectSearchForm': case 'objectSearchForm':
$sTargetClass = utils::ReadParam('sRemoteClass', ''); $sTargetClass = utils::ReadParam('sTargetClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$sSuffix = utils::ReadParam('sSuffix', ''); $sTitle = utils::ReadParam('sTitle');
$sValue = utils::ReadParam('sValue', ''); $oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
//$oWizardHelper = WizardHelper::FromJSON($sJson); $oWidget->GetSearchDialog($oPage, $sTitle);
//$oObj = $oWizardHelper->GetTargetObject();
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, array() /*array('this' => $oObj)*/);
$oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $oAllowedValues, $sValue, $iInputId, false, $sSuffix, '');
$oWidget->GetSearchDialog($oPage);
break; break;
// ui.extkeywidget // ui.extkeywidget
case 'objectCreationForm': case 'objectCreationForm':
$sTargetClass = utils::ReadParam('sRemoteClass', ''); $sTargetClass = utils::ReadParam('sTargetClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$sSuffix = utils::ReadParam('sSuffix', ''); $oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
$sJson = utils::ReadParam('json', '');
$oWizardHelper = WizardHelper::FromJSON($sJson);
$oObj = $oWizardHelper->GetTargetObject();
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, array('this' => $oObj));
$oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $oAllowedValues, $oObj->Get($sAttCode), $iInputId, false, $sSuffix, '');
$oWidget->GetObjectCreationForm($oPage); $oWidget->GetObjectCreationForm($oPage);
break; break;
// ui.extkeywidget // ui.extkeywidget
case 'doCreateObject': case 'doCreateObject':
$sTargetClass = utils::ReadParam('sRemoteClass', ''); $sTargetClass = utils::ReadParam('sTargetClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$sSuffix = utils::ReadParam('sSuffix', ''); $sFormPrefix = utils::ReadParam('sFormPrefix', '');
$sJson = utils::ReadParam('json', ''); $oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
$oWizardHelper = WizardHelper::FromJSON($sJson);
$oObj = $oWizardHelper->GetTargetObject();
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, array('this' => $oObj));
// The iInputId of the autocomplete is the prefix for the form used to create the target object
$oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $oAllowedValues, null, $iInputId, false, $sSuffix, $oWizardHelper->GetFormPrefix());
$aResult = $oWidget->DoCreateObject($oPage); $aResult = $oWidget->DoCreateObject($oPage);
echo json_encode($aResult); echo json_encode($aResult);
break; break;
@@ -143,15 +146,15 @@ try
// ui.extkeywidget // ui.extkeywidget
case 'getObjectName': case 'getObjectName':
$sTargetClass = utils::ReadParam('sTargetClass', ''); $sTargetClass = utils::ReadParam('sTargetClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$iObjectId = utils::ReadParam('iObjectId', ''); $iObjectId = utils::ReadParam('iObjectId', '');
$sSuffix = utils::ReadParam('sSuffix', ''); $oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
$oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', null, '', $iInputId, $sSuffix, '');
$sName = $oWidget->GetObjectName($iObjectId); $sName = $oWidget->GetObjectName($iObjectId);
echo json_encode(array('name' => $sName)); echo json_encode(array('name' => $sName));
break; break;
////////////////////////////////////////////////////
// ui.linkswidget // ui.linkswidget
case 'doAddObjects': case 'doAddObjects':
$sAttCode = utils::ReadParam('sAttCode', ''); $sAttCode = utils::ReadParam('sAttCode', '');
@@ -298,30 +301,6 @@ try
$oPage->Add("<input type=\"button\" class=\"jqmClose\" value=\" Close \" />\n"); $oPage->Add("<input type=\"button\" class=\"jqmClose\" value=\" Close \" />\n");
break; break;
case 'autocomplete':
$key = utils::ReadParam('id', 0);
$sClass = utils::ReadParam('sclass', 'bizContact');
$sAttCode = utils::ReadParam('attCode', 'name');
$sOrg = utils::ReadParam('org_id', '');
$sName = utils::ReadParam('q', '');
$iMaxCount = utils::ReadParam('max', 30);
$aArgs = array();
if (!empty($key))
{
if ($oThis = MetaModel::GetObject($sClass, $key))
{
$aArgs['*this*'] = $oThis;
$aArgs['this'] = $oThis;
}
}
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs, $sName);
$iCount = 0;
foreach($aAllowedValues as $key => $value)
{
$oPage->add($value."|".$key."\n");
}
break;
case 'link': case 'link':
$sClass = utils::ReadParam('sclass', 'logInfra'); $sClass = utils::ReadParam('sclass', 'logInfra');
$sAttCode = utils::ReadParam('attCode', 'name'); $sAttCode = utils::ReadParam('attCode', 'name');