Compare commits

..

1 Commits

Author SHA1 Message Date
Eric Espie
25d8631b88 N°9169 - Adapt ITSM designer connector to the new setup - Button Back to designer 2026-06-01 17:57:39 +02:00
8 changed files with 127 additions and 54 deletions

View File

@@ -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');
}
}

View File

@@ -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('<input type="hidden" name="_steps" value="'.utils::EscapeHtml(json_encode($this->aWizardSteps)).'"/>');
$oPage->add('<table style="width:100%;" class="ibo-setup--wizard--buttons-container"><tr>');
if ((count($this->aWizardSteps) > 0) && ($oStep->CanMoveBackward())) {
$oPage->add('<td style="text-align: left"><button id="btn_back" class="ibo-button ibo-is-alternative ibo-is-neutral" type="submit" name="operation" value="back"><span class="ibo-button--label">Back</span></button></td>');
if (count($this->aWizardSteps) > 0) {
if ($oStep->CanMoveBackward()) {
$oPage->add('<td style="text-align: left"><button id="btn_back" class="ibo-button ibo-is-alternative ibo-is-neutral" type="submit" name="operation" value="back"><span class="ibo-button--label">Back</span></button></td>');
} else {
$oPage->add('<td style="text-align: left"><button id="btn_back" class="ibo-button ibo-is-alternative ibo-is-neutral ibo-is-hidden" type="submit" name="operation" value="back"><span class="ibo-button--label">Back</span></button></td>');
}
}
if ($oStep->CanMoveForward()) {
$oPage->add('<td style="text-align:right;"><button id="btn_next" class="default ibo-button ibo-is-regular ibo-is-primary" type="submit" name="operation" value="next"><span class="ibo-button--label">'.utils::EscapeHtml($oStep->GetNextButtonLabel()).'</span></button></td>');

View File

@@ -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
{
@@ -128,18 +132,37 @@ INPUT;
</form>
HTML
);
$sButtonLabel = $this->oWizard->GetParameter('return_button_label', '');
SetupLog::Info(__METHOD__.": return_button_label [$sButtonLabel]");
$sButtonUrl = $this->oWizard->GetParameter('return_button_url', '');
if ($sButtonLabel !== '') {
$oPage->add_ready_script(
<<<JS
$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after('<td style="text-align:center;"><button id="return-button" class="ibo-button ibo-is-alternative ibo-is-neutral ibo-is-hidden" type="button" onclick="window.location.href=\'$sButtonUrl\'"><span class="ibo-button--label">$sButtonLabel</span></button></td>');
JS
);
}
}
protected function AddProgressErrorScript($oPage, $aRes)
{
$oPage->add_ready_script(
<<<JS
if ($('#return-button').length > 0) {
$('#return-button').removeClass('ibo-is-hidden');
}
JS
);
if (isset($aRes['error_code']) && $aRes['error_code'] === DataAuditSequencer::DATA_AUDIT_FAILED) {
$oPage->add_ready_script(
<<<EOF
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').before('<td style="text-align:center;"><button class="ibo-button ibo-is-alternative ibo-is-neutral" type="submit" name="operation" value="next" id="ignore_and_continue"><span class="ibo-button--label">Ignore and continue</span></button></td>');
<<<JS
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').after('<td style="text-align:center;"><button class="ibo-button ibo-is-alternative ibo-is-neutral" type="submit" name="operation" value="next" id="ignore_and_continue"><span class="ibo-button--label">Ignore and continue</span></button></td>');
$('#ignore_and_continue').on('click', function() {
return confirm("If you skip the cleanup you won't be able to run the process later. You'll have to migrate or delete unconsistent data manually.");
});
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').after('<td style="text-align:center;"><span id="submit-wait" class="ibo-spinner ibo-is-inline ibo-is-hidden ibo-spinner ibo-block" data-role="ibo-spinner"><i class="ibo-spinner--icon fas fa-sync-alt fa-spin" aria-hidden="true"></i></span>&nbsp;<button id="goto-data-feature-removal" class="default ibo-button ibo-is-regular ibo-is-primary" type="button"><span class="ibo-button--label">Cleanup my data</span></button></td>');
$('.ibo-setup--wizard--buttons-container tr td:nth-child(3)').after('<td style="text-align:center;"><span id="submit-wait" class="ibo-spinner ibo-is-inline ibo-is-hidden ibo-spinner ibo-block" data-role="ibo-spinner"><i class="ibo-spinner--icon fas fa-sync-alt fa-spin" aria-hidden="true"></i></span>&nbsp;<button id="goto-data-feature-removal" class="default ibo-button ibo-is-regular ibo-is-primary" type="button"><span class="ibo-button--label">Cleanup my data</span></button></td>');
$('#goto-data-feature-removal').on("click", function() {
$('#goto-data-feature-removal').prop('disabled', true);
$('#submit-wait').removeClass("ibo-is-hidden");
@@ -148,7 +171,7 @@ HTML
$("#wiz_form").data("installation_status", "cleanup_needed");
$('#btn_next').hide();
EOF
JS
);
}
@@ -161,6 +184,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;';
}
}

View File

@@ -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]");
$sButtonUrl = $this->oWizard->GetParameter('return_button_url', '');
if ($sButtonLabel !== '') {
$oPage->add_ready_script(
<<<JS
$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after('<td style="text-align:center;"><button id="return-button" class="ibo-button ibo-is-alternative ibo-is-neutral ibo-is-hidden" type="button" onclick="window.location.href=\'$sButtonUrl\'"><span class="ibo-button--label">$sButtonLabel</span></button></td>');
JS
);
}
}
/**
* @throws \Exception
*/
@@ -125,27 +146,25 @@ JS);
// Tell the web page to move the progress bar and to launch the next step
$sMessage = addslashes(utils::EscapeHtml($aRes['next-step-label']));
$oPage->add_ready_script(
<<<EOF
$("#wiz_form").data("installation_status", "running");
WizardUpdateButtons();
$('#setup_msg').html('$sMessage');
$('#progress').progression( {Current:{$aRes['percentage-completed']}, Maximum: 100} );
//$("#percentage").html('{$aRes['percentage-completed']} % completed<br/>{$aRes['next-step-label']}');
ExecuteStep('{$aRes['next-step']}');
EOF
<<<JS
$("#wiz_form").data("installation_status", "running");
WizardUpdateButtons();
$('#setup_msg').html('$sMessage');
$('#progress').progression( {Current:{$aRes['percentage-completed']}, Maximum: 100} );
//$("#percentage").html('{$aRes['percentage-completed']} % completed<br/>{$aRes['next-step-label']}');
ExecuteStep('{$aRes['next-step']}');
JS
);
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
} elseif ($aRes['status'] !== StepSequencer::ERROR) {
// Installation complete, move to the next step of the wizard
$oPage->add_ready_script(
<<<EOF
$("#wiz_form").data("installation_status", "completed");
$('#progress').progression( {Current:100, Maximum: 100} );
WizardUpdateButtons();
$("#btn_next").off("click.install");
$("#btn_next").trigger('click');
EOF
<<<JS
$('#progress').progression( {Current:100, Maximum: 100} );
$("#wiz_form").data("installation_status", "completed");
$("#btn_next").trigger('click');
JS
);
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
} else {
@@ -153,12 +172,12 @@ EOF
$sMessage = addslashes(utils::EscapeHtml($aRes['message']));
$sMessage = str_replace("\n", '<br>', $sMessage);
$oPage->add_ready_script(
<<<EOF
$("#wiz_form").data("installation_status", "error");
$("#progress .progress").addClass('progress-error');
WizardUpdateButtons();
$('#setup_error').html('$sMessage').show();
EOF
<<<JS
$("#wiz_form").data("installation_status", "error");
$("#progress .progress").addClass('progress-error');
WizardUpdateButtons();
$('#setup_error').html('$sMessage').show();
JS
);
$this->AddProgressErrorScript($oPage, $aRes);
}
@@ -166,7 +185,13 @@ EOF
protected function AddProgressErrorScript($oPage, $aRes)
{
$oPage->add_ready_script(
<<<JS
if ($('#return-button').length > 0) {
$('#return-button').removeClass('ibo-is-hidden');
}
JS
);
}
/**

View File

@@ -24,6 +24,9 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
$oWizard->SaveParameter('use_symbolic_links', MFCompiler::UseSymbolicLinks());
$oWizard->SaveParameter('force-uninstall', '');
$oWizard->SaveParameter('return_button_label', '');
$oWizard->SaveParameter('return_button_url', '');
// should be done at the end
parent::__construct($oWizard, $sCurrentState, false);
}
@@ -84,7 +87,7 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
return 'Next';
}
public function CanComeBack()
public function CanMoveBackward()
{
return false;
}

View File

@@ -57,6 +57,14 @@ class WizStepSummary 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
{
$this->oWizard->SaveParameter('db_backup', false);
@@ -242,6 +250,19 @@ JS
);
}
public function PostFormDisplay(SetupPage $oPage)
{
$sButtonLabel = $this->oWizard->GetParameter('return_button_label', '');
$sButtonUrl = $this->oWizard->GetParameter('return_button_url', '');
if ($sButtonLabel !== '') {
$oPage->add_ready_script(
<<<JS
$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after('<td style="text-align:center;"><button id="return-button" class="ibo-button ibo-is-alternative ibo-is-neutral" type="button" onclick="window.location.href=\'$sButtonUrl\'"><span class="ibo-button--label">$sButtonLabel</span></button></td>');
JS
);
}
}
/**
* Tells whether the "Next" button should be enabled interactively
* @return string A piece of javascript code returning either true or false
@@ -257,7 +278,11 @@ JS
*/
public function JSCanMoveBackward()
{
return 'return true;';
if ($this->oWizard->GetParameter('return_button_label', '') === '') {
return 'return true;';
}
return 'return false;';
}
}

View File

@@ -18,8 +18,6 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\WebPage\WebPage;
/**
* First step of the iTop Installation Wizard: Welcome screen, requirements
*/
@@ -96,7 +94,7 @@ EOF
}
}
$sStyle = 'style="display:none;overflow:auto;"';
$sToggleButtons = '<button type="button" id="show_details" class="ibo-button ibo-is-alternative ibo-is-neutral" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#hide_details\').toggle();"><span class="ibo-button--icon fa fa-caret-down"></span><span class="ibo-button--label">Show details</span></button><button type="button" id="hide_details" class="ibo-button ibo-is-alternative ibo-is-neutral" style="display:none;" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#show_details\').toggle();"><span class="ibo-button--icon fa fa-caret-up"></span><span class="ibo-button--label">Hide details</span></button>';
$sToggleButtons = '<button type="button" id="show_details" class="ibo-button ibo-is-secondary ibo-is-neutral" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#hide_details\').toggle();"><span class="ibo-button--icon fa fa-caret-down"></span><span class="ibo-button--label">Show details</span></button><button type="button" id="hide_details" class="ibo-button ibo-is-secondary ibo-is-neutral" style="display:none;" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#show_details\').toggle();"><span class="ibo-button--icon fa fa-caret-up"></span><span class="ibo-button--label">Hide details</span></button>';
if (count($aErrors) > 0) {
$sStyle = 'overflow:auto;"';
$sTitle = count($aErrors).' Error(s), '.count($aWarnings).' Warning(s).';

View File

@@ -151,15 +151,6 @@ abstract class WizardStep
return true;
}
/**
* Tells whether the user will come back to this step/state if he click on "Back"
* @return boolean True if the 'Back' button should display this step
*/
public function CanComeBack()
{
return true;
}
/**
* Tells whether the "Next" button should be enabled interactively
* @return string A piece of javascript code returning either true or false