diff --git a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart index eaadf671..9e2f6dbb 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart @@ -155,63 +155,76 @@ class CreateSpaceDialogState extends State { }, ), const SizedBox(height: 10), - SpaceModelLinkingWidget( - isSpaceModelDisabled: isSpaceModelDisabled, - onPressed: () { - isSpaceModelDisabled - ? null - : _showLinkSpaceModelDialog(context); - }, - onDeleted: () => setState(() { - selectedSpaceModel = null; - subspaces = widget.subspaces ?? []; - tags = widget.tags ?? []; - }), - screenWidth: screenWidth, - selectedSpaceModel: selectedSpaceModel, - ), + // SpaceModelLinkingWidget( + // isSpaceModelDisabled: true, + // // isSpaceModelDisabled, + // onPressed: () { + // isSpaceModelDisabled + // ? null + // : _showLinkSpaceModelDialog(context); + // }, + // onDeleted: () => setState(() { + // selectedSpaceModel = null; + // subspaces = widget.subspaces ?? []; + // tags = widget.tags ?? []; + // }), + // screenWidth: screenWidth, + // selectedSpaceModel: selectedSpaceModel, + // ), const SizedBox(height: 25), - Row( - children: [ - const Expanded( - child: Divider( - color: ColorsManager.neutralGray, - thickness: 1.0, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 6.0), - child: Text( - 'OR', - style: Theme.of(context) - .textTheme - .bodyMedium - ?.copyWith(fontWeight: FontWeight.bold), - ), - ), - const Expanded( - child: Divider( - color: ColorsManager.neutralGray, - thickness: 1.0, - ), - ), - ], - ), + // Row( + // children: [ + // const Expanded( + // child: Divider( + // color: ColorsManager.neutralGray, + // thickness: 1.0, + // ), + // ), + // Padding( + // padding: const EdgeInsets.symmetric(horizontal: 6.0), + // child: Text( + // 'OR', + // style: Theme.of(context) + // .textTheme + // .bodyMedium + // ?.copyWith(fontWeight: FontWeight.bold), + // ), + // ), + // const Expanded( + // child: Divider( + // color: ColorsManager.neutralGray, + // thickness: 1.0, + // ), + // ), + // ], + // ), const SizedBox(height: 25), SubSpacePartWidget( subspaces: subspaces, onPressed: () { isTagsAndSubspaceModelDisabled ? null - : _showSubSpaceDialog(context, enteredName, [], - false, widget.products, subspaces); + : _showSubSpaceDialog( + context, + enteredName, + [], + false, + widget.products, + subspaces, + ); }, isTagsAndSubspaceModelDisabled: isTagsAndSubspaceModelDisabled, screenWidth: screenWidth, editChipOnTap: () async { - _showSubSpaceDialog(context, enteredName, [], true, - widget.products, subspaces); + _showSubSpaceDialog( + context, + enteredName, + [], + true, + widget.products, + subspaces, + ); }, ), const SizedBox(height: 10), @@ -289,6 +302,13 @@ class CreateSpaceDialogState extends State { ? enteredName : (widget.name ?? ''); if (newName.isNotEmpty) { + if (tags != null && tags!.isNotEmpty) { + if (tags!.any( + (tag) => tag.uuid == null || tag.uuid!.isEmpty, + )) { + return; + } + } widget.onCreateSpace( newName, selectedIcon, @@ -352,12 +372,13 @@ class CreateSpaceDialogState extends State { } void _showSubSpaceDialog( - BuildContext context, - String name, - final List? spaceTags, - bool isEdit, - List? products, - final List? existingSubSpaces) { + BuildContext context, + String name, + final List? spaceTags, + bool isEdit, + List? products, + final List? existingSubSpaces, + ) { showDialog( context: context, builder: (BuildContext context) { @@ -366,7 +387,7 @@ class CreateSpaceDialogState extends State { dialogTitle: isEdit ? 'Edit Sub-spaces' : 'Create Sub-spaces', products: products, existingSubSpaces: existingSubSpaces, - onSave: (slectedSubspaces) { + onSave: (slectedSubspaces, updatedSubSpaces) { final List tagsToAppendToSpace = []; if (slectedSubspaces != null && slectedSubspaces.isNotEmpty) { @@ -378,6 +399,22 @@ class CreateSpaceDialogState extends State { .toList(); for (var s in deletedSubspaces) { if (s.tags != null) { + s.tags!.forEach( + (tag) => tag.location = null, + ); + tagsToAppendToSpace.addAll(s.tags!); + } + } + } + } else { + if (existingSubSpaces != null) { + final deletedSubspaces = existingSubSpaces; + + for (var s in deletedSubspaces) { + if (s.tags != null) { + s.tags!.forEach( + (tag) => tag.location = null, + ); tagsToAppendToSpace.addAll(s.tags!); } }