mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-07-26 11:59:14 +00:00
Fix nested condition display in dynamic group builder
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/fcf50376-b9ed-4d4a-a1cf-906b0aa23dae.jpg
This commit is contained in:
@@ -83,6 +83,7 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
||||
const addCondition = (parentId?: number | null) => {
|
||||
const newCondition: Condition = {
|
||||
...defaultCondition,
|
||||
id: Math.max(0, ...conditions.map(c => c.id || 0)) + 1, // Generate a new ID
|
||||
parentId
|
||||
};
|
||||
|
||||
@@ -105,8 +106,12 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
||||
|
||||
// Handle adding a new condition group
|
||||
const addConditionGroup = (parentId?: number | null) => {
|
||||
// Generate a new ID for the group
|
||||
const newId = Math.max(0, ...conditions.map(c => c.id || 0)) + 1;
|
||||
|
||||
const newGroup: Condition = {
|
||||
...defaultGroup,
|
||||
id: newId, // Assign the new ID
|
||||
parentId
|
||||
};
|
||||
|
||||
@@ -122,16 +127,14 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
||||
const newConditions = [...conditions];
|
||||
newConditions.splice(insertIndex, 0, newGroup);
|
||||
onChange(newConditions);
|
||||
|
||||
// Automatically expand the new group
|
||||
if (newGroup.id) {
|
||||
setExpandedGroups(prev => {
|
||||
const expanded = new Set(prev);
|
||||
expanded.add(newGroup.id!);
|
||||
return expanded;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically expand the new group
|
||||
setExpandedGroups(prev => {
|
||||
const expanded = new Set(prev);
|
||||
expanded.add(newId);
|
||||
return expanded;
|
||||
});
|
||||
};
|
||||
|
||||
// Handle updating a condition
|
||||
|
||||
Reference in New Issue
Block a user