瀏覽代碼

Bug fix: support [+] button inside linkedsets.. with constraints

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1915 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父節點
當前提交
6e578eaedf
共有 2 個文件被更改,包括 39 次插入2 次删除
  1. 1 1
      application/ui.extkeywidget.class.inc.php
  2. 38 1
      application/ui.linkswidget.class.inc.php

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

@@ -134,7 +134,7 @@ class UIExtKeyWidget
 			{
 				$sWizHelper = 'oWizardHelper'.$sFormPrefix;
 			}
-			$sWizHelperJSON = $sWizHelper.'.ToJSON()';
+			$sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()';
 			$sJSSearchMode = 'false';
 		}
 		if (is_null($oAllowedValues))

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

@@ -108,6 +108,7 @@ class UILinksWidget
 		if(is_object($linkObjOrId))
 		{
 			$key = $linkObjOrId->GetKey();
+			$iRemoteObjKey =  $linkObjOrId->Get($this->m_sExtKeyToRemote);
 			$sPrefix .= "[$key][";
 			$sNameSuffix = "]"; // To make a tabular form
 			$aArgs['prefix'] = $sPrefix;
@@ -129,10 +130,11 @@ class UILinksWidget
 		{
 			// form for creating a new record
 			$sPrefix .= "[$linkObjOrId][";
+			$iRemoteObjKey = -$linkObjOrId;
 			$oNewLinkObj = MetaModel::NewObject($this->m_sLinkedClass);
 			$oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, -$linkObjOrId);
 			$oNewLinkObj->Set($this->m_sExtKeyToRemote, $oRemoteObj); // 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
+			$oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj); // Setting the extkey with the object also fills the related external fields
 			$sNameSuffix = "]"; // To make a tabular form
 			$aArgs['prefix'] = $sPrefix;
 			$aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}_".(-$linkObjOrId);
@@ -148,8 +150,38 @@ class UILinksWidget
 				$aFieldsMap[$sFieldCode] = $sFieldId;
 			}
 			$sState = '';
+			$oP->add_script(
+<<<EOF
+$(".date-pick").datepicker({
+		showOn: 'button',
+		buttonImage: '../images/calendar.png',
+		buttonImageOnly: true,
+		dateFormat: 'yy-mm-dd',
+		constrainInput: false,
+		changeMonth: true,
+		changeYear: true
+	});
+$(".datetime-pick").datepicker({
+		showOn: 'button',
+		buttonImage: '../images/calendar.png',
+		buttonImageOnly: true,
+		dateFormat: 'yy-mm-dd 00:00:00',
+		constrainInput: false,
+		changeMonth: true,
+		changeYear: true
+});
+EOF
+			);
 		}
 		
+		$sExtKeyToMeId = $this->MakeID($sPrefix.$this->m_sExtKeyToMe);
+		$aFieldsMap[$this->m_sExtKeyToMe] = $sExtKeyToMeId;
+		$aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"$sExtKeyToMeId\" value=\"".$oCurrentObj->GetKey()."\">";
+
+		$sExtKeyToRemoteId = $this->MakeID($sPrefix.$this->m_sExtKeyToRemote);
+		$aFieldsMap[$this->m_sExtKeyToRemote] = $sExtKeyToRemoteId;
+		$aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"$sExtKeyToRemoteId\" value=\"$iRemoteObjKey\">";
+		
 		$iFieldsCount = count($aFieldsMap);
 		$sJsonFieldsMap = json_encode($aFieldsMap);
 		
@@ -167,6 +199,11 @@ EOF
 		}
 		return $aRow;
 	}
+	
+	protected function MakeID($sName)
+	{
+		return str_replace(array('[', ']'), '_', $sName);
+	}
 
 	/**
 	 * Display one row of the whole form