Refactor group mode switching logic to ensure proper list management
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:
@@ -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 />
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -111,6 +111,8 @@ export const ru = {
|
||||
added: 'Добавлено позиций: {{count}}',
|
||||
alreadyIn: 'уже в группе',
|
||||
mode: {
|
||||
switchConfirm:
|
||||
'Сменить режим? Список позиций будет собран заново: в статической группе он и есть состав, в динамической — только поправки к правилу.',
|
||||
label: 'Состав',
|
||||
Static: 'Явный список',
|
||||
Dynamic: 'По правилу',
|
||||
|
||||
Reference in New Issue
Block a user