浏览代码

Bug fix: support [+] button inside linkedsets

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1909 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父节点
当前提交
e3038e201e
共有 2 个文件被更改,包括 26 次插入2 次删除
  1. 8 1
      application/ui.extkeywidget.class.inc.php
  2. 18 1
      application/ui.linkswidget.class.inc.php

+ 8 - 1
application/ui.extkeywidget.class.inc.php

@@ -126,7 +126,14 @@ class UIExtKeyWidget
 		} 
 		} 
 		else
 		else
 		{
 		{
-			$sWizHelper = 'oWizardHelper'.$sFormPrefix;
+			if (isset($aArgs['wizHelper']))
+			{
+				$sWizHelper = $aArgs['wizHelper'];
+			}
+			else
+			{
+				$sWizHelper = 'oWizardHelper'.$sFormPrefix;
+			}
 			$sWizHelperJSON = $sWizHelper.'.ToJSON()';
 			$sWizHelperJSON = $sWizHelper.'.ToJSON()';
 			$sJSSearchMode = 'false';
 			$sJSSearchMode = 'false';
 		}
 		}

+ 18 - 1
application/ui.linkswidget.class.inc.php

@@ -104,12 +104,14 @@ class UILinksWidget
 	{
 	{
 		$sPrefix = "$this->m_sAttCode{$this->m_sNameSuffix}";
 		$sPrefix = "$this->m_sAttCode{$this->m_sNameSuffix}";
 		$aRow = array();
 		$aRow = array();
+		$aFieldsMap = array();
 		if(is_object($linkObjOrId))
 		if(is_object($linkObjOrId))
 		{
 		{
 			$key = $linkObjOrId->GetKey();
 			$key = $linkObjOrId->GetKey();
 			$sPrefix .= "[$key][";
 			$sPrefix .= "[$key][";
 			$sNameSuffix = "]"; // To make a tabular form
 			$sNameSuffix = "]"; // To make a tabular form
 			$aArgs['prefix'] = $sPrefix;
 			$aArgs['prefix'] = $sPrefix;
+			$aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}{$key}";
 			$aArgs['this'] = $linkObjOrId;
 			$aArgs['this'] = $linkObjOrId;
 			$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$key\">";
 			$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$key\">";
 			$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"$key\">";
 			$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"$key\">";
@@ -119,7 +121,9 @@ class UILinksWidget
 				$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
 				$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
 				$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
 				$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
 				$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '' /* DisplayValue */, $sSafeId, $sNameSuffix, 0, $aArgs);
 				$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '' /* DisplayValue */, $sSafeId, $sNameSuffix, 0, $aArgs);
+				$aFieldsMap[$sFieldCode] = $sFieldId;
 			}
 			}
+			$sState = $linkObjOrId->GetState();
 		}
 		}
 		else
 		else
 		{
 		{
@@ -131,6 +135,7 @@ class UILinksWidget
 			$oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj); // Setting the extkey with the object alsoo fills the related external fields
 			$oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj); // Setting the extkey with the object alsoo fills the related external fields
 			$sNameSuffix = "]"; // To make a tabular form
 			$sNameSuffix = "]"; // To make a tabular form
 			$aArgs['prefix'] = $sPrefix;
 			$aArgs['prefix'] = $sPrefix;
+			$aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}_".(-$linkObjOrId);
 			$aArgs['this'] = $oNewLinkObj;
 			$aArgs['this'] = $oNewLinkObj;
 			$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$linkObjOrId\">";
 			$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$linkObjOrId\">";
 			$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
 			$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
@@ -140,9 +145,21 @@ class UILinksWidget
 				$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
 				$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
 				$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
 				$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
 				$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $oNewLinkObj->Get($sFieldCode) /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, $sSafeId /* id */, $sNameSuffix, 0, $aArgs);
 				$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $oNewLinkObj->Get($sFieldCode) /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, $sSafeId /* id */, $sNameSuffix, 0, $aArgs);
+				$aFieldsMap[$sFieldCode] = $sFieldId;
 			}
 			}
+			$sState = '';
 		}
 		}
-
+		
+		$iFieldsCount = count($aFieldsMap);
+		$sJsonFieldsMap = json_encode($aFieldsMap);
+		
+		$oP->add_script(
+<<<EOF
+var {$aArgs['wizHelper']} = new WizardHelper('{$this->m_sLinkedClass}', '', '$sState');
+{$aArgs['wizHelper']}.SetFieldsMap($sJsonFieldsMap);
+{$aArgs['wizHelper']}.SetFieldsCount($iFieldsCount);
+EOF
+		);
 		$aRow['static::key'] = $oLinkedObj->GetHyperLink();
 		$aRow['static::key'] = $oLinkedObj->GetHyperLink();
 		foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
 		foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
 		{
 		{