diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php index 94eb6ab4f..bac4fb536 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php @@ -26,6 +26,7 @@ use Dict; use Exception; use MetaModel; use RunTimeEnvironment; +use SecurityException; use SetupUtils; use utils; @@ -83,10 +84,11 @@ class DataFeatureRemovalController extends Controller { $aParams = []; - if (SetupUtils::IsSessionSetupTokenValid()) { + try { //from setup wizard/mtp + SetupUtils::CheckSetupToken(); SetupUtils::EraseSetupToken(); - } else { + } catch (SecurityException $e) { //from same module $this->ValidateTransactionId(); } @@ -100,6 +102,7 @@ class DataFeatureRemovalController extends Controller 'removed_extensions' => '[]', 'extensions_not_uninstallable' => '[]', 'copy_setup_files' => 1, + 'return_button_label' => '', ]; $aHiddenInputs = []; @@ -108,6 +111,10 @@ class DataFeatureRemovalController extends Controller } $aParams['aHiddenInputs'] = $aHiddenInputs; + if ($aHiddenInputs['return_button_label'] !== '') { + $aParams['sReturnButtonURL'] = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + } + $aAddedExtensions = json_decode($aHiddenInputs['added_extensions'], true); $aRemovedExtensions = json_decode($aHiddenInputs['removed_extensions'], true); @@ -179,6 +186,10 @@ class DataFeatureRemovalController extends Controller $aParams['aSetupParams']["_params[$sInputName]"] = $sInputValue; } + if ($aHiddenInputs['return_button_label'] !== '') { + $aParams['sReturnButtonURL'] = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + } + [$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses); [$aParams['aDeletionExecutionSummary'], $aParams['bHasDeletionExecution']] = $this->GetExecutionSummaryTable(); $aParams['bDeletionNeeded'] = ($aParams['iQueryCount'] > 0); diff --git a/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig b/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig index 9d5bb1c64..d2a2dc5ca 100644 --- a/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig +++ b/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig @@ -87,11 +87,15 @@ {% endif %} {% endif %} - {% UIForm Standard {} %} - {% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %} - {% UIInput ForHidden { sName:'operation', sValue:'Main'} %} - {% UIToolbar ForButton {} %} - {% UIButton ForPrimaryAction {sLabel:'UI:Button:BackToMain'|dict_s, sName:'btn_back', sId:'btn_back', bIsSubmit:true} %} - {% EndUIToolbar %} - {% EndUIForm %} + {% if aHiddenInputs.return_button_label != '' %} + {% UIButton ForAlternativeSecondaryAction { sLabel:aHiddenInputs.return_button_label, OnClickJsCode: 'window.location.href="' ~ sReturnButtonURL ~ '"'} %} + {% else %} + {% UIForm Standard {} %} + {% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %} + {% UIInput ForHidden { sName:'operation', sValue:'Main'} %} + {% UIToolbar ForButton {} %} + {% UIButton ForPrimaryAction {sLabel:'UI:Button:BackToMain'|dict_s, sName:'btn_back', sId:'btn_back', bIsSubmit:true} %} + {% EndUIToolbar %} + {% EndUIForm %} + {% endif %} {% EndUIPanel %} diff --git a/setup/setup.js b/setup/setup.js index c7917b749..26026dddd 100644 --- a/setup/setup.js +++ b/setup/setup.js @@ -26,17 +26,17 @@ function WizardAsyncAction(sActionCode, oParams, OnErrorFunction) function WizardUpdateButtons() { if (CanMoveForward()) { - $("#btn_next").prop('disabled', false); + $("#btn_next").removeClass('ibo-is-hidden'); } else { - $("#btn_next").prop('disabled', true); + $("#btn_next").addClass('ibo-is-hidden'); } if (CanMoveBackward()) { - $("#btn_back").prop('disabled', false); + $("#btn_back").removeClass('ibo-is-hidden'); } else { - $("#btn_back").prop('disabled', true); + $("#btn_back").addClass('ibo-is-hidden'); } } diff --git a/setup/wizardcontroller.class.inc.php b/setup/wizardcontroller.class.inc.php index eace6760d..97cd4a425 100644 --- a/setup/wizardcontroller.class.inc.php +++ b/setup/wizardcontroller.class.inc.php @@ -151,10 +151,10 @@ class WizardController $sCurrentState = utils::ReadParam('_state', $this->sInitialState); $oStep = $this->GetWizardStep($sCurrentStepClass, $sCurrentState); if ($oStep->ValidateParams()) { - if ($oStep->CanComeBack()) { + $aPossibleSteps = $oStep->GetPossibleSteps(); + if ($oStep->CanMoveBackward()) { $this->PushStep(['class' => $sCurrentStepClass, 'state' => $sCurrentState]); } - $aPossibleSteps = $oStep->GetPossibleSteps(); $oWizardState = $oStep->UpdateWizardStateAndGetNextStep(true); // true => moving forward if (in_array($oWizardState->GetNextStep(), $aPossibleSteps)) { $oNextStep = $this->GetWizardStep($oWizardState->GetNextStep(), $oWizardState->GetState()); @@ -237,8 +237,12 @@ HTML; $oPage->add(''); $oPage->add('
| '); + if (count($this->aWizardSteps) > 0) { + if ($oStep->CanMoveBackward()) { + $oPage->add(' | '); + } else { + $oPage->add(' | '); + } } if ($oStep->CanMoveForward()) { $oPage->add(' | '); diff --git a/setup/wizardsteps/WizStepDataAudit.php b/setup/wizardsteps/WizStepDataAudit.php index 725ce2f1a..fe8e2bfe5 100644 --- a/setup/wizardsteps/WizStepDataAudit.php +++ b/setup/wizardsteps/WizStepDataAudit.php @@ -54,16 +54,20 @@ class WizStepDataAudit extends WizStepInstall } } + /** + * Tells whether this step/state allows to go back or not + * @return boolean True if the '<< Back' button should be displayed + */ + public function CanMoveBackward() + { + return false; + } + public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState { return new WizardState(WizStepSummary::class); } - public function CanComeBack() - { - return false; - } - public function Display(SetupPage $oPage): void { @@ -108,6 +112,7 @@ JS); 'removed_extensions' => '[]', 'extensions_not_uninstallable' => '[]', 'copy_setup_files' => 1, + 'return_button_label' => '', ]; $aHiddenInputs = ''; foreach ($aParams as $sParamName => $defaultValue) { @@ -123,23 +128,43 @@ INPUT; << - + $aHiddenInputs HTML ); + + $sButtonLabel = $this->oWizard->GetParameter('return_button_label', ''); + if ($sButtonLabel !== '') { + $sButtonLabel = utils::HtmlEntities($sButtonLabel); + $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + $sButtonUrl = utils::HtmlEntities($sButtonUrl); + $oPage->add_ready_script( + << | '); + $('.ibo-setup--wizard--buttons-container tr td:nth-child(3)').after(' | '); $('#goto-data-feature-removal').on("click", function() { $('#goto-data-feature-removal').prop('disabled', true); $('#submit-wait').removeClass("ibo-is-hidden"); @@ -148,7 +173,7 @@ HTML $("#wiz_form").data("installation_status", "cleanup_needed"); $('#btn_next').hide(); -EOF +JS ); } @@ -161,6 +186,10 @@ EOF public function JSCanMoveBackward() { + if ($this->oWizard->GetParameter('return_button_label', '') !== '') { + return 'return false;'; + } + return 'return ["not started", "error", "cleanup_needed"].indexOf($("#wiz_form").data("installation_status")) !== -1;'; } } diff --git a/setup/wizardsteps/WizStepDone.php b/setup/wizardsteps/WizStepDone.php index 2cde077c2..843ead687 100644 --- a/setup/wizardsteps/WizStepDone.php +++ b/setup/wizardsteps/WizStepDone.php @@ -144,6 +144,11 @@ class WizStepDone extends WizardStep return false; } + public function JSCanMoveBackward() + { + return 'return false;'; + } + /** * Tells whether this step of the wizard requires that the configuration file be writable * @return bool True if the wizard will possibly need to modify the configuration at some point diff --git a/setup/wizardsteps/WizStepInstall.php b/setup/wizardsteps/WizStepInstall.php index 9b3499acc..648e1f2e7 100644 --- a/setup/wizardsteps/WizStepInstall.php +++ b/setup/wizardsteps/WizStepInstall.php @@ -54,6 +54,13 @@ class WizStepInstall extends AbstractWizStepInstall } } + public function CanMoveBackward() + { + $sLabel = $this->oWizard->GetParameter('return_button_label', ''); + SetupLog::Info(__METHOD__.": return_button_label [$sLabel]"); + return $sLabel === ''; + } + public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState { return new WizardState(WizStepDone::class); @@ -109,6 +116,20 @@ JS); JS); } + public function PostFormDisplay(SetupPage $oPage) + { + $sButtonLabel = $this->oWizard->GetParameter('return_button_label', ''); + SetupLog::Info(__METHOD__.": return_button_label [$sButtonLabel]"); + if ($sButtonLabel !== '') { + $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + $oPage->add_ready_script( + << |