Compare commits

..

5 Commits

Author SHA1 Message Date
2d3345c1d9 fixed issue in subspace updatw 2025-03-19 21:48:44 +04:00
5e05b20f68 Merge pull request #118 from SyncrowIOT/SP-1318
Sp 1318
2025-03-17 09:34:16 +04:00
95730cc2ba Merge pull request #119 from SyncrowIOT/SP-1327
append space id to list
2025-03-17 09:33:28 +04:00
a5a37f3841 append space id to list 2025-03-14 14:10:03 +04:00
5b2822f973 Merge pull request #117 from SyncrowIOT/SP-1318
Sp 1318
2025-03-13 14:51:54 +04:00
3 changed files with 20 additions and 46 deletions

View File

@ -37,8 +37,9 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
List<CommunityModel> list = state.isSearching ? state.filteredCommunity : state.communityList; List<CommunityModel> list = state.isSearching ? state.filteredCommunity : state.communityList;
return Container( return Container(
height: MediaQuery.sizeOf(context).height, height: MediaQuery.sizeOf(context).height,
color: ColorsManager.whiteColors, decoration: widget.isSide == true
decoration: widget.isSide == true ? subSectionContainerDecoration : null, ? subSectionContainerDecoration.copyWith(color: ColorsManager.whiteColors)
: const BoxDecoration(color: ColorsManager.whiteColors),
child: state is SpaceTreeLoadingState child: state is SpaceTreeLoadingState
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: Column( : Column(

View File

@ -262,27 +262,6 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
return; return;
} }
if (communities.isEmpty) {
communities = await _api.fetchCommunities(projectUuid);
List<CommunityModel> updatedCommunities = await Future.wait(
communities.map((community) async {
List<SpaceModel> spaces = await _fetchSpacesForCommunity(community.uuid);
return CommunityModel(
uuid: community.uuid,
createdAt: community.createdAt,
updatedAt: community.updatedAt,
name: community.name,
description: community.description,
spaces: spaces,
region: community.region,
);
}).toList(),
);
communities = updatedCommunities;
}
emit(BlankState( emit(BlankState(
spaceModels: prevSpaceModels, spaceModels: prevSpaceModels,
communities: communities, communities: communities,
@ -540,7 +519,7 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
List<TagModelUpdate> tagUpdates = []; List<TagModelUpdate> tagUpdates = [];
List<SpaceModel> matchedSpaces = List<SpaceModel> matchedSpaces =
selectedCommunity.spaces.where((space) => space.uuid == space.uuid).toList(); findMatchingSpaces(selectedCommunity.spaces, space.uuid!);
if (matchedSpaces.isEmpty) continue; if (matchedSpaces.isEmpty) continue;
@ -696,27 +675,6 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
var prevSpaceModels = await fetchSpaceModels(); var prevSpaceModels = await fetchSpaceModels();
if (communities.isEmpty) {
communities = await _api.fetchCommunities(projectUuid);
List<CommunityModel> updatedCommunities = await Future.wait(
communities.map((community) async {
List<SpaceModel> spaces = await _fetchSpacesForCommunity(community.uuid);
return CommunityModel(
uuid: community.uuid,
createdAt: community.createdAt,
updatedAt: community.updatedAt,
name: community.name,
description: community.description,
spaces: spaces,
region: community.region,
);
}).toList(),
);
communities = updatedCommunities;
}
emit(SpaceModelLoaded( emit(SpaceModelLoaded(
communities: communities, communities: communities,
products: _cachedProducts ?? [], products: _cachedProducts ?? [],
@ -799,4 +757,18 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
return tagUpdates; return tagUpdates;
} }
List<SpaceModel> findMatchingSpaces(List<SpaceModel> spaces, String targetUuid) {
List<SpaceModel> matched = [];
for (var space in spaces) {
if (space.uuid == targetUuid) {
matched.add(space);
}
matched
.addAll(findMatchingSpaces(space.children, targetUuid)); // Recursively search in children
}
return matched;
}
} }

View File

@ -28,10 +28,11 @@ class LinkSpaceToModelBloc
try { try {
BuildContext context = NavigationService.navigatorKey.currentContext!; BuildContext context = NavigationService.navigatorKey.currentContext!;
var spaceBloc = context.read<SpaceTreeBloc>(); var spaceBloc = context.read<SpaceTreeBloc>();
spacesListIds.clear();
for (var communityId in spaceBloc.state.selectedCommunities) { for (var communityId in spaceBloc.state.selectedCommunities) {
List<String> spacesList = List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? []; spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
spacesListIds = spacesList; spacesListIds.addAll(spacesList);
} }
hasSelectedSpaces = hasSelectedSpaces =
spaceBloc.state.selectedCommunities.any((communityId) { spaceBloc.state.selectedCommunities.any((communityId) {