fixed issue in creating space

This commit is contained in:
hannathkadher
2025-02-02 21:02:58 +04:00
parent 916b606cb1
commit 91dfd53477
6 changed files with 110 additions and 57 deletions

View File

@ -457,7 +457,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
context: context,
builder: (context) => AssignTagDialog(
products: widget.products,
subspaces: widget.subspaces,
subspaces: subspaces,
addedProducts: TagHelper
.createInitialSelectedProductsForTags(
tags ?? [], subspaces),
@ -488,7 +488,6 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
enteredName,
widget.isEdit,
widget.products,
subspaces,
);
},
style: TextButton.styleFrom(
@ -617,9 +616,26 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
products: products,
existingSubSpaces: existingSubSpaces,
onSave: (slectedSubspaces) {
final List<Tag> tagsToAppendToSpace = [];
if (slectedSubspaces != null) {
final updatedIds =
slectedSubspaces.map((s) => s.internalId).toSet();
if (existingSubSpaces != null) {
final deletedSubspaces = existingSubSpaces
.where((s) => !updatedIds.contains(s.internalId))
.toList();
for (var s in deletedSubspaces) {
if (s.tags != null) {
tagsToAppendToSpace.addAll(s.tags!);
}
}
}
}
if (slectedSubspaces != null) {
setState(() {
subspaces = slectedSubspaces;
tags?.addAll(tagsToAppendToSpace);
selectedSpaceModel = null;
});
}
@ -629,7 +645,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
}
void _showTagCreateDialog(BuildContext context, String name, bool isEdit,
List<ProductModel>? products, List<SubspaceModel>? subspaces) {
List<ProductModel>? products) {
isEdit
? showDialog(
context: context,