From b15621639b6f632fdb3eda50d0bf4e75bf7937b8 Mon Sep 17 00:00:00 2001 From: Guillaume Lajarige Date: Tue, 27 Jun 2017 10:14:58 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B0653:=20Dependant=20fields=20on=20transit?= =?UTF-8?q?ions=20was=20not=20using=20transition=20flags.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[4769] --- application/cmdbabstract.class.inc.php | 2 +- application/wizardhelper.class.inc.php | 20 +++++++++++++++----- js/wizardhelper.js | 14 ++++++++++++-- pages/ajax.render.php | 7 ++++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index bbfb67251..3a293aa97 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -2628,7 +2628,7 @@ EOF $oPage->add_script( <<GetState()}', '$sStimulus'); oWizardHelper.SetFieldsMap($sJsonFieldsMap); oWizardHelper.SetFieldsCount($iFieldsCount); EOF diff --git a/application/wizardhelper.class.inc.php b/application/wizardhelper.class.inc.php index fa241873e..c544044c2 100644 --- a/application/wizardhelper.class.inc.php +++ b/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) { diff --git a/js/wizardhelper.js b/js/wizardhelper.js index a76d8f9b0..cfe22ac1c 100644 --- a/js/wizardhelper.js +++ b/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) { diff --git a/pages/ajax.render.php b/pages/ajax.render.php index fd8c6680e..bc9e045f9 100644 --- a/pages/ajax.render.php +++ b/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); }