Skip to content

N°3366 - Multiple target state on approbal-extended #7

Draft
accognet wants to merge 9 commits into
masterfrom
feature/3366-Mutiple_target_state_on_approbal-extended
Draft

N°3366 - Multiple target state on approbal-extended #7
accognet wants to merge 9 commits into
masterfrom
feature/3366-Mutiple_target_state_on_approbal-extended

Conversation

@accognet
Copy link
Copy Markdown
Contributor

@accognet accognet commented Jun 24, 2024

need change in approval base (branche feature/3366-Add_status_informations_on_approval )

Allows you to configure which classes are affected by the approval and from which statuses. Multiple starting statuses are allowed for a class.

new configuration for this module:

_'combodo-approval-extended' => array (
	'targets' => array (
	  'UserRequest' => 
	  array (
	    'target_states' => ['new','assigned'],
	    'bypass_profiles' => 'Service Manager',
	    'reuse_previous_answers' => true,
	  ),
	)
),_

You can configure different triggers to send different messages for approval:
image

Different approval stages are visible on the object in the Approval tab with the starting and ending status (thanks to the functionality implemented in the approval-base)
image

@accognet accognet self-assigned this Jun 24, 2024
@accognet accognet added the enhancement New feature or request label Jun 24, 2024
@Hipska
Copy link
Copy Markdown

Hipska commented Jun 25, 2024

Sounds interesting, does that mean it could be used to have a ruleset for NormalChange objects to go from new to validated/rejected and also from planned to approved/notapproved?

In your example I see it went from assigned towards escalated_ttr. Is there a way to specify what the target state should be?

@accognet
Copy link
Copy Markdown
Contributor Author

Yes, this is the target.
The target status is defined in XML as the current approval with 2 transitions: ev_approve and ev_reject

@Hipska
Copy link
Copy Markdown

Hipska commented Jun 25, 2024

Okay, so the transitions from starting state towards ending state should be named exactly ev_approve and ev_reject?

Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread datamodel.combodo-approval-extended.xml Outdated
@accognet
Copy link
Copy Markdown
Contributor Author

There are a lot of logs, because the code is not finished yet. I still have to do a lot of tests to validate this code. To not forget what I did I have already created the PR. I will have time in August to finish it.

@Hipska
Copy link
Copy Markdown

Hipska commented Jul 12, 2024

Sure, I gave suggestions to apply correct line indentations and log debug messages as actual debug, not error ;)

@Molkobain
Copy link
Copy Markdown
Contributor

Support PRs review:

  • Don't forget to add the conf migration during setup, see combodo-autoclose-tickets for an equivalent example
  • Change target_state to target_states
  • Change target_states format from a CSV list to an array (will work out of the box when config edition wil be through GUI)
  • Mind to add the target_states default value in HideButtonsPlugin::OnDisplayProperties()

Good :

  • Store start/end states instead of computing them on the fly, that way what has been done won't change even in case of conf / lifecycle changes
  • New conf format

Sounds nice! Will take a closer look.

Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread datamodel.combodo-approval-extended.xml Outdated
Molkobain and others added 3 commits August 12, 2024 17:42
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
Copy link
Copy Markdown

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentations sometimes still not correct. (Is your IDE correctly configured?)

Also, what with users that already have customised their config? Shouldn't there be a migration method during iTop Setup? Currently the old config is ignored and reverted to default.

Comment thread datamodel.combodo-approval-extended.xml Outdated
Comment thread main.combodo-approval-extended.php
Comment thread main.combodo-approval-extended.php Outdated
@Molkobain
Copy link
Copy Markdown
Contributor

Also, what with users that already have customised their config? Shouldn't there be a migration method during iTop Setup? Currently the old config is ignored and reverted to default.

Totally, the config migration was asked during the support PRs review:

  • Don't forget to add the conf migration during setup, see combodo-autoclose-tickets for an equivalent example

Copy link
Copy Markdown

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installer looks good 👍

Comment thread module.combodo-approval-extended.php
Comment thread module.combodo-approval-extended.php
Comment thread main.combodo-approval-extended.php Outdated
Comment thread main.combodo-approval-extended.php
Comment thread datamodel.combodo-approval-extended.xml Outdated
accognet and others added 2 commits September 17, 2024 16:00
Copy link
Copy Markdown

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the code looks much more readable now. Some minor remarks:

Comment on lines +93 to +102
// Replacing old conf parameters value to indicate that it is obsolete
$aParamsToRemove = array('target_states', 'bypass_profiles', 'reuse_previous_answers');
foreach($aParamsToRemove as $sParamToRemove)
{
$sParamCurrentValue = $oConfiguration->GetModuleSetting('combodo-approval-extended', $sParamToRemove, null);
if(!empty($sParamCurrentValue))
{
$oConfiguration->SetModuleSetting('combodo-approval-extended', $sParamToRemove, 'No longer used, you can remove this parameter.');
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this section, since you said this: https://github.com/Combodo/combodo-approval-extended/pull/7/files#r1763440755

Comment on lines +84 to +90
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_states', null) ],
'bypass_profiles' =>$oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Service Manager') ,
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true) ,
]
];
Copy link
Copy Markdown

@Hipska Hipska Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some indentation problem, a typo and to keep backward compatibility, the admin profile should also be included when migrating.

Suggested change
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_states', null) ],
'bypass_profiles' =>$oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Service Manager') ,
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true) ,
]
];
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_state', 'new')],
'bypass_profiles' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Administrator, Service Manager'),
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true),
]
];

Comment on lines +389 to +390
$aAllowedClasses = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aAllowedClasses) === false) {
Copy link
Copy Markdown

@Hipska Hipska Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense later in the code when this var is named differently..

Suggested change
$aAllowedClasses = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aAllowedClasses) === false) {
$aTargets = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aTargets) === false) {

@Hipska
Copy link
Copy Markdown

Hipska commented Dec 16, 2025

Hi @accognet @jf-cbd Could this PR be revived and added to the project maybe?

@github-project-automation github-project-automation Bot moved this to First review needed in Combodo PRs dashboard Dec 17, 2025
@accognet accognet moved this from First review needed to Pending functional review in Combodo PRs dashboard Dec 17, 2025
@jf-cbd jf-cbd moved this from Pending functional review to Pending review in Combodo PRs dashboard Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Pending review

Development

Successfully merging this pull request may close these issues.

4 participants