mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 04:22:28 +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/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/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/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/pages/space_management_v2/modules/space_details/presentation/helpers/space_details_dialog_helper.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -164,6 +166,16 @@ class _CommunityStructureCanvasState extends State<CommunityStructureCanvas>
|
|||||||
context.read<CommunitiesBloc>().add(
|
context.read<CommunitiesBloc>().add(
|
||||||
CommunitiesUpdateCommunity(newCommunity),
|
CommunitiesUpdateCommunity(newCommunity),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
context.read<ReorderSpacesBloc>().add(
|
||||||
|
ReorderSpacesEvent(
|
||||||
|
ReorderSpacesParam(
|
||||||
|
communityUuid: widget.community.uuid,
|
||||||
|
parentSpaceUuid: data.parent?.uuid ?? '',
|
||||||
|
spaces: children,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSpaceTapped(SpaceModel? space) {
|
void _onSpaceTapped(SpaceModel? space) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:dio/dio.dart';
|
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/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/pages/space_management_v2/modules/reorder_spaces/domain/services/reorder_spaces_service.dart';
|
||||||
import 'package:syncrow_web/services/api/api_exception.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 {
|
Future<void> reorderSpaces(ReorderSpacesParam param) async {
|
||||||
try {
|
try {
|
||||||
await _httpClient.post(
|
await _httpClient.post(
|
||||||
path: ApiEndpoints.reorderSpaces,
|
path: await _makeUrl(param),
|
||||||
body: param,
|
body: param.toJson(),
|
||||||
expectedResponseModel: (json) => json,
|
expectedResponseModel: (json) => json,
|
||||||
);
|
);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
@ -32,4 +33,26 @@ final class RemoteReorderSpacesService implements ReorderSpacesService {
|
|||||||
final errorMessage = error?['message'] as String? ?? '';
|
final errorMessage = error?['message'] as String? ?? '';
|
||||||
return errorMessage;
|
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 {
|
class ReorderSpacesParam extends Equatable {
|
||||||
const ReorderSpacesParam({
|
const ReorderSpacesParam({
|
||||||
required this.spaces,
|
|
||||||
required this.communityUuid,
|
required this.communityUuid,
|
||||||
this.parentSpaceUuid,
|
required this.parentSpaceUuid,
|
||||||
|
required this.spaces,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<SpaceModel> spaces;
|
|
||||||
final String communityUuid;
|
final String communityUuid;
|
||||||
final String? parentSpaceUuid;
|
final String parentSpaceUuid;
|
||||||
|
final List<SpaceModel> spaces;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [spaces, communityUuid, parentSpaceUuid];
|
List<Object?> get props => [spaces, communityUuid, parentSpaceUuid];
|
||||||
|
Reference in New Issue
Block a user