mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-24 20:22:27 +00:00
Integrate ReorderSpaces functionality into CommunityStructureCanvas and enhance RemoteReorderSpacesService with dynamic URL generation. Update ReorderSpacesParam to require parentSpaceUuid and spaces for improved validation and serialization.
This commit is contained in:
@ -11,6 +11,8 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/domain/params/reorder_spaces_param.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/presentation/bloc/reorder_spaces_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/helpers/space_details_dialog_helper.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
@ -164,6 +166,16 @@ class _CommunityStructureCanvasState extends State<CommunityStructureCanvas>
|
||||
context.read<CommunitiesBloc>().add(
|
||||
CommunitiesUpdateCommunity(newCommunity),
|
||||
);
|
||||
|
||||
context.read<ReorderSpacesBloc>().add(
|
||||
ReorderSpacesEvent(
|
||||
ReorderSpacesParam(
|
||||
communityUuid: widget.community.uuid,
|
||||
parentSpaceUuid: data.parent?.uuid ?? '',
|
||||
spaces: children,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onSpaceTapped(SpaceModel? space) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/domain/params/reorder_spaces_param.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/domain/services/reorder_spaces_service.dart';
|
||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||
@ -14,8 +15,8 @@ final class RemoteReorderSpacesService implements ReorderSpacesService {
|
||||
Future<void> reorderSpaces(ReorderSpacesParam param) async {
|
||||
try {
|
||||
await _httpClient.post(
|
||||
path: ApiEndpoints.reorderSpaces,
|
||||
body: param,
|
||||
path: await _makeUrl(param),
|
||||
body: param.toJson(),
|
||||
expectedResponseModel: (json) => json,
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
@ -32,4 +33,26 @@ final class RemoteReorderSpacesService implements ReorderSpacesService {
|
||||
final errorMessage = error?['message'] as String? ?? '';
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
Future<String> _makeUrl(ReorderSpacesParam param) async {
|
||||
final projectUuid = await ProjectManager.getProjectUUID();
|
||||
final communityUuid = param.communityUuid;
|
||||
|
||||
if (projectUuid == null || projectUuid.isEmpty) {
|
||||
throw APIException('Project UUID is not set');
|
||||
}
|
||||
|
||||
if (communityUuid.isEmpty) {
|
||||
throw APIException('Community UUID is not set');
|
||||
}
|
||||
|
||||
if (param.parentSpaceUuid.isEmpty) {
|
||||
throw APIException('Parent Space UUID is not set');
|
||||
}
|
||||
|
||||
return ApiEndpoints.reorderSpaces
|
||||
.replaceAll('{projectUuid}', projectUuid)
|
||||
.replaceAll('{communityUuid}', communityUuid)
|
||||
.replaceAll('{parentSpaceUuid}', param.parentSpaceUuid);
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain
|
||||
|
||||
class ReorderSpacesParam extends Equatable {
|
||||
const ReorderSpacesParam({
|
||||
required this.spaces,
|
||||
required this.communityUuid,
|
||||
this.parentSpaceUuid,
|
||||
required this.parentSpaceUuid,
|
||||
required this.spaces,
|
||||
});
|
||||
|
||||
final List<SpaceModel> spaces;
|
||||
final String communityUuid;
|
||||
final String? parentSpaceUuid;
|
||||
final String parentSpaceUuid;
|
||||
final List<SpaceModel> spaces;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [spaces, communityUuid, parentSpaceUuid];
|
||||
|
Reference in New Issue
Block a user