Refactor group mode switching logic to ensure proper list management
ci / build-backend (push) Successful in 1m36s
ci / build-frontend (push) Successful in 52s
ci / tests (push) Successful in 2m3s
ci / sonar (push) Successful in 6m21s

Updated the Group and UpdateGroupCommandHandler classes to clarify the behavior of group mode switching. The transition to dynamic mode now clears the existing item list to prevent old items from interfering with the new rule-based composition. Enhanced documentation and comments to explain the implications of mode changes. Updated tests to reflect the new behavior, ensuring that the group correctly handles item lists during mode transitions. Localization strings were also updated to inform users about the changes in item management during mode switching.
This commit is contained in:
Leonid Pershin
2026-07-31 04:22:36 +03:00
parent 7163a0b937
commit 375e0a810b
9 changed files with 79 additions and 37 deletions
@@ -209,7 +209,12 @@ export function GroupDetail({ groupId }: Readonly<{ groupId: string }>) {
<span className="font-medium">{t('admin.groups.mode.label')}:</span>
<Select
value={group.mode}
onValueChange={(value) => saveMutation.mutate(value as GroupMode)}
onValueChange={(value) => {
// Смена режима сбрасывает список: в статической он и есть состав, в динамической —
// только поправки к правилу. Переносить его как есть нельзя, но и терять молча тоже.
if (!window.confirm(t('admin.groups.mode.switchConfirm'))) return
saveMutation.mutate(value as GroupMode)
}}
>
<SelectTrigger className="h-8 w-56">
<SelectValue />
+2
View File
@@ -111,6 +111,8 @@ export const en = {
added: 'Items added: {{count}}',
alreadyIn: 'already in group',
mode: {
switchConfirm:
'Switch the mode? The item list will be rebuilt: in a static group it is the composition itself, in a dynamic one — only corrections to the rule.',
label: 'Composition',
Static: 'Explicit list',
Dynamic: 'By rule',
+2
View File
@@ -111,6 +111,8 @@ export const ru = {
added: 'Добавлено позиций: {{count}}',
alreadyIn: 'уже в группе',
mode: {
switchConfirm:
'Сменить режим? Список позиций будет собран заново: в статической группе он и есть состав, в динамической — только поправки к правилу.',
label: 'Состав',
Static: 'Явный список',
Dynamic: 'По правилу',