mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Enhance Community Structure Widgets: Updated SpaceDetailsDialogHelper to accept community UUID for space creation and editing. Refactored CreateSpaceButton and CommunityStructureHeader to pass community UUID, improving data handling and consistency across the community structure features.
This commit is contained in:
@ -241,7 +241,10 @@ class _CommunityStructureCanvasState extends State<CommunityStructureCanvas>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onTap: () => SpaceDetailsDialogHelper.showCreate(context),
|
onTap: () => SpaceDetailsDialogHelper.showCreate(
|
||||||
|
context,
|
||||||
|
communityUuid: widget.community.uuid,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -55,8 +55,9 @@ class CommunityStructureHeader extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Community Structure',
|
'Community Structure',
|
||||||
style: theme.textTheme.headlineLarge
|
style: theme.textTheme.headlineLarge?.copyWith(
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (selectedCommunity != null)
|
if (selectedCommunity != null)
|
||||||
Row(
|
Row(
|
||||||
@ -67,8 +68,9 @@ class CommunityStructureHeader extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: SelectableText(
|
child: SelectableText(
|
||||||
selectedCommunity.name,
|
selectedCommunity.name,
|
||||||
style: theme.textTheme.bodyLarge
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -93,13 +95,11 @@ class CommunityStructureHeader extends StatelessWidget {
|
|||||||
CommunityStructureHeaderActionButtons(
|
CommunityStructureHeaderActionButtons(
|
||||||
onDelete: (space) {},
|
onDelete: (space) {},
|
||||||
onDuplicate: (space) {},
|
onDuplicate: (space) {},
|
||||||
onEdit: (space) {
|
onEdit: (space) => SpaceDetailsDialogHelper.showEdit(
|
||||||
SpaceDetailsDialogHelper.showEdit(
|
|
||||||
context,
|
context,
|
||||||
spaceModel: selectedSpace!,
|
spaceModel: selectedSpace!,
|
||||||
communityUuid: selectedCommunity.uuid,
|
communityUuid: selectedCommunity.uuid,
|
||||||
);
|
),
|
||||||
},
|
|
||||||
selectedSpace: selectedSpace,
|
selectedSpace: selectedSpace,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -3,12 +3,20 @@ import 'package:syncrow_web/pages/space_management_v2/modules/space_details/pres
|
|||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class CreateSpaceButton extends StatelessWidget {
|
class CreateSpaceButton extends StatelessWidget {
|
||||||
const CreateSpaceButton({super.key});
|
const CreateSpaceButton({
|
||||||
|
required this.communityUuid,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String communityUuid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => SpaceDetailsDialogHelper.showCreate(context),
|
onTap: () => SpaceDetailsDialogHelper.showCreate(
|
||||||
|
context,
|
||||||
|
communityUuid: communityUuid,
|
||||||
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 60,
|
height: 60,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -16,8 +16,14 @@ class SpaceManagementCommunityStructure extends StatelessWidget {
|
|||||||
const spacer = Spacer(flex: 10);
|
const spacer = Spacer(flex: 10);
|
||||||
return Visibility(
|
return Visibility(
|
||||||
visible: selectedCommunity!.spaces.isNotEmpty,
|
visible: selectedCommunity!.spaces.isNotEmpty,
|
||||||
replacement: const Row(
|
replacement: Row(
|
||||||
children: [spacer, Expanded(child: CreateSpaceButton()), spacer],
|
children: [
|
||||||
|
spacer,
|
||||||
|
Expanded(
|
||||||
|
child: CreateSpaceButton(communityUuid: selectedCommunity.uuid),
|
||||||
|
),
|
||||||
|
spacer
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
@ -11,7 +11,10 @@ import 'package:syncrow_web/pages/space_management_v2/modules/update_space/prese
|
|||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
abstract final class SpaceDetailsDialogHelper {
|
abstract final class SpaceDetailsDialogHelper {
|
||||||
static void showCreate(BuildContext context) {
|
static void showCreate(
|
||||||
|
BuildContext context, {
|
||||||
|
required String communityUuid,
|
||||||
|
}) {
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => MultiBlocProvider(
|
builder: (_) => MultiBlocProvider(
|
||||||
@ -33,6 +36,7 @@ abstract final class SpaceDetailsDialogHelper {
|
|||||||
title: const SelectableText('Create Space'),
|
title: const SelectableText('Create Space'),
|
||||||
spaceModel: SpaceModel.empty(),
|
spaceModel: SpaceModel.empty(),
|
||||||
onSave: (space) {},
|
onSave: (space) {},
|
||||||
|
communityUuid: communityUuid,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -74,6 +78,7 @@ abstract final class SpaceDetailsDialogHelper {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
communityUuid: communityUuid,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/domain/models/space_model.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/space_details/domain/models/space_details_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/bloc/space_details_bloc.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/bloc/space_details_bloc.dart';
|
||||||
@ -15,6 +14,7 @@ class SpaceDetailsDialog extends StatefulWidget {
|
|||||||
required this.spaceModel,
|
required this.spaceModel,
|
||||||
required this.onSave,
|
required this.onSave,
|
||||||
required this.context,
|
required this.context,
|
||||||
|
required this.communityUuid,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ class SpaceDetailsDialog extends StatefulWidget {
|
|||||||
final SpaceModel spaceModel;
|
final SpaceModel spaceModel;
|
||||||
final void Function(SpaceDetailsModel space) onSave;
|
final void Function(SpaceDetailsModel space) onSave;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
final String communityUuid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SpaceDetailsDialog> createState() => _SpaceDetailsDialogState();
|
State<SpaceDetailsDialog> createState() => _SpaceDetailsDialogState();
|
||||||
@ -35,11 +36,7 @@ class _SpaceDetailsDialogState extends State<SpaceDetailsDialog> {
|
|||||||
if (!isCreateMode) {
|
if (!isCreateMode) {
|
||||||
final param = LoadSpaceDetailsParam(
|
final param = LoadSpaceDetailsParam(
|
||||||
spaceUuid: widget.spaceModel.uuid,
|
spaceUuid: widget.spaceModel.uuid,
|
||||||
communityUuid: widget.context
|
communityUuid: widget.communityUuid,
|
||||||
.read<CommunitiesTreeSelectionBloc>()
|
|
||||||
.state
|
|
||||||
.selectedCommunity!
|
|
||||||
.uuid,
|
|
||||||
);
|
);
|
||||||
widget.context.read<SpaceDetailsBloc>().add(LoadSpaceDetails(param));
|
widget.context.read<SpaceDetailsBloc>().add(LoadSpaceDetails(param));
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,38 @@ class UpdateSpaceParam {
|
|||||||
|
|
||||||
final SpaceDetailsModel space;
|
final SpaceDetailsModel space;
|
||||||
final String communityUuid;
|
final String communityUuid;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'spaceName': space.spaceName,
|
||||||
|
'icon': space.icon,
|
||||||
|
'subspaces': space.subspaces
|
||||||
|
.map(
|
||||||
|
(e) => {
|
||||||
|
'subspaceName': e.name,
|
||||||
|
'productAllocations': e.productAllocations
|
||||||
|
.map(
|
||||||
|
(e) => {
|
||||||
|
'name': e.tag.name,
|
||||||
|
'productUuid': e.product.uuid,
|
||||||
|
'uuid': e.uuid,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
'uuid': e.uuid,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
'productAllocations': space.productAllocations
|
||||||
|
.map(
|
||||||
|
(e) => {
|
||||||
|
'tagName': e.tag.name,
|
||||||
|
'tagUuid': e.tag.uuid,
|
||||||
|
'productUuid': e.product.uuid,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
'spaceModelUuid': space.uuid,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user