mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Merge pull request #86 from SyncrowIOT/roles_permissions_bugs
Roles permissions bugs
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
@ -51,6 +52,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
user = await HomeApi().fetchUserInfo(uuid);
|
user = await HomeApi().fetchUserInfo(uuid);
|
||||||
add(FetchTermEvent());
|
add(FetchTermEvent());
|
||||||
|
add(FetchPolicyEvent());
|
||||||
|
|
||||||
emit(HomeInitial());
|
emit(HomeInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
@ -61,8 +64,9 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
try {
|
try {
|
||||||
emit(LoadingHome());
|
emit(LoadingHome());
|
||||||
terms = await HomeApi().fetchTerms();
|
terms = await HomeApi().fetchTerms();
|
||||||
add(FetchPolicyEvent());
|
emit(HomeInitial());
|
||||||
emit(PolicyAgreement());
|
|
||||||
|
// emit(PolicyAgreement());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,8 +76,11 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
try {
|
try {
|
||||||
emit(LoadingHome());
|
emit(LoadingHome());
|
||||||
policy = await HomeApi().fetchPolicy();
|
policy = await HomeApi().fetchPolicy();
|
||||||
emit(PolicyAgreement());
|
debugPrint("Fetched policy: $policy");
|
||||||
|
// Emit a state to trigger the UI update
|
||||||
|
emit(HomeInitial());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
debugPrint("Error fetching policy: $e");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,103 +9,126 @@ import 'package:syncrow_web/pages/home/view/home_card.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||||
|
|
||||||
class HomeWebPage extends StatelessWidget {
|
class HomeWebPage extends StatefulWidget {
|
||||||
const HomeWebPage({super.key});
|
const HomeWebPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HomeWebPage> createState() => _HomeWebPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeWebPageState extends State<HomeWebPage> {
|
||||||
|
// Flag to track whether the dialog is already shown.
|
||||||
|
bool _dialogShown = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
|
homeBloc.add(FetchUserInfo());
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvoked: (didPop) => false,
|
onPopInvoked: (didPop) => false,
|
||||||
child: BlocConsumer<HomeBloc, HomeState>(
|
child: BlocConsumer<HomeBloc, HomeState>(
|
||||||
listener: (BuildContext context, state) {
|
listener: (BuildContext context, state) {
|
||||||
if (state is HomeInitial) {
|
print('state=$state');
|
||||||
if (homeBloc.user!.hasAcceptedWebAgreement == false) {
|
if (state is HomeInitial) {
|
||||||
Future.delayed(const Duration(seconds: 2), () {
|
if (homeBloc.user!.hasAcceptedWebAgreement == false &&
|
||||||
showDialog(
|
!_dialogShown) {
|
||||||
context: context,
|
_dialogShown =
|
||||||
barrierDismissible: false,
|
true; // Set the flag to true to indicate the dialog is showing.
|
||||||
builder: (BuildContext context) {
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
return AgreementAndPrivacyDialog(
|
showDialog(
|
||||||
terms: homeBloc.terms,
|
context: context,
|
||||||
policy: homeBloc.policy,
|
barrierDismissible: false,
|
||||||
);
|
builder: (BuildContext context) {
|
||||||
},
|
return AgreementAndPrivacyDialog(
|
||||||
).then((v) {
|
terms: homeBloc.terms,
|
||||||
if (v != null) {
|
policy: homeBloc.policy,
|
||||||
homeBloc.add(ConfirmUserAgreementEvent());
|
);
|
||||||
homeBloc.add(const FetchUserInfo());
|
},
|
||||||
}
|
).then((v) {
|
||||||
});
|
_dialogShown = false;
|
||||||
|
if (v != null) {
|
||||||
|
homeBloc.add(ConfirmUserAgreementEvent());
|
||||||
|
homeBloc.add(const FetchUserInfo());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
builder: (context, state) {
|
},
|
||||||
return WebScaffold(
|
builder: (context, state) {
|
||||||
enableMenuSidebar: false,
|
return WebScaffold(
|
||||||
appBarTitle: Row(
|
enableMenuSidebar: false,
|
||||||
|
appBarTitle: Row(
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.loginLogo,
|
||||||
|
width: 150,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
scaffoldBody: SizedBox(
|
||||||
|
height: size.height,
|
||||||
|
width: size.width,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
Column(
|
||||||
Assets.loginLogo,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
width: 150,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(height: size.height * 0.1),
|
||||||
|
Text(
|
||||||
|
'ACCESS YOUR APPS',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.headlineLarge!
|
||||||
|
.copyWith(color: Colors.black, fontSize: 40),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: SizedBox(
|
||||||
|
height: size.height * 0.6,
|
||||||
|
width: size.width * 0.68,
|
||||||
|
child: GridView.builder(
|
||||||
|
itemCount: 3, // Change this count if needed.
|
||||||
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 3, // Adjust as needed.
|
||||||
|
crossAxisSpacing: 20.0,
|
||||||
|
mainAxisSpacing: 20.0,
|
||||||
|
childAspectRatio: 1.5,
|
||||||
|
),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return HomeCard(
|
||||||
|
index: index,
|
||||||
|
active: homeBloc.homeItems[index].active!,
|
||||||
|
name: homeBloc.homeItems[index].title!,
|
||||||
|
img: homeBloc.homeItems[index].icon!,
|
||||||
|
onTap: () =>
|
||||||
|
homeBloc.homeItems[index].onPress(context),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
scaffoldBody: SizedBox(
|
),
|
||||||
height: size.height,
|
);
|
||||||
width: size.width,
|
},
|
||||||
child: Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
);
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: size.height * 0.1),
|
|
||||||
Text(
|
|
||||||
'ACCESS YOUR APPS',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineLarge!
|
|
||||||
.copyWith(color: Colors.black, fontSize: 40),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: SizedBox(
|
|
||||||
height: size.height * 0.6,
|
|
||||||
width: size.width * 0.68,
|
|
||||||
child: GridView.builder(
|
|
||||||
itemCount: 3, //8
|
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 3, //4
|
|
||||||
crossAxisSpacing: 20.0,
|
|
||||||
mainAxisSpacing: 20.0,
|
|
||||||
childAspectRatio: 1.5,
|
|
||||||
),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return HomeCard(
|
|
||||||
index: index,
|
|
||||||
active: homeBloc.homeItems[index].active!,
|
|
||||||
name: homeBloc.homeItems[index].title!,
|
|
||||||
img: homeBloc.homeItems[index].icon!,
|
|
||||||
onTap: () => homeBloc.homeItems[index].onPress(context),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,19 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
|
originalCommunities = updatedCommunities;
|
||||||
emit(const SpacesLoadedState());
|
emit(const SpacesLoadedState());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(ErrorState('Error loading communities and spaces: $e'));
|
emit(ErrorState('Error loading communities and spaces: $e'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This variable holds the full original list.
|
||||||
|
List<TreeNode> originalCommunities = [];
|
||||||
|
|
||||||
|
// This variable holds the working list that may be filtered.
|
||||||
|
|
||||||
|
// Build tree nodes from your data model.
|
||||||
List<TreeNode> _buildTreeNodes(List<SpaceModel> spaces) {
|
List<TreeNode> _buildTreeNodes(List<SpaceModel> spaces) {
|
||||||
return spaces.map((space) {
|
return spaces.map((space) {
|
||||||
List<TreeNode> childNodes =
|
List<TreeNode> childNodes =
|
||||||
@ -123,12 +130,39 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optional helper method to deep clone a TreeNode.
|
||||||
|
TreeNode _cloneNode(TreeNode node) {
|
||||||
|
return TreeNode(
|
||||||
|
uuid: node.uuid,
|
||||||
|
title: node.title,
|
||||||
|
isChecked: node.isChecked,
|
||||||
|
isHighlighted: node.isHighlighted,
|
||||||
|
isExpanded: node.isExpanded,
|
||||||
|
children: node.children.map(_cloneNode).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone an entire list of tree nodes.
|
||||||
|
List<TreeNode> _cloneNodes(List<TreeNode> nodes) {
|
||||||
|
return nodes.map(_cloneNode).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Your search event handler.
|
||||||
void searchTreeNode(SearchAnode event, Emitter<UsersState> emit) {
|
void searchTreeNode(SearchAnode event, Emitter<UsersState> emit) {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
|
|
||||||
|
// If the search term is empty, restore the original list.
|
||||||
if (event.searchTerm!.isEmpty) {
|
if (event.searchTerm!.isEmpty) {
|
||||||
|
// Clear any highlights on the restored copy.
|
||||||
|
updatedCommunities = _cloneNodes(originalCommunities);
|
||||||
_clearHighlights(updatedCommunities);
|
_clearHighlights(updatedCommunities);
|
||||||
} else {
|
} else {
|
||||||
_searchAndHighlightNodes(updatedCommunities, event.searchTerm!);
|
// Start with a fresh clone of the original tree.
|
||||||
|
List<TreeNode> freshClone = _cloneNodes(originalCommunities);
|
||||||
|
|
||||||
|
_searchAndHighlightNodes(freshClone, event.searchTerm!);
|
||||||
|
|
||||||
|
updatedCommunities = _filterNodes(freshClone, event.searchTerm!);
|
||||||
}
|
}
|
||||||
emit(ChangeStatusSteps());
|
emit(ChangeStatusSteps());
|
||||||
}
|
}
|
||||||
@ -155,6 +189,91 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
return anyMatch;
|
return anyMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<TreeNode> _filterNodes(List<TreeNode> nodes, String searchTerm) {
|
||||||
|
List<TreeNode> filteredNodes = [];
|
||||||
|
for (var node in nodes) {
|
||||||
|
bool isMatch =
|
||||||
|
node.title.toLowerCase().contains(searchTerm.toLowerCase());
|
||||||
|
List<TreeNode> filteredChildren = _filterNodes(node.children, searchTerm);
|
||||||
|
if (isMatch || filteredChildren.isNotEmpty) {
|
||||||
|
node.isHighlighted = isMatch;
|
||||||
|
node.children = filteredChildren;
|
||||||
|
filteredNodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List<TreeNode> _buildTreeNodes(List<SpaceModel> spaces) {
|
||||||
|
// return spaces.map((space) {
|
||||||
|
// List<TreeNode> childNodes =
|
||||||
|
// space.children.isNotEmpty ? _buildTreeNodes(space.children) : [];
|
||||||
|
// return TreeNode(
|
||||||
|
// uuid: space.uuid!,
|
||||||
|
// title: space.name,
|
||||||
|
// isChecked: false,
|
||||||
|
// isHighlighted: false,
|
||||||
|
// isExpanded: childNodes.isNotEmpty,
|
||||||
|
// children: childNodes,
|
||||||
|
// );
|
||||||
|
// }).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void searchTreeNode(SearchAnode event, Emitter<UsersState> emit) {
|
||||||
|
// emit(UsersLoadingState());
|
||||||
|
// if (event.searchTerm!.isEmpty) {
|
||||||
|
// _clearHighlights(updatedCommunities);
|
||||||
|
// } else {
|
||||||
|
// _searchAndHighlightNodes(updatedCommunities, event.searchTerm!);
|
||||||
|
// updatedCommunities = _filterNodes(updatedCommunities, event.searchTerm!);
|
||||||
|
// }
|
||||||
|
// emit(ChangeStatusSteps());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void _clearHighlights(List<TreeNode> nodes) {
|
||||||
|
// for (var node in nodes) {
|
||||||
|
// node.isHighlighted = false;
|
||||||
|
// if (node.children.isNotEmpty) {
|
||||||
|
// _clearHighlights(node.children);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// bool _searchAndHighlightNodes(List<TreeNode> nodes, String searchTerm) {
|
||||||
|
// bool anyMatch = false;
|
||||||
|
// for (var node in nodes) {
|
||||||
|
// bool isMatch =
|
||||||
|
// node.title.toLowerCase().contains(searchTerm.toLowerCase());
|
||||||
|
// bool childMatch = _searchAndHighlightNodes(node.children, searchTerm);
|
||||||
|
// node.isHighlighted = isMatch || childMatch;
|
||||||
|
|
||||||
|
// anyMatch = anyMatch || node.isHighlighted;
|
||||||
|
// }
|
||||||
|
// return anyMatch;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// List<TreeNode> _filterNodes(List<TreeNode> nodes, String searchTerm) {
|
||||||
|
// List<TreeNode> filteredNodes = [];
|
||||||
|
// for (var node in nodes) {
|
||||||
|
// // Check if the current node's title contains the search term.
|
||||||
|
// bool isMatch =
|
||||||
|
// node.title.toLowerCase().contains(searchTerm.toLowerCase());
|
||||||
|
|
||||||
|
// // Recursively filter the children.
|
||||||
|
// List<TreeNode> filteredChildren = _filterNodes(node.children, searchTerm);
|
||||||
|
|
||||||
|
// // If the current node is a match or any of its children are, include it.
|
||||||
|
// if (isMatch || filteredChildren.isNotEmpty) {
|
||||||
|
// // Optionally, update any properties (like isHighlighted) if you still need them.
|
||||||
|
// node.isHighlighted = isMatch;
|
||||||
|
// // Replace the children with the filtered ones.
|
||||||
|
// node.children = filteredChildren;
|
||||||
|
// filteredNodes.add(node);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return filteredNodes;
|
||||||
|
// }
|
||||||
|
|
||||||
List<String> selectedIds = [];
|
List<String> selectedIds = [];
|
||||||
|
|
||||||
List<String> getSelectedIds(List<TreeNode> nodes) {
|
List<String> getSelectedIds(List<TreeNode> nodes) {
|
||||||
@ -251,7 +370,6 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_editInviteUser(EditInviteUsers event, Emitter<UsersState> emit) async {
|
_editInviteUser(EditInviteUsers event, Emitter<UsersState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
|
@ -26,126 +26,126 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
create: (BuildContext context) => UsersBloc()
|
create: (BuildContext context) => UsersBloc()
|
||||||
..add(const LoadCommunityAndSpacesEvent())
|
..add(const LoadCommunityAndSpacesEvent())
|
||||||
..add(const RoleEvent()),
|
..add(const RoleEvent()),
|
||||||
child: BlocConsumer<UsersBloc, UsersState>(
|
child: BlocConsumer<UsersBloc, UsersState>(listener: (context, state) {
|
||||||
listener: (context, state) {},
|
// print('88888==${state}');
|
||||||
builder: (context, state) {
|
// if (state is SpacesLoadedState) {
|
||||||
final _blocRole = BlocProvider.of<UsersBloc>(context);
|
// print('object');
|
||||||
|
// _blocRole.add(const CheckRoleStepStatus());
|
||||||
|
// }
|
||||||
|
}, builder: (context, state) {
|
||||||
|
final _blocRole = BlocProvider.of<UsersBloc>(context);
|
||||||
|
|
||||||
return Dialog(
|
return Dialog(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20))),
|
borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
width: 900,
|
width: 900,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Title
|
// Title
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Add New User",
|
"Add New User",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: ColorsManager.secondaryColor),
|
color: ColorsManager.secondaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildStep1Indicator(1, "Basics", _blocRole),
|
||||||
|
_buildStep2Indicator(2, "Spaces", _blocRole),
|
||||||
|
_buildStep3Indicator(
|
||||||
|
3, "Role & Permissions", _blocRole),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
const Divider(),
|
width: 1,
|
||||||
Expanded(
|
color: ColorsManager.grayBorder,
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
_buildStep1Indicator(1, "Basics", _blocRole),
|
|
||||||
_buildStep2Indicator(2, "Spaces", _blocRole),
|
|
||||||
_buildStep3Indicator(
|
|
||||||
3, "Role & Permissions", _blocRole),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 1,
|
|
||||||
color: ColorsManager.grayBorder,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Expanded(
|
|
||||||
child: _getFormContent(),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
const Divider(),
|
flex: 2,
|
||||||
Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
child: Row(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
const SizedBox(height: 10),
|
||||||
onTap: () {
|
Expanded(
|
||||||
Navigator.of(context).pop();
|
child: _getFormContent(),
|
||||||
},
|
),
|
||||||
child: const Text("Cancel"),
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
InkWell(
|
),
|
||||||
onTap: () {
|
|
||||||
_blocRole.add(const CheckEmailEvent());
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
if (currentStep < 3) {
|
|
||||||
currentStep++;
|
|
||||||
if (currentStep == 2) {
|
|
||||||
_blocRole.add(
|
|
||||||
const CheckStepStatus(isEditUser: false));
|
|
||||||
} else if (currentStep == 3) {
|
|
||||||
_blocRole
|
|
||||||
.add(const CheckSpacesStepStatus());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_blocRole
|
|
||||||
.add(SendInviteUsers(context: context));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
currentStep < 3 ? "Next" : "Save",
|
|
||||||
style: TextStyle(
|
|
||||||
color: (_blocRole.isCompleteSpaces == false ||
|
|
||||||
_blocRole.isCompleteBasics ==
|
|
||||||
false ||
|
|
||||||
_blocRole
|
|
||||||
.isCompleteRolePermissions ==
|
|
||||||
false) &&
|
|
||||||
currentStep == 3
|
|
||||||
? ColorsManager.grayColor
|
|
||||||
: ColorsManager.secondaryColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
));
|
const Divider(),
|
||||||
}));
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text("Cancel"),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
_blocRole.add(const CheckEmailEvent());
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
if (currentStep < 3) {
|
||||||
|
currentStep++;
|
||||||
|
if (currentStep == 2) {
|
||||||
|
_blocRole.add(
|
||||||
|
const CheckStepStatus(isEditUser: false));
|
||||||
|
} else if (currentStep == 3) {
|
||||||
|
_blocRole.add(const CheckSpacesStepStatus());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_blocRole.add(SendInviteUsers(context: context));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
currentStep < 3 ? "Next" : "Save",
|
||||||
|
style: TextStyle(
|
||||||
|
color: (_blocRole.isCompleteSpaces == false ||
|
||||||
|
_blocRole.isCompleteBasics == false ||
|
||||||
|
_blocRole.isCompleteRolePermissions ==
|
||||||
|
false) &&
|
||||||
|
currentStep == 3
|
||||||
|
? ColorsManager.grayColor
|
||||||
|
: ColorsManager.secondaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _getFormContent() {
|
Widget _getFormContent() {
|
||||||
@ -236,12 +236,16 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentStep = step;
|
|
||||||
bloc.add(const CheckStepStatus(isEditUser: false));
|
bloc.add(const CheckStepStatus(isEditUser: false));
|
||||||
|
currentStep = step;
|
||||||
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
bloc.add(const CheckStepStatus(isEditUser: false));
|
||||||
|
});
|
||||||
if (step3 == 3) {
|
if (step3 == 3) {
|
||||||
bloc.add(const CheckRoleStepStatus());
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
bloc.add(const CheckRoleStepStatus());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -46,117 +46,120 @@ class BasicsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
Flexible(
|
||||||
width: MediaQuery.of(context).size.width * 0.18,
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.width * 0.08,
|
// width: MediaQuery.of(context).size.width * 0.18,
|
||||||
child: Column(
|
height: MediaQuery.of(context).size.width * 0.08,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
SizedBox(
|
children: [
|
||||||
child: Row(
|
SizedBox(
|
||||||
children: [
|
child: Row(
|
||||||
const Text(
|
children: [
|
||||||
" * ",
|
const Text(
|
||||||
style: TextStyle(
|
" * ",
|
||||||
color: ColorsManager.red,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w900,
|
color: ColorsManager.red,
|
||||||
fontSize: 15,
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
'First Name',
|
||||||
'First Name',
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: TextFormField(
|
|
||||||
style:
|
|
||||||
const TextStyle(color: ColorsManager.blackColor),
|
|
||||||
// onChanged: (value) {
|
|
||||||
// Future.delayed(const Duration(milliseconds: 200),
|
|
||||||
// () {
|
|
||||||
// _blocRole.add(const ValidateBasicsStep());
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
controller: _blocRole.firstNameController,
|
|
||||||
decoration: inputTextFormDeco(
|
|
||||||
hintText: "Enter first name",
|
|
||||||
).copyWith(
|
|
||||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.textGray),
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'Enter first name';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width * 0.18,
|
|
||||||
height: MediaQuery.of(context).size.width * 0.08,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
" * ",
|
|
||||||
style: TextStyle(
|
|
||||||
color: ColorsManager.red,
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
fontSize: 15,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text('Last Name',
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
)),
|
),
|
||||||
],
|
),
|
||||||
)),
|
],
|
||||||
Padding(
|
)),
|
||||||
padding: const EdgeInsets.all(8.0),
|
Padding(
|
||||||
child: TextFormField(
|
padding: const EdgeInsets.all(8.0),
|
||||||
// onChanged: (value) {
|
child: TextFormField(
|
||||||
// Future.delayed(const Duration(milliseconds: 200),
|
style: const TextStyle(
|
||||||
// () {
|
color: ColorsManager.blackColor),
|
||||||
// _blocRole.add(ValidateBasicsStep());
|
// onChanged: (value) {
|
||||||
// });
|
// Future.delayed(const Duration(milliseconds: 200),
|
||||||
// },
|
// () {
|
||||||
controller: _blocRole.lastNameController,
|
// _blocRole.add(const ValidateBasicsStep());
|
||||||
style: const TextStyle(color: Colors.black),
|
// });
|
||||||
decoration:
|
// },
|
||||||
inputTextFormDeco(hintText: "Enter last name")
|
controller: _blocRole.firstNameController,
|
||||||
.copyWith(
|
decoration: inputTextFormDeco(
|
||||||
hintStyle: context
|
hintText: "Enter first name",
|
||||||
.textTheme.bodyMedium
|
).copyWith(
|
||||||
?.copyWith(
|
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: ColorsManager.textGray)),
|
color: ColorsManager.textGray),
|
||||||
validator: (value) {
|
),
|
||||||
if (value == null || value.isEmpty) {
|
validator: (value) {
|
||||||
return 'Enter last name';
|
if (value == null || value.isEmpty) {
|
||||||
}
|
return 'Enter first name';
|
||||||
return null;
|
}
|
||||||
},
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Flexible(
|
||||||
|
child: SizedBox(
|
||||||
|
// width: MediaQuery.of(context).size.width * 0.18,
|
||||||
|
height: MediaQuery.of(context).size.width * 0.08,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
" * ",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ColorsManager.red,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text('Last Name',
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 13,
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
// onChanged: (value) {
|
||||||
|
// Future.delayed(const Duration(milliseconds: 200),
|
||||||
|
// () {
|
||||||
|
// _blocRole.add(ValidateBasicsStep());
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
controller: _blocRole.lastNameController,
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
inputTextFormDeco(hintText: "Enter last name")
|
||||||
|
.copyWith(
|
||||||
|
hintStyle: context.textTheme.bodyMedium
|
||||||
|
?.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.textGray)),
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return 'Enter last name';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -27,7 +27,16 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
List<RolesUserModel> users = [];
|
List<RolesUserModel> users = [];
|
||||||
List<RolesUserModel> initialUsers = [];
|
List<RolesUserModel> initialUsers = [];
|
||||||
|
|
||||||
|
List<RolesUserModel> totalUsersCount = [];
|
||||||
String currentSortOrder = '';
|
String currentSortOrder = '';
|
||||||
|
|
||||||
|
String currentSortJopTitle = '';
|
||||||
|
String currentSortRole = '';
|
||||||
|
String currentSortCreatedDate = '';
|
||||||
|
String currentSortStatus = '';
|
||||||
|
String currentSortCreatedBy = '';
|
||||||
|
|
||||||
String currentSortOrderDate = '';
|
String currentSortOrderDate = '';
|
||||||
List<String> roleTypes = [];
|
List<String> roleTypes = [];
|
||||||
List<String> jobTitle = [];
|
List<String> jobTitle = [];
|
||||||
@ -60,6 +69,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
jobTitle = jobTitle.toSet().toList();
|
jobTitle = jobTitle.toSet().toList();
|
||||||
createdBy = createdBy.toSet().toList();
|
createdBy = createdBy.toSet().toList();
|
||||||
_handlePageChange(ChangePage(1), emit);
|
_handlePageChange(ChangePage(1), emit);
|
||||||
|
totalUsersCount = initialUsers;
|
||||||
add(ChangePage(currentPage));
|
add(ChangePage(currentPage));
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -91,26 +101,6 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
event.userId, event.newStatus == "disabled" ? false : true);
|
event.userId, event.newStatus == "disabled" ? false : true);
|
||||||
if (res == true) {
|
if (res == true) {
|
||||||
add(const GetUsers());
|
add(const GetUsers());
|
||||||
// users = users.map((user) {
|
|
||||||
// if (user.uuid == event.userId) {
|
|
||||||
// return RolesUserModel(
|
|
||||||
// uuid: user.uuid,
|
|
||||||
// createdAt: user.createdAt,
|
|
||||||
// email: user.email,
|
|
||||||
// firstName: user.firstName,
|
|
||||||
// lastName: user.lastName,
|
|
||||||
// roleType: user.roleType,
|
|
||||||
// status: event.newStatus,
|
|
||||||
// isEnabled: event.newStatus == "disabled" ? false : true,
|
|
||||||
// invitedBy: user.invitedBy,
|
|
||||||
// phoneNumber: user.phoneNumber,
|
|
||||||
// jobTitle: user.jobTitle,
|
|
||||||
// createdDate: user.createdDate,
|
|
||||||
// createdTime: user.createdTime,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// return user;
|
|
||||||
// }).toList();
|
|
||||||
}
|
}
|
||||||
emit(UsersLoadedState(users: users));
|
emit(UsersLoadedState(users: users));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -128,7 +118,6 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
users = List.from(users);
|
users = List.from(users);
|
||||||
emit(UsersLoadedState(users: users));
|
|
||||||
} else {
|
} else {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "Asc";
|
currentSortOrder = "Asc";
|
||||||
@ -136,8 +125,12 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.compareTo(b.firstName.toString().toLowerCase()));
|
.compareTo(b.firstName.toString().toLowerCase()));
|
||||||
emit(UsersLoadedState(users: users));
|
|
||||||
}
|
}
|
||||||
|
currentSortJopTitle = '';
|
||||||
|
currentSortCreatedDate = '';
|
||||||
|
currentSortStatus = '';
|
||||||
|
currentSortCreatedBy = '';
|
||||||
|
emit(UsersLoadedState(users: users));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleSortUsersByNameDesc(
|
void _toggleSortUsersByNameDesc(
|
||||||
@ -150,13 +143,16 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
users = List.from(initialUsers);
|
users = List.from(initialUsers);
|
||||||
emit(UsersLoadedState(users: users));
|
|
||||||
} else {
|
} else {
|
||||||
emit(UsersLoadingState());
|
emit(UsersLoadingState());
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
users.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
users.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
emit(UsersLoadedState(users: users));
|
|
||||||
}
|
}
|
||||||
|
currentSortJopTitle = '';
|
||||||
|
currentSortCreatedDate = '';
|
||||||
|
currentSortStatus = '';
|
||||||
|
currentSortCreatedBy = '';
|
||||||
|
emit(UsersLoadedState(users: users));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleSortUsersByDateNewestToOldest(
|
void _toggleSortUsersByDateNewestToOldest(
|
||||||
@ -222,6 +218,7 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
Future<void> _searchUsers(
|
Future<void> _searchUsers(
|
||||||
SearchUsers event, Emitter<UserTableState> emit) async {
|
SearchUsers event, Emitter<UserTableState> emit) async {
|
||||||
try {
|
try {
|
||||||
|
emit(TableSearch());
|
||||||
final query = event.query.toLowerCase();
|
final query = event.query.toLowerCase();
|
||||||
final filteredUsers = initialUsers.where((user) {
|
final filteredUsers = initialUsers.where((user) {
|
||||||
final fullName = "${user.firstName} ${user.lastName}".toLowerCase();
|
final fullName = "${user.firstName} ${user.lastName}".toLowerCase();
|
||||||
@ -250,7 +247,8 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handlePageChange(ChangePage event, Emitter<UserTableState> emit) {
|
void _handlePageChange(ChangePage event, Emitter<UserTableState> emit) {
|
||||||
const itemsPerPage = 10;
|
currentPage = event.pageNumber;
|
||||||
|
const itemsPerPage = 20;
|
||||||
final startIndex = (event.pageNumber - 1) * itemsPerPage;
|
final startIndex = (event.pageNumber - 1) * itemsPerPage;
|
||||||
final endIndex = startIndex + itemsPerPage;
|
final endIndex = startIndex + itemsPerPage;
|
||||||
if (startIndex >= users.length) {
|
if (startIndex >= users.length) {
|
||||||
@ -287,9 +285,15 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else if (event.sortOrder == "Desc") {
|
} else if (event.sortOrder == "Desc") {
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
} else {
|
} else {}
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
}
|
currentSortCreatedDate = '';
|
||||||
|
currentSortStatus = '';
|
||||||
|
currentSortCreatedBy = '';
|
||||||
|
currentSortJopTitle = '';
|
||||||
|
currentSortOrderDate = "";
|
||||||
|
|
||||||
|
totalUsersCount = filteredUsers;
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
@ -311,9 +315,16 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else if (event.sortOrder == "Desc") {
|
} else if (event.sortOrder == "Desc") {
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
} else {
|
} else {}
|
||||||
currentSortOrder = "";
|
currentSortOrder = "";
|
||||||
}
|
currentSortCreatedDate = '';
|
||||||
|
currentSortStatus = '';
|
||||||
|
currentSortCreatedBy = '';
|
||||||
|
currentSortRole = '';
|
||||||
|
currentSortOrderDate = "";
|
||||||
|
|
||||||
|
totalUsersCount = filteredUsers;
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,9 +346,15 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else if (event.sortOrder == "Desc") {
|
} else if (event.sortOrder == "Desc") {
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
} else {
|
} else {}
|
||||||
currentSortOrder = "";
|
currentSortOrder = '';
|
||||||
}
|
currentSortRole = '';
|
||||||
|
currentSortCreatedDate = '';
|
||||||
|
currentSortStatus = '';
|
||||||
|
currentSortOrderDate = "";
|
||||||
|
|
||||||
|
totalUsersCount = filteredUsers;
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,14 +388,17 @@ class UserTableBloc extends Bloc<UserTableEvent, UserTableState> {
|
|||||||
} else if (event.sortOrder == "Desc") {
|
} else if (event.sortOrder == "Desc") {
|
||||||
currentSortOrder = "Desc";
|
currentSortOrder = "Desc";
|
||||||
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
filteredUsers.sort((a, b) => b.firstName!.compareTo(a.firstName!));
|
||||||
} else {
|
totalUsersCount = filteredUsers;
|
||||||
currentSortOrder = "";
|
} else {}
|
||||||
}
|
currentSortOrder = '';
|
||||||
|
currentSortRole = '';
|
||||||
|
currentSortCreatedDate = '';
|
||||||
|
currentSortCreatedBy = '';
|
||||||
|
currentSortOrderDate = "";
|
||||||
|
|
||||||
emit(UsersLoadedState(users: filteredUsers));
|
emit(UsersLoadedState(users: filteredUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _resetAllFilters(Emitter<UserTableState> emit) {
|
void _resetAllFilters(Emitter<UserTableState> emit) {
|
||||||
selectedRoles.clear();
|
selectedRoles.clear();
|
||||||
selectedJobTitles.clear();
|
selectedJobTitles.clear();
|
||||||
|
@ -9,7 +9,10 @@ final class TableInitial extends UserTableState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
final class TableSearch extends UserTableState {
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
final class RolesLoadingState extends UserTableState {
|
final class RolesLoadingState extends UserTableState {
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
|
@ -129,9 +129,12 @@ class UsersPage extends StatelessWidget {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: searchController,
|
controller: searchController,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context
|
final bloc = context.read<UserTableBloc>();
|
||||||
.read<UserTableBloc>()
|
bloc.add(FilterClearEvent());
|
||||||
.add(SearchUsers(value));
|
bloc.add(SearchUsers(value));
|
||||||
|
if (value == '') {
|
||||||
|
bloc.add(ChangePage(1));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
decoration: textBoxDecoration(radios: 15)!.copyWith(
|
decoration: textBoxDecoration(radios: 15)!.copyWith(
|
||||||
@ -222,7 +225,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.jobTitle,
|
list: _blocRole.jobTitle,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortJopTitle,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
searchController.clear();
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
@ -233,14 +236,14 @@ class UsersPage extends StatelessWidget {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole.add(FilterUsersByJobEvent(
|
_blocRole.add(FilterUsersByJobEvent(
|
||||||
selectedJob: selectedItems,
|
selectedJob: selectedItems,
|
||||||
sortOrder: _blocRole.currentSortOrder,
|
sortOrder: _blocRole.currentSortJopTitle,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
onSortAtoZ: (v) {
|
onSortAtoZ: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortJopTitle = v;
|
||||||
},
|
},
|
||||||
onSortZtoA: (v) {
|
onSortZtoA: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortJopTitle = v;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -263,7 +266,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.roleTypes,
|
list: _blocRole.roleTypes,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortRole,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
searchController.clear();
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
@ -275,13 +278,13 @@ class UsersPage extends StatelessWidget {
|
|||||||
context.read<UserTableBloc>().add(
|
context.read<UserTableBloc>().add(
|
||||||
FilterUsersByRoleEvent(
|
FilterUsersByRoleEvent(
|
||||||
selectedRoles: selectedItems,
|
selectedRoles: selectedItems,
|
||||||
sortOrder: _blocRole.currentSortOrder));
|
sortOrder: _blocRole.currentSortRole));
|
||||||
},
|
},
|
||||||
onSortAtoZ: (v) {
|
onSortAtoZ: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortRole = v;
|
||||||
},
|
},
|
||||||
onSortZtoA: (v) {
|
onSortZtoA: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortRole = v;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -319,7 +322,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.createdBy,
|
list: _blocRole.createdBy,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortCreatedBy,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
searchController.clear();
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
@ -330,13 +333,13 @@ class UsersPage extends StatelessWidget {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole.add(FilterUsersByCreatedEvent(
|
_blocRole.add(FilterUsersByCreatedEvent(
|
||||||
selectedCreatedBy: selectedItems,
|
selectedCreatedBy: selectedItems,
|
||||||
sortOrder: _blocRole.currentSortOrder));
|
sortOrder: _blocRole.currentSortCreatedBy));
|
||||||
},
|
},
|
||||||
onSortAtoZ: (v) {
|
onSortAtoZ: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortCreatedBy = v;
|
||||||
},
|
},
|
||||||
onSortZtoA: (v) {
|
onSortZtoA: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortCreatedBy = v;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -359,7 +362,7 @@ class UsersPage extends StatelessWidget {
|
|||||||
list: _blocRole.status,
|
list: _blocRole.status,
|
||||||
context: context,
|
context: context,
|
||||||
checkboxStates: checkboxStates,
|
checkboxStates: checkboxStates,
|
||||||
isSelected: _blocRole.currentSortOrder,
|
isSelected: _blocRole.currentSortStatus,
|
||||||
onOkPressed: () {
|
onOkPressed: () {
|
||||||
searchController.clear();
|
searchController.clear();
|
||||||
_blocRole.add(FilterClearEvent());
|
_blocRole.add(FilterClearEvent());
|
||||||
@ -370,13 +373,13 @@ class UsersPage extends StatelessWidget {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
_blocRole.add(FilterUsersByDeActevateEvent(
|
_blocRole.add(FilterUsersByDeActevateEvent(
|
||||||
selectedActivate: selectedItems,
|
selectedActivate: selectedItems,
|
||||||
sortOrder: _blocRole.currentSortOrder));
|
sortOrder: _blocRole.currentSortStatus));
|
||||||
},
|
},
|
||||||
onSortAtoZ: (v) {
|
onSortAtoZ: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortStatus = v;
|
||||||
},
|
},
|
||||||
onSortZtoA: (v) {
|
onSortZtoA: (v) {
|
||||||
_blocRole.currentSortOrder = v;
|
_blocRole.currentSortStatus = v;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -508,12 +511,11 @@ class UsersPage extends StatelessWidget {
|
|||||||
const Icon(Icons.keyboard_double_arrow_right),
|
const Icon(Icons.keyboard_double_arrow_right),
|
||||||
firstPageIcon:
|
firstPageIcon:
|
||||||
const Icon(Icons.keyboard_double_arrow_left),
|
const Icon(Icons.keyboard_double_arrow_left),
|
||||||
totalPages: (_blocRole.users.length /
|
totalPages: (_blocRole.totalUsersCount.length /
|
||||||
_blocRole.itemsPerPage)
|
_blocRole.itemsPerPage)
|
||||||
.ceil(),
|
.ceil(),
|
||||||
currentPage: _blocRole.currentPage,
|
currentPage: _blocRole.currentPage,
|
||||||
onPageChanged: (int pageNumber) {
|
onPageChanged: (int pageNumber) {
|
||||||
_blocRole.currentPage = pageNumber;
|
|
||||||
context
|
context
|
||||||
.read<UserTableBloc>()
|
.read<UserTableBloc>()
|
||||||
.add(ChangePage(pageNumber));
|
.add(ChangePage(pageNumber));
|
||||||
|
Reference in New Issue
Block a user