浏览代码

- 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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1285 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 14 年之前
父节点
当前提交
25d4e15bef
共有 1 个文件被更改,包括 44 次插入65 次删除
  1. 44 65
      pages/ajax.render.php

+ 44 - 65
pages/ajax.render.php

@@ -72,86 +72,89 @@ 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', '');
-		$sAttCode = utils::ReadParam('sAttCode', '');
+		$sTargetClass = utils::ReadParam('sTargetClass', '');
 		$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);
-		$oObj = $oWizardHelper->GetTargetObject();
-			$currentValue = $oObj->Get($sAttCode);
+			$oWizardHelper = WizardHelper::FromJSON($sJson);
+			$oObj = $oWizardHelper->GetTargetObject();
+		}
+		else
+		{
+			// Search form: no current object
+			$oObj = null;
+		}
+		$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
+		$oWidget->SearchObjectsToSelect($oPage, $sFilter, $sRemoteClass, $oObj);	
+		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
 		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($sAttCode, $sClass, '', $oAllowedValues, $currentValue, $iInputId, false, $sSuffix, '');
-		$oWidget->SearchObjectsToSelect($oPage, $sTargetClass);	
+		$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', '');
-		$sAttCode = utils::ReadParam('sAttCode', '');
+		$sTargetClass = utils::ReadParam('sTargetClass', '');
 		$iInputId = utils::ReadParam('iInputId', '');
 		$iInputId = utils::ReadParam('iInputId', '');
-		$sSuffix = utils::ReadParam('sSuffix', '');
-		$sValue = utils::ReadParam('sValue', '');
-		//$oWizardHelper = WizardHelper::FromJSON($sJson);
-		//$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);
+		$sTitle = utils::ReadParam('sTitle');
+		$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
+		$oWidget->GetSearchDialog($oPage, $sTitle);
 		break;
 		break;
 
 
 		// ui.extkeywidget
 		// ui.extkeywidget
 		case 'objectCreationForm':
 		case 'objectCreationForm':
-		$sTargetClass = utils::ReadParam('sRemoteClass', '');
-		$sAttCode = utils::ReadParam('sAttCode', '');
+		$sTargetClass = utils::ReadParam('sTargetClass', '');
 		$iInputId = utils::ReadParam('iInputId', '');
 		$iInputId = utils::ReadParam('iInputId', '');
-		$sSuffix = utils::ReadParam('sSuffix', '');
-		$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 = new UIExtKeyWidget($sTargetClass, $iInputId);
 		$oWidget->GetObjectCreationForm($oPage);
 		$oWidget->GetObjectCreationForm($oPage);
 		break;
 		break;
 		
 		
 		// ui.extkeywidget
 		// ui.extkeywidget
 		case 'doCreateObject':
 		case 'doCreateObject':
-		$sTargetClass = utils::ReadParam('sRemoteClass', '');
-		$sAttCode = utils::ReadParam('sAttCode', '');
+		$sTargetClass = utils::ReadParam('sTargetClass', '');
 		$iInputId = utils::ReadParam('iInputId', '');
 		$iInputId = utils::ReadParam('iInputId', '');
-		$sSuffix = utils::ReadParam('sSuffix', '');
-		$sJson = utils::ReadParam('json', '');
-		$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());
+		$sFormPrefix = utils::ReadParam('sFormPrefix', '');
+		$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
 		$aResult = $oWidget->DoCreateObject($oPage);
 		$aResult = $oWidget->DoCreateObject($oPage);
-		echo json_encode($aResult);	
+		echo json_encode($aResult);
 		break;
 		break;
 		
 		
 		// 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($sAttCode, $sClass, '', null, '', $iInputId, $sSuffix, '');
+		$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId);
 		$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', '');
@@ -297,31 +300,7 @@ try
 		$oDisplayBlock->RenderContent($oPage);
 		$oDisplayBlock->RenderContent($oPage);
 		$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');