diff --git a/lib/pages/roles_and_permission/users_page/add_user_dialog/view/add_user_dialog.dart b/lib/pages/roles_and_permission/users_page/add_user_dialog/view/add_user_dialog.dart index 1a487830..44ba81ff 100644 --- a/lib/pages/roles_and_permission/users_page/add_user_dialog/view/add_user_dialog.dart +++ b/lib/pages/roles_and_permission/users_page/add_user_dialog/view/add_user_dialog.dart @@ -24,7 +24,7 @@ class _AddNewUserDialogState extends State { Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => UsersBloc() - ..add(const LoadCommunityAndSpacesEvent()) + // ..add(const LoadCommunityAndSpacesEvent()) ..add(const RoleEvent()), child: BlocConsumer( listener: (context, state) {}, diff --git a/lib/pages/roles_and_permission/users_page/add_user_dialog/view/edit_user_dialog.dart b/lib/pages/roles_and_permission/users_page/add_user_dialog/view/edit_user_dialog.dart index 22c603ab..071de067 100644 --- a/lib/pages/roles_and_permission/users_page/add_user_dialog/view/edit_user_dialog.dart +++ b/lib/pages/roles_and_permission/users_page/add_user_dialog/view/edit_user_dialog.dart @@ -26,13 +26,12 @@ class _EditUserDialogState extends State { Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => UsersBloc() - ..add(const LoadCommunityAndSpacesEvent()) + // ..add(const LoadCommunityAndSpacesEvent()) ..add(const RoleEvent()) ..add(GetUserByIdEvent(uuid: widget.userId)), child: BlocConsumer(listener: (context, state) { if (state is SpacesLoadedState) { - BlocProvider.of(context) - .add(GetUserByIdEvent(uuid: widget.userId)); + BlocProvider.of(context).add(GetUserByIdEvent(uuid: widget.userId)); } }, builder: (context, state) { final _blocRole = BlocProvider.of(context); @@ -40,8 +39,7 @@ class _EditUserDialogState extends State { return Dialog( child: Container( decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(20))), + color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))), width: 900, child: Column( children: [ @@ -70,8 +68,7 @@ class _EditUserDialogState extends State { children: [ _buildStep1Indicator(1, "Basics", _blocRole), _buildStep2Indicator(2, "Spaces", _blocRole), - _buildStep3Indicator( - 3, "Role & Permissions", _blocRole), + _buildStep3Indicator(3, "Role & Permissions", _blocRole), ], ), ), @@ -119,15 +116,13 @@ class _EditUserDialogState extends State { if (currentStep < 3) { currentStep++; if (currentStep == 2) { - _blocRole - .add(CheckStepStatus(isEditUser: true)); + _blocRole.add(CheckStepStatus(isEditUser: true)); } else if (currentStep == 3) { _blocRole.add(const CheckSpacesStepStatus()); } } else { - _blocRole.add(EditInviteUsers( - context: context, - userId: widget.userId!)); + _blocRole + .add(EditInviteUsers(context: context, userId: widget.userId!)); } }); }, @@ -136,8 +131,7 @@ class _EditUserDialogState extends State { style: TextStyle( color: (_blocRole.isCompleteSpaces == false || _blocRole.isCompleteBasics == false || - _blocRole.isCompleteRolePermissions == - false) && + _blocRole.isCompleteRolePermissions == false) && currentStep == 3 ? ColorsManager.grayColor : ColorsManager.secondaryColor), @@ -210,12 +204,8 @@ class _EditUserDialogState extends State { label, style: TextStyle( fontSize: 16, - color: currentStep == step - ? ColorsManager.blackColor - : ColorsManager.greyColor, - fontWeight: currentStep == step - ? FontWeight.bold - : FontWeight.normal, + color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor, + fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal, ), ), ], @@ -273,12 +263,8 @@ class _EditUserDialogState extends State { label, style: TextStyle( fontSize: 16, - color: currentStep == step - ? ColorsManager.blackColor - : ColorsManager.greyColor, - fontWeight: currentStep == step - ? FontWeight.bold - : FontWeight.normal, + color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor, + fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal, ), ), ], @@ -335,12 +321,8 @@ class _EditUserDialogState extends State { label, style: TextStyle( fontSize: 16, - color: currentStep == step - ? ColorsManager.blackColor - : ColorsManager.greyColor, - fontWeight: currentStep == step - ? FontWeight.bold - : FontWeight.normal, + color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor, + fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal, ), ), ], diff --git a/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart b/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart index 76011358..b5455646 100644 --- a/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart +++ b/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart @@ -427,6 +427,7 @@ class UsersPage extends StatelessWidget { isActive: true, title: "Edit", onTap: () { + context.read().add(ClearCachedData()); showDialog( context: context, barrierDismissible: false, diff --git a/lib/pages/routines/view/routines_view.dart b/lib/pages/routines/view/routines_view.dart index 0982601e..b0efb4a9 100644 --- a/lib/pages/routines/view/routines_view.dart +++ b/lib/pages/routines/view/routines_view.dart @@ -7,7 +7,6 @@ import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_vie import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart'; import 'package:syncrow_web/utils/color_manager.dart'; -import 'package:syncrow_web/utils/snack_bar.dart'; class RoutinesView extends StatefulWidget { const RoutinesView({super.key}); diff --git a/lib/pages/space_tree/bloc/space_tree_bloc.dart b/lib/pages/space_tree/bloc/space_tree_bloc.dart index c2a26164..e7fb4dc1 100644 --- a/lib/pages/space_tree/bloc/space_tree_bloc.dart +++ b/lib/pages/space_tree/bloc/space_tree_bloc.dart @@ -91,6 +91,7 @@ class SpaceTreeBloc extends Bloc { List updatedSelectedSpaces = List.from(state.selectedSpaces.toSet().toList()); List updatedSoldChecks = List.from(state.soldCheck.toSet().toList()); Map> communityAndSpaces = Map.from(state.selectedCommunityAndSpaces); + List selectedSpacesInCommunity = communityAndSpaces[event.communityId] ?? []; List childrenIds = _getAllChildIds(event.children); @@ -98,14 +99,16 @@ class SpaceTreeBloc extends Bloc { // Select the community and all its children updatedSelectedCommunities.add(event.communityId); updatedSelectedSpaces.addAll(childrenIds); + selectedSpacesInCommunity.addAll(childrenIds); } else { // Unselect the community and all its children updatedSelectedCommunities.remove(event.communityId); updatedSelectedSpaces.removeWhere(childrenIds.contains); updatedSoldChecks.removeWhere(childrenIds.contains); + selectedSpacesInCommunity.removeWhere(childrenIds.contains); } - communityAndSpaces[event.communityId] = updatedSelectedSpaces; + communityAndSpaces[event.communityId] = selectedSpacesInCommunity; emit(state.copyWith( selectedCommunities: updatedSelectedCommunities, @@ -125,6 +128,8 @@ class SpaceTreeBloc extends Bloc { List updatedSoldChecks = List.from(state.soldCheck.toSet().toList()); Map> communityAndSpaces = Map.from(state.selectedCommunityAndSpaces); + List selectedSpacesInCommunity = communityAndSpaces[event.communityModel.uuid] ?? []; + List childrenIds = _getAllChildIds(event.children); bool isChildSelected = false; @@ -139,8 +144,11 @@ class SpaceTreeBloc extends Bloc { // First click: Select the space and all its children updatedSelectedSpaces.add(event.spaceId); updatedSelectedCommunities.add(event.communityModel.uuid); + selectedSpacesInCommunity.add(event.spaceId); + if (childrenIds.isNotEmpty) { updatedSelectedSpaces.addAll(childrenIds); + selectedSpacesInCommunity.addAll(childrenIds); } List spaces = _getThePathToChild(event.communityModel.uuid, event.spaceId); @@ -153,14 +161,17 @@ class SpaceTreeBloc extends Bloc { childrenIds.isNotEmpty && isChildSelected) { // Second click: Unselect space but keep children + selectedSpacesInCommunity.remove(event.spaceId); updatedSelectedSpaces.remove(event.spaceId); updatedSoldChecks.add(event.spaceId); } else { // Third click: Unselect space and all its children + selectedSpacesInCommunity.remove(event.spaceId); updatedSelectedSpaces.remove(event.spaceId); if (childrenIds.isNotEmpty) { updatedSelectedSpaces.removeWhere(childrenIds.contains); updatedSoldChecks.removeWhere(childrenIds.contains); + selectedSpacesInCommunity.removeWhere(childrenIds.contains); } updatedSoldChecks.remove(event.spaceId); @@ -185,7 +196,7 @@ class SpaceTreeBloc extends Bloc { } } - communityAndSpaces[event.communityModel.uuid] = updatedSelectedSpaces; + communityAndSpaces[event.communityModel.uuid] = selectedSpacesInCommunity; emit(state.copyWith( selectedCommunities: updatedSelectedCommunities.toSet().toList(),