Fix group removal on escalation only - #483
Conversation
|
Please Fix CI |
| // Do not display a group as a previous assignment while it is still | ||
| // assigned to the ticket. Its history entry stays in the database and | ||
| // becomes visible after a real reassignment removes the group. | ||
| $group_ticket = new Group_Ticket(); | ||
| $currently_assigned = $group_ticket->find([ | ||
| 'tickets_id' => $tickets_id, | ||
| 'type' => CommonITILActor::ASSIGN, | ||
| ]); | ||
|
|
||
| $currently_assigned_ids = array_map( | ||
| static fn(array $actor): int => (int) $actor['groups_id'], | ||
| $currently_assigned, | ||
| ); | ||
|
|
||
| $found = array_filter( | ||
| $found, | ||
| static fn(array $history_entry): bool => !in_array( | ||
| (int) $history_entry['groups_id'], | ||
| $currently_assigned_ids, | ||
| true, | ||
| ), | ||
| ); | ||
|
|
There was a problem hiding this comment.
The "hide currently-assigned groups from history" filter runs unconditionally, including when getHistory($tickets_id, true) is called for the "full assignation history" popup (front/popup_histories.php:50). Two consequences: (1) the popup, meant to be a complete audit trail, will never show a group that happens to still be assigned; (2) since only the single most-recently-modified group is shifted off as "current" (line 170), a ticket with several concurrently assigned groups — a scenario this very PR re-legitimizes via testStandardGroupAssignmentKeepsExistingGroups — will have all but one of its active groups vanish from the widget entirely, shown neither as current nor as history. Was hiding active groups meant to apply only to the compact/inline view ($full_history === false), and not to the full popup?
| ['tickets_id' => $tickets_id], | ||
| ['date_mod DESC', 'id DESC'], | ||
| ); | ||
| $nb_histories = count($found); |
There was a problem hiding this comment.
$nb_histories is captured before the new currently-assigned filter runs, so the "show ... full-history link" check at line 257 ($nb_histories - 1 > self::HISTORY_LIMIT) now overcounts relative to what's actually displayed.
|
Can you rebase ? |
Previously, when the "Remove previously assigned group when assigning a group" option was enabled, adding a group through the standard GLPI actors field also removed all previously assigned groups. Now, previously assigned groups are removed only when the Escalade reassignment action is used. Adding groups through the standard GLPI actors field keeps the existing assigned groups. The visual group assignment history has also been updated so that all groups that were assigned before a reassignment remain visible in the history.
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
ae2fe1f to
45040c7
Compare
Previously, when the "Remove previously assigned group when assigning a group" option was enabled, adding a group through the standard GLPI actors field also removed all previously assigned groups.
Now, previously assigned groups are removed only when the Escalade reassignment action is used. Adding groups through the standard GLPI actors field keeps the existing assigned groups.
The visual group assignment history has also been updated so that all groups that were assigned before a reassignment remain visible in the history.