added tags and subspace to update space

This commit is contained in:
hannathkadher
2025-01-29 09:55:36 +04:00
parent 45b0b67fe0
commit 9331193e90
4 changed files with 205 additions and 37 deletions

View File

@ -79,6 +79,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
widget.selectedProducts.isNotEmpty ? widget.selectedProducts : [];
isOkButtonEnabled =
enteredName.isNotEmpty || nameController.text.isNotEmpty;
tags = widget.tags ?? [];
subspaces = widget.subspaces ?? [];
}
@override
@ -237,7 +239,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
),
)
: Container(
width: screenWidth * 0.35,
width: screenWidth * 0.25,
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 16.0),
decoration: BoxDecoration(
@ -312,7 +314,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
],
),
const SizedBox(height: 25),
subspaces == null
subspaces == null || subspaces!.isEmpty
? TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
@ -344,21 +346,29 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
runSpacing: 8.0,
children: [
if (subspaces != null)
...subspaces!.map((subspace) =>
SubspaceNameDisplayWidget(
validateName: (updatedName) {
return !subspaces!.any((s) =>
s != subspace &&
s.subspaceName == updatedName);
},
text: subspace.subspaceName,
onNameChanged: (updatedName) {
setState(() {
subspace.subspaceName =
updatedName;
});
},
)),
...subspaces!.map((subspace) {
return Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SubspaceNameDisplayWidget(
text: subspace.subspaceName,
validateName: (updatedName) {
return subspaces!.any((s) =>
s != subspace &&
s.subspaceName ==
updatedName);
},
onNameChanged: (updatedName) {
setState(() {
subspace.subspaceName =
updatedName;
});
},
),
],
);
}),
EditChip(
onTap: () async {
_showSubSpaceDialog(context, enteredName,
@ -425,14 +435,29 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
),
EditChip(onTap: () async {
_showTagCreateDialog(
context,
enteredName,
widget.isEdit,
widget.products,
subspaces,
final result = await showDialog(
context: context,
builder: (context) => AssignTagDialog(
products: widget.products,
subspaces: widget.subspaces,
addedProducts: TagHelper
.createInitialSelectedProductsForTags(
tags ?? [], subspaces),
title: 'Edit Device',
initialTags:
TagHelper.generateInitialForTags(
spaceTags: tags,
subspaces: subspaces),
spaceName: widget.name ?? '',
onSave:
(updatedTags, updatedSubspaces) {
setState(() {
tags = updatedTags;
subspaces = updatedSubspaces;
});
},
),
);
// Edit action
})
],
),
@ -547,6 +572,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
setState(() {
selectedSpaceModel = selectedModel;
subspaces = null;
tags = null;
});
}
},
@ -610,6 +636,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
products: products,
subspaces: subspaces,
spaceTags: tags,
isCreate: true,
allTags: [],
initialSelectedProducts:
TagHelper.createInitialSelectedProductsForTags(