Forráskód Böngészése

N°653: Dependant fields on transitions was not using transition flags.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4769 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 8 éve
szülő
commit
8ef5e9ff20

+ 1 - 1
application/cmdbabstract.class.inc.php

@@ -2628,7 +2628,7 @@ EOF
 		$oPage->add_script(
 <<<EOF
 		// Initializes the object once at the beginning of the page...
-		var oWizardHelper = new WizardHelper('$sClass', '', '$sTargetState');
+		var oWizardHelper = new WizardHelper('$sClass', '', '$sTargetState', '{$this->GetState()}', '$sStimulus');
 		oWizardHelper.SetFieldsMap($sJsonFieldsMap);
 		oWizardHelper.SetFieldsCount($iFieldsCount);
 EOF

+ 15 - 5
application/wizardhelper.class.inc.php

@@ -270,11 +270,21 @@ class WizardHelper
 	{
 		return $this->m_aData['m_sClass'];
 	}
-	
-	public function GetFormPrefix()
-	{
-		return $this->m_aData['m_sFormPrefix'];
-	}
+
+    public function GetFormPrefix()
+    {
+        return $this->m_aData['m_sFormPrefix'];
+    }
+
+    public function GetInitialState()
+    {
+        return $this->m_aData['m_sInitialState'];
+    }
+
+    public function GetStimulus()
+    {
+        return $this->m_aData['m_sStimulus'];
+    }
 	
 	public function GetIdForField($sFieldName)
 	{

+ 12 - 2
js/wizardhelper.js

@@ -34,7 +34,7 @@ if (!Array.prototype.indexOf) // Emulation of the indexOf function for IE and ol
 	};
 }
 
-function WizardHelper(sClass, sFormPrefix, sState)
+function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus)
 {
 	this.m_oData = { 'm_sClass' : '',
 					 'm_oFieldsMap': {},
@@ -48,7 +48,17 @@ function WizardHelper(sClass, sFormPrefix, sState)
 					 'm_sState': sState
 					};
 	this.m_oData.m_sClass = sClass;
-	
+
+	// Setting optional transition data
+	if(sInitialState !== undefined)
+	{
+		this.m_oData.m_sInitialState = sInitialState;
+	}
+	if(sStimulus !== undefined)
+	{
+		this.m_oData.m_sStimulus = sStimulus;
+	}
+
 	// Methods
 	this.SetFieldsMap = function (oFieldsMap)
 	{

+ 6 - 1
pages/ajax.render.php

@@ -569,12 +569,17 @@ try
 			$oObj->Set($sAttCode, $defaultValue);
 		}
 		$sFormPrefix = $oWizardHelper->GetFormPrefix();
+		$aExpectedAttributes = $oObj->GetTransitionAttributes($oWizardHelper->GetStimulus(), $oWizardHelper->GetInitialState());
 		foreach($oWizardHelper->GetFieldsForAllowedValues() as $sAttCode)
 		{
 			$sId = $oWizardHelper->GetIdForField($sAttCode);
 			if ($sId != '')
 			{
-				if ($oObj->IsNew())
+                if(array_key_exists($sAttCode, $aExpectedAttributes))
+                {
+                    $iFlags = $aExpectedAttributes[$sAttCode];
+                }
+                elseif ($oObj->IsNew())
 				{
 					$iFlags = $oObj->GetInitialStateAttributeFlags($sAttCode);
 				}