mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fixed update space
This commit is contained in:
@ -431,11 +431,15 @@ class SpaceManagementBloc
|
||||
for (var space in orderedSpaces) {
|
||||
try {
|
||||
if (space.uuid != null && space.uuid!.isNotEmpty) {
|
||||
List<TagModelUpdate> tagUpdates = [];
|
||||
|
||||
final prevSpace = await _api.getSpace(communityUuid, space.uuid!);
|
||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
||||
final List<SubspaceModel>? newSubspaces = space.subspaces;
|
||||
|
||||
tagUpdates = processTagUpdates(prevSpace?.tags, space.tags);
|
||||
|
||||
if (prevSubspaces != null || newSubspaces != null) {
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
@ -497,6 +501,18 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
final response = await _api.updateSpace(
|
||||
communityId: communityUuid,
|
||||
spaceId: space.uuid!,
|
||||
name: space.name,
|
||||
parentId: space.parent?.uuid,
|
||||
isPrivate: space.isPrivate,
|
||||
position: space.position,
|
||||
icon: space.icon,
|
||||
subspaces: subspaceUpdates,
|
||||
tags: tagUpdates,
|
||||
direction: space.incomingConnection?.direction,
|
||||
);
|
||||
} else {
|
||||
// Call create if the space does not have a UUID
|
||||
final List<CreateTagBodyModel> tagBodyModels = space.tags != null
|
||||
@ -514,7 +530,6 @@ class SpaceManagementBloc
|
||||
}).toList() ??
|
||||
[];
|
||||
|
||||
|
||||
final response = await _api.createSpace(
|
||||
communityId: communityUuid,
|
||||
name: space.name,
|
||||
@ -596,7 +611,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
List<TagModelUpdate> processTagUpdates(
|
||||
List<TagModelUpdate> processTagUpdates(
|
||||
List<Tag>? prevTags,
|
||||
List<Tag>? newTags,
|
||||
) {
|
||||
@ -670,5 +685,4 @@ class SpaceManagementBloc
|
||||
|
||||
return tagUpdates;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ class SpaceModel {
|
||||
final instance = SpaceModel(
|
||||
internalId: internalId,
|
||||
uuid: json['uuid'] ?? '',
|
||||
spaceTuyaUuid: json['spaceTuyaUuid'],
|
||||
name: json['spaceName'],
|
||||
isPrivate: json['isPrivate'] ?? false,
|
||||
invitationCode: json['invitationCode'],
|
||||
|
@ -306,7 +306,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
// Set the first space in the center or use passed position
|
||||
Offset centerPosition =
|
||||
position ?? _getCenterPosition(screenSize);
|
||||
print(tags);
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
|
@ -629,7 +629,25 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
products: products,
|
||||
subspaces: subspaces,
|
||||
allTags: [],
|
||||
onSave: (selectedSpaceTags, selectedSubspaces) {},
|
||||
onSave: (selectedSpaceTags, selectedSubspaces) {
|
||||
setState(() {
|
||||
tags = selectedSpaceTags;
|
||||
selectedSpaceModel = null;
|
||||
|
||||
if (selectedSubspaces != null) {
|
||||
if (subspaces != null) {
|
||||
for (final subspace in subspaces!) {
|
||||
for (final selectedSubspace in selectedSubspaces) {
|
||||
if (subspace.subspaceName ==
|
||||
selectedSubspace.subspaceName) {
|
||||
subspace.tags = selectedSubspace.tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
|
Reference in New Issue
Block a user