add search functions to superadmin screens

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-10-03 08:33:10 +08:00
parent ba89592496
commit deeca18962
38 changed files with 3517 additions and 2576 deletions

View File

@ -51,10 +51,13 @@ class LearningDevelopmentBloc
attachmentCategories =
await AttachmentServices.instance.getCategories();
}
List<LearningDevelopement> learnings = await LearningDevelopmentServices
if(learningsAndDevelopments.isEmpty){
List<LearningDevelopement> learnings = await LearningDevelopmentServices
.instance
.getLearningDevelopments(event.profileId, event.token);
learningsAndDevelopments = learnings;
}
emit(LearningDevelopmentLoadedState(
learningsAndDevelopment: learningsAndDevelopments,attachmentCategory: attachmentCategories));
} catch (e) {

View File

@ -64,6 +64,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
primaryBasicInformation: globalCurrentProfile!));
} else {
currentProfileInformation = event.primaryBasicInformation;
globalCurrentProfile = currentProfileInformation;
emit(BasicInformationProfileLoaded(
primaryBasicInformation: currentProfileInformation!));
}
@ -108,7 +109,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
}
emit(BasicInformationEditingState(
primaryInformation: currentProfileInformation!,
primaryInformation: globalCurrentProfile!,
extensions: nameExtensions,
sexes: sexes,
bloodTypes: bloodType,

View File

@ -13,9 +13,12 @@ class GetAgencies extends AgencyEvent{
class AddAgency extends AgencyEvent{
final Agency agency;
const AddAgency({required this.agency});
List<Object> get props => [agency
];
}
class GetEstPointPersonAgencies extends AgencyEvent{
final List<AssignedArea>? assignedAreas;
const GetEstPointPersonAgencies({required this.assignedAreas});
}

View File

@ -60,7 +60,7 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
}
});
on<AddAssignArea>((event, emit) async {
// try {
try {
emit(AssignAreaLoadingState());
Map<dynamic, dynamic> response = await RbacAssignedAreaServices.instance
.add(
@ -77,11 +77,6 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
break;
}
}
// newAssignArea = userAssignedAreas.firstWhere((var element) {
// return element.assignedRole?.role?.id == event.roleId &&
// element.assignedRole?.user?.id == event.userId;
// });
if (newAssignArea?.assignedArea != null) {
userAssignedAreas.removeWhere((element) =>
element.assignedRole!.role!.id == event.roleId &&
@ -120,8 +115,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea);
//// purok
}
if (event.areaTypeId == 2) {
@ -149,8 +144,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea);
}
////statiom
if (event.areaTypeId == 4) {
@ -200,8 +195,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea);
}
////agency
if (event.areaTypeId == 3) {
@ -231,16 +226,16 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea);
}
}
newAssignArea?.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!);
newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea);
}
emit(AssignAreaAddedState(response: response));
} else {
emit(AssignAreaAddedState(response: response));
}
// } catch (e) {
// emit(AssignAreaErorState(message: e.toString()));
// }
} catch (e) {
emit(AssignAreaErorState(message: e.toString()));
}
});
on<LoadAssignedAreas>((event, emit) async {
emit(AssignedAreaLoadedState(

View File

@ -11,7 +11,7 @@ part 'role_module_state.dart';
class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
RoleModuleBloc() : super(RoleModuleInitial()) {
List<RoleModules> roleModules = [];
List<RBAC> roles = [];
List<RBAC> roles = [];
List<RBAC> modules = [];
on<GetRoleModules>((event, emit) async {
emit(RoleModuleLoadingState());
@ -19,18 +19,19 @@ class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
if (roleModules.isEmpty) {
roleModules = await RbacRoleModuleServices.instance.getRoleModules();
}
if (modules.isEmpty) {
if (modules.isEmpty) {
modules = await RbacModuleServices.instance.getRbacModule();
}
if (roles.isEmpty) {
if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles();
}
emit(RoleModuleLoadedState(roleModules: roleModules,modules: modules,roles: roles));
emit(RoleModuleLoadedState(
roleModules: roleModules, modules: modules, roles: roles));
} catch (e) {
emit(RoleModuleErrorState(message: e.toString()));
}
});
on<AddRoleModule>((event, emit) async {
on<AddRoleModule>((event, emit) async {
try {
emit(RoleModuleLoadingState());
Map<dynamic, dynamic> statusResponse =
@ -40,9 +41,12 @@ class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
moduleIds: event.moduleIds);
if (statusResponse['success']) {
List<int?> ids = roleModules.map((e) => e.id).toList();
statusResponse['data'].forEach((var roleMod) {
RoleModules newRoleModule = RoleModules.fromJson(roleMod);
roleModules.add(newRoleModule);
if (!ids.contains(newRoleModule.id)) {
roleModules.add(newRoleModule);
}
emit(RoleModuleAddedState(response: statusResponse));
});
} else {

View File

@ -36,11 +36,14 @@ class RolesUnderBloc extends Bloc<RolesUnderEvent, RolesUnderState> {
.add(roleId: event.roleId, rolesId: event.roleUnderIds);
if (statusResponse['success']) {
List<int> ids = rolesUnder.map((e) => e.id).toList();
statusResponse['data'].forEach((var roleMod) {
RolesUnder newRoleUnder = RolesUnder.fromJson(roleMod);
rolesUnder.add(newRoleUnder);
emit(RoleUnderAddedState(response: statusResponse));
if (!ids.contains(newRoleUnder.id)) {
rolesUnder.add(newRoleUnder);
}
});
emit(RoleUnderAddedState(response: statusResponse));
} else {
emit(RoleUnderAddedState(response: statusResponse));
}

View File

@ -23,9 +23,9 @@ import '../../../../utils/alerts.dart';
class CitizenShipScreen extends StatefulWidget {
final int profileId;
final String token;
final List<Citizenship> citizenships;
const CitizenShipScreen(
{super.key, required this.profileId, required this.token});
{super.key, required this.profileId, required this.token , required this.citizenships});
@override
State<CitizenShipScreen> createState() => _CitizenShipScreenState();
@ -421,7 +421,9 @@ class _CitizenShipScreenState extends State<CitizenShipScreen> {
if (state is CitizenshipErrorState) {
return Scaffold(
body: SomethingWentWrong(
message: state.message, onpressed: () {}));
message: state.message, onpressed: () {
context.read<CitizenshipBloc>().add(GetCitizenship(citizenship: widget.citizenships));
}));
}
return Container();
},

View File

@ -10,6 +10,7 @@ import 'package:unit2/sevices/profile/contact_services.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/global_context.dart';
import 'package:unit2/utils/text_container.dart';
import '../../../../../theme-data.dart/colors.dart';
@ -84,7 +85,7 @@ class _AddContactInformationScreenState
serviceTypeId:
selectedServiceType!.id!);
} catch (e) {
context
NavigationService.navigatorKey.currentContext!
.read<ContactBloc>()
.add(CallErrorEvent(message: e.toString()));
}
@ -129,6 +130,7 @@ class _AddContactInformationScreenState
? selectedServiceType?.id == 2
//// Landline
? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController,
inputFormatters: [landLineFormatter],
name: 'number-mail',
@ -150,7 +152,7 @@ class _AddContactInformationScreenState
errorText: "This field is required"),
decoration: normalTextFieldStyle(
"Mobile number *",
"+63 (9xx) xxx - xxxx"),
"+63 (9xx) xxx - xxxx").copyWith(helperText: "Please input your mobile number excluding the 0"),
)
: selectedServiceType!.id == 4
////Social Media
@ -167,6 +169,7 @@ class _AddContactInformationScreenState
: selectedServiceType!.id == 3
////Email Address
? FormBuilderTextField(
keyboardType: TextInputType.emailAddress,
controller: numberMailController,
name: 'number-mail',
validator: FormBuilderValidators

View File

@ -37,7 +37,7 @@ class _EditContactInformationScreenState
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
filter: {"#": RegExp(r'^[0-9][0-9]*$')},
type: MaskAutoCompletionType.lazy,
initialText: "0");
@ -149,6 +149,7 @@ class _EditContactInformationScreenState
? selectedServiceType?.id == 2
//// Landline
? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController,
name: 'number-mail',
inputFormatters: [landLineFormatter],
@ -162,6 +163,7 @@ class _EditContactInformationScreenState
selectedServiceType!.id == 19
//// Mobile number
? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController,
name: 'number-mail',
inputFormatters: [mobileFormatter],
@ -172,10 +174,12 @@ class _EditContactInformationScreenState
decoration: normalTextFieldStyle(
"Mobile number *",
"+63 (9xx) xxx - xxxx"),
)
: selectedServiceType!.id == 4
////Social Media
? FormBuilderTextField(
controller: numberMailController,
name: 'number-mail',
validator:
@ -188,6 +192,7 @@ class _EditContactInformationScreenState
: selectedServiceType!.id == 3
////Email Address
? FormBuilderTextField(
keyboardType: TextInputType.emailAddress,
controller:
numberMailController,
name: 'number-mail',

View File

@ -1,10 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import '../../../../../bloc/profile/family/family_bloc.dart';
import '../../../../../theme-data.dart/btn-style.dart';
import '../../../../../theme-data.dart/colors.dart';
import '../../../../../theme-data.dart/form-style.dart';
@ -26,6 +22,7 @@ class AddMobileNumber extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
keyboardType: TextInputType.number,
name: 'number_mail',
inputFormatters: [mobileFormatter],
validator: FormBuilderValidators.required(

View File

@ -45,7 +45,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget {
AttachmentCategory? selectedAttachmentCategory;
List<AttachmentCategory> attachmentCategories = [];
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: context.watch<LearningDevelopmentBloc>().state
is LearningDevelopmentAddingState

View File

@ -48,360 +48,378 @@ import '../unit2/homepage.dart/components/menu.dart';
import 'components/main_menu.dart';
import 'components/submenu.dart';
class ProfileInfo extends StatelessWidget {
class ProfileInfo extends StatefulWidget {
const ProfileInfo({super.key});
@override
State<ProfileInfo> createState() => _ProfileInfoState();
}
class _ProfileInfoState extends State<ProfileInfo> {
@override
Widget build(BuildContext context) {
int? profileId;
String? token;
Profile profile;
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
centerTitle: true,
title: const Text('Profile'),
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!;
if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!;
} else {
profile = globalCurrentProfile!;
return WillPopScope(
onWillPop: () async{
setState(() {
});
return true;
},
child: Scaffold(
appBar: AppBar(
backgroundColor: primary,
centerTitle: true,
title: const Text('Profile'),
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!;
if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!;
globalCurrentProfile = profile;
} else {
profile = globalCurrentProfile!;
}
return BlocConsumer<ProfileBloc, ProfileState>(
listener: (
context,
state,
) {
if (state is ProfileLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is ProfileLoaded ||
state is ProfileErrorState ||
state is BasicInformationEditingState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is ProfileLoaded) {
return Container(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 12),
child: ListView(
children: [
Text(
"View and Update your Profile Information",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
Elusive.address_book,
color: primary,
),
title: Text(
"Basic Information",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(Icons.person, "Primary", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider<ProfileBloc>.value(
value: ProfileBloc()
..add(GetPrimaryBasicInfo(
primaryBasicInformation: profile)),
child: PrimaryInfo(
token: token!,
profileId: profileId!,
),
);
}));
}),
subMenu(Icons.home, "Addresses", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => AddressBloc()
..add(GetAddress(
addresses: state.profileInformation
.basicInfo.addresses)),
child: const AddressScreen(),
);
}));
}),
subMenu(Icons.contact_mail, "Identifications",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => IdentificationBloc()
..add(GetIdentifications(
identificationInformation: state
.profileInformation
.basicInfo
.identifications)),
child: const IdentificationsScreen(),
);
}));
}),
subMenu(Icons.contact_phone, "Contact Info",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ContactBloc()
..add(GetContacts(
contactInformations: state
.profileInformation
.basicInfo
.contactInformation)),
child: const ContactInformationScreen(),
);
}));
}),
subMenu(Icons.flag, "Citizenships", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => CitizenshipBloc()
..add(GetCitizenship(
citizenship: state
.profileInformation
.basicInfo
.citizenships)),
child: CitizenShipScreen(
citizenships: state
.profileInformation
.basicInfo
.citizenships,
profileId: profileId!, token: token!),
);
}));
}),
]),
const Divider(),
MainMenu(
icon: Elusive.group,
title: "Family",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => FamilyBloc()
..add(GetFamilies(
profileId: profileId!, token: token!)),
child: const FamilyBackgroundScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.graduation_cap,
title: "Education",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EducationBloc()
..add(GetEducationalBackground(
profileId: profileId!, token: token!)),
child: const EducationScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Icons.stars,
title: "Eligibility",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EligibilityBloc()
..add(GetEligibilities(
profileId: profileId!, token: token!)),
child: const EligibiltyScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.shopping_bag,
title: "Work History",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => WorkHistoryBloc()
..add(GetWorkHistories(
profileId: profileId!, token: token!)),
child: const WorkHistoryScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.walking,
title: "Voluntary Work & Civic Services",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => VoluntaryWorkBloc()
..add(GetVoluntarWorks(
profileId: profileId!, token: token!)),
child: const VolunataryWorkScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Elusive.lightbulb,
title: "Learning & Development",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => LearningDevelopmentBloc()
..add(GetLearningDevelopments(
profileId: profileId!, token: token!)),
child: const LearningAndDevelopmentScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Brandico.codepen,
title: "Personal References",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ReferencesBloc()
..add(GetReferences(
profileId: profileId!, token: token!)),
child: const ReferencesScreen(),
);
}));
},
),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
Icons.info,
color: primary,
),
title: Text(
"Other Information",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(
Icons.fitness_center, "Skills & Hobbies",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => HoobiesBloc()
..add(GetSkillsHobbies(
profileId: profileId!,
token: token!)),
child: const SkillHobbiesScreen(),
);
}));
}),
subMenu(FontAwesome5.certificate,
"Organization Memberships", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
OrganizationMembershipBloc()
..add(GetOrganizationMembership(
profileId: profileId!,
token: token!)),
child: const OrgMembershipsScreen(),
);
}));
}),
subMenu(Entypo.doc_text,
"Non-Academic Recognitions", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
NonAcademicRecognitionBloc()
..add(GetNonAcademicRecognition(
profileId: profileId!,
token: token!)),
child:
const NonAcademicRecognitionScreen(),
);
}));
}),
]),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
FontAwesome5.laptop_house,
color: primary,
),
title: Text(
"Assets",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(ModernPictograms.home,
"Real Property Tax", () {}),
]),
],
),
);
}
if (state is ProfileLoading) {
return const LoadingScreen();
}
if (state is ProfileErrorState) {
return SomethingWentWrong(
message: state.mesage,
onpressed: () {
BlocProvider.of<ProfileBloc>(context).add(
LoadProfile(token: token!, userID: profileId!));
});
}
return Container();
},
);
}
print(profile.lastName);
return BlocConsumer<ProfileBloc, ProfileState>(
listener: (
context,
state,
) {
if (state is ProfileLoading) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is ProfileLoaded ||
state is ProfileErrorState ||
state is BasicInformationEditingState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
}
},
builder: (context, state) {
if (state is ProfileLoaded) {
return Container(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 12),
child: ListView(
children: [
Text(
"View and Update your Profile Information",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
Elusive.address_book,
color: primary,
),
title: Text(
"Basic Information",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(Icons.person, "Primary", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider<ProfileBloc>.value(
value: ProfileBloc()
..add(GetPrimaryBasicInfo(
primaryBasicInformation: profile)),
child: PrimaryInfo(
token: token!,
profileId: profileId!,
),
);
}));
}),
subMenu(Icons.home, "Addresses", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => AddressBloc()
..add(GetAddress(
addresses: state.profileInformation
.basicInfo.addresses)),
child: const AddressScreen(),
);
}));
}),
subMenu(Icons.contact_mail, "Identifications",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => IdentificationBloc()
..add(GetIdentifications(
identificationInformation: state
.profileInformation
.basicInfo
.identifications)),
child: const IdentificationsScreen(),
);
}));
}),
subMenu(Icons.contact_phone, "Contact Info",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ContactBloc()
..add(GetContacts(
contactInformations: state
.profileInformation
.basicInfo
.contactInformation)),
child: const ContactInformationScreen(),
);
}));
}),
subMenu(Icons.flag, "Citizenships", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => CitizenshipBloc()
..add(GetCitizenship(
citizenship: state
.profileInformation
.basicInfo
.citizenships)),
child: CitizenShipScreen(
profileId: profileId!, token: token!),
);
}));
}),
]),
const Divider(),
MainMenu(
icon: Elusive.group,
title: "Family",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => FamilyBloc()
..add(GetFamilies(
profileId: profileId!, token: token!)),
child: const FamilyBackgroundScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.graduation_cap,
title: "Education",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EducationBloc()
..add(GetEducationalBackground(
profileId: profileId!, token: token!)),
child: const EducationScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Icons.stars,
title: "Eligibility",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => EligibilityBloc()
..add(GetEligibilities(
profileId: profileId!, token: token!)),
child: const EligibiltyScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.shopping_bag,
title: "Work History",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => WorkHistoryBloc()
..add(GetWorkHistories(
profileId: profileId!, token: token!)),
child: const WorkHistoryScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: FontAwesome5.walking,
title: "Voluntary Work & Civic Services",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => VoluntaryWorkBloc()
..add(GetVoluntarWorks(
profileId: profileId!, token: token!)),
child: const VolunataryWorkScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Elusive.lightbulb,
title: "Learning & Development",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => LearningDevelopmentBloc()
..add(GetLearningDevelopments(
profileId: profileId!, token: token!)),
child: const LearningAndDevelopmentScreen(),
);
}));
},
),
const Divider(),
MainMenu(
icon: Brandico.codepen,
title: "Personal References",
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => ReferencesBloc()
..add(GetReferences(
profileId: profileId!, token: token!)),
child: const ReferencesScreen(),
);
}));
},
),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
Icons.info,
color: primary,
),
title: Text(
"Other Information",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(
Icons.fitness_center, "Skills & Hobbies",
() {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => HoobiesBloc()
..add(GetSkillsHobbies(
profileId: profileId!,
token: token!)),
child: const SkillHobbiesScreen(),
);
}));
}),
subMenu(FontAwesome5.certificate,
"Organization Memberships", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
OrganizationMembershipBloc()
..add(GetOrganizationMembership(
profileId: profileId!,
token: token!)),
child: const OrgMembershipsScreen(),
);
}));
}),
subMenu(Entypo.doc_text,
"Non-Academic Recognitions", () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
NonAcademicRecognitionBloc()
..add(GetNonAcademicRecognition(
profileId: profileId!,
token: token!)),
child:
const NonAcademicRecognitionScreen(),
);
}));
}),
]),
ExpandableGroup(
collapsedIcon:
const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up),
header: const ListTile(
leading: Icon(
FontAwesome5.laptop_house,
color: primary,
),
title: Text(
"Assets",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
items: [
subMenu(ModernPictograms.home,
"Real Property Tax", () {}),
]),
],
),
);
}
if (state is ProfileLoading) {
return const LoadingScreen();
}
if (state is ProfileErrorState) {
return SomethingWentWrong(
message: state.mesage,
onpressed: () {
BlocProvider.of<ProfileBloc>(context).add(
LoadProfile(token: token!, userID: profileId!));
});
}
return Container();
},
);
}
return Container();
}),
));
return Container();
}),
)),
);
}
}

View File

@ -5,6 +5,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
@ -28,6 +29,7 @@ class RbacAgencyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
List<Agency> agencies = [];
List<Category> agencyCategory = [];
Category? selectedAgencyCategory;
bool? isPrivate;
@ -38,7 +40,37 @@ class RbacAgencyScreen extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
title: const Text("Agencies"),
actions: [
actions: context.watch<AgencyBloc>().state is AgencyLoadingState || context.watch<AgencyBloc>().state is AgencyErrorState || context.watch<AgencyBloc>().state is AgencyAddesState?[]:[
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: primary),
builder: (Agency rbac) {
return Column(
children: [
ListTile(
title: Text(rbac.name!),
),
const Divider(),
],
);
},
filter: (Agency rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Agency found :("),
),
items: agencies,
searchLabel: "Search Agency",
suggestion: const Center(
child: Text("Search agency by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
parent = context;
showDialog(
@ -220,6 +252,7 @@ class RbacAgencyScreen extends StatelessWidget {
builder: (context, state) {
final parent = context;
if (state is AgenciesLoaded) {
agencies = state.agencies;
agencyCategory = state.agencyCategory;
if (state.agencies.isNotEmpty) {
return ListView.builder(
@ -262,7 +295,7 @@ class RbacAgencyScreen extends StatelessWidget {
});
} else {
return const EmptyData(
message: "No Object available. Please click + to add.");
message: "No Agency available. Please click + to add.");
}
}if (state is AgencyErrorState) {
return SomethingWentWrong(

View File

@ -82,7 +82,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
areaType = null;
return AlertDialog(
title: const Text("Add New Role"),
title: const Text("Add New Assigned area"),
content: FormBuilder(
key: formKey,
child: StatefulBuilder(builder: (context, setState) {
@ -1005,7 +1005,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
if (state is AssignedAreaDeletedState) {
if (state.success) {
successAlert(context, "Delete Successfull!",
"Role Module Deleted Successfully", () {
"Assign Area Deleted Successfully", () {
Navigator.of(context).pop();
context
.read<AssignAreaBloc>()
@ -1013,7 +1013,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed",
context, "Delete Failed", "Assign Area Deletion Failed",
() {
Navigator.of(context).pop();
context

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/error_state.dart';
@ -23,83 +25,283 @@ class RbacModuleScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<ModuleBloc>(context);
List<RBAC> modules = [];
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Module Screen"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Module name *", "Module name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle("Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!.value['object_name'];
String? slug =
formKey.currentState!.value['slug'];
String? short = formKey
.currentState!.value['shorthand'];
parent.read<ModuleBloc>().add(
AddRbacModule(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
actions:
context.watch<ModuleBloc>().state is ModuleLoadingState ||
context.watch<ModuleBloc>().state is ModuleErrorState ||
context.watch<ModuleBloc>().state is ModuleAddedState ||
context.watch<ModuleBloc>().state is ModuleDeletedState ||
context.watch<ModuleBloc>().state is ModuleAddedState ||
context.watch<ModuleBloc>().state is ModuleUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
const SizedBox(
width: 12,
),
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Module name *",
"Module name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
////Update
bloc.add(UpdateRbacModule(
moduleId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
////delete
Navigator.pop(context);
confirmAlert(context, () {
context
.read<ModuleBloc>()
.add(DeleteRbacModule(
moduleId:
rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Module found :("),
),
items: modules,
searchLabel: "Search Module",
suggestion: const Center(
child: Text("Search module by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Module name *", "Module name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration:
normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator:
FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand",
decoration: normalTextFieldStyle(
"Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!
.value['object_name'];
String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey
.currentState!
.value['shorthand'];
parent.read<ModuleBloc>().add(
AddRbacModule(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -162,7 +364,7 @@ class RbacModuleScreen extends StatelessWidget {
context.read<ModuleBloc>().add(GetModule());
});
} else {
errorAlert(context, "Delete Failed", "Module Delete Failed",
errorAlert(context, "Delete Failed", "Module Deletion Failed",
() {
Navigator.of(context).pop();
context.read<ModuleBloc>().add(GetModule());
@ -174,6 +376,7 @@ class RbacModuleScreen extends StatelessWidget {
final parent = context;
if (state is ModuleLoaded) {
if (state.module.isNotEmpty) {
modules = state.module;
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -190,18 +393,22 @@ class RbacModuleScreen extends StatelessWidget {
children: [
Expanded(
child: Row(
children: [
CircleAvatar(child: Text('${index+1}'),),
const SizedBox(width: 12,),
Text(state.module[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
],
)),
children: [
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Text(state.module[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
],
)),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
@ -211,7 +418,8 @@ class RbacModuleScreen extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Update Module"),
title:
const Text("Update Module"),
content: FormBuilder(
key: formKey,
child: Column(
@ -355,7 +563,7 @@ class RbacModuleScreen extends StatelessWidget {
});
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
message: "No Module available. Please click + to add.");
}
}
if (state is ModuleErrorState) {

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
@ -33,106 +32,121 @@ class RbacModuleObjectsScreen extends StatelessWidget {
List<ValueItem> selectedValueItemObjects = [];
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
elevation: 0,
backgroundColor: primary,
title: const Text("Module Object Screen"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemObjects = objects.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add New Module Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "module",
decoration:
normalTextFieldStyle("Module", "Module"),
items: modules.isEmpty
? []
: modules.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? object) {
selectedModule = object;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemObjects = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Objects",
padding: const EdgeInsets.all(8),
options: valueItemObjects,
selectionType: SelectionType.multi,
chipConfig:
const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemObjects.isNotEmpty) {
int assignerId = id;
int moduleId = selectedModule!.id!;
List<int> objectId = [];
for (var object in objects) {
selectedValueItemObjects
.forEach((element) {
if (element.label.toLowerCase() ==
object.name?.toLowerCase()) {
objectId.add(object.id!);
actions: context.watch<ModuleObjectsBloc>().state
is ModuleObjectLoadingState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectsErrorState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectAddedState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectDeletedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemObjects = objects.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add New Module Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "module",
decoration: normalTextFieldStyle(
"Module", "Module"),
items: modules.isEmpty
? []
: modules.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? object) {
selectedModule = object;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemObjects =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Objects",
padding: const EdgeInsets.all(8),
options: valueItemObjects,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemObjects
.isNotEmpty) {
int assignerId = id;
int moduleId = selectedModule!.id!;
List<int> objectId = [];
for (var object in objects) {
selectedValueItemObjects
.forEach((element) {
if (element.label
.toLowerCase() ==
object.name
?.toLowerCase()) {
objectId.add(object.id!);
}
});
}
Navigator.of(context).pop();
parent
.read<ModuleObjectsBloc>()
.add(AddRbacModuleObjects(
assignerId: assignerId,
moduleId: moduleId,
objectsId: objectId));
}
});
}
Navigator.of(context).pop();
parent.read<ModuleObjectsBloc>().add(
AddRbacModuleObjects(
assignerId: assignerId,
moduleId: moduleId,
objectsId: objectId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -140,7 +154,6 @@ class RbacModuleObjectsScreen extends StatelessWidget {
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<ModuleObjectsBloc, ModuleObjectsState>(
listener: (context, state) {
if (state is ModuleObjectLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
@ -157,13 +170,13 @@ class RbacModuleObjectsScreen extends StatelessWidget {
if (state is ModuleObjectDeletedState) {
if (state.success) {
successAlert(
context, "Delete Successfull!", "Role Deleted Successfully",
context, "Delete Successfull!", "Module Object Deleted Successfully",
() {
Navigator.of(context).pop();
context.read<ModuleObjectsBloc>().add(GetModuleObjects());
});
} else {
errorAlert(context, "Delete Failed", "Role Delete Failed", () {
errorAlert(context, "Delete Failed", "Module Object Deletion Failed", () {
Navigator.of(context).pop();
context.read<ModuleObjectsBloc>().add(GetModuleObjects());
});
@ -270,20 +283,23 @@ class RbacModuleObjectsScreen extends StatelessWidget {
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold),
.copyWith(
color: primary, fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
message:
"No Module Object available. Please click + to add.");
}
}
if (state is ModuleObjectsErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
parent.read<ModuleObjectsBloc>().add(GetModuleObjects());
message: state.message,
onpressed: () {
parent.read<ModuleObjectsBloc>().add(GetModuleObjects());
});
}
return Container();

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../theme-data.dart/box_shadow.dart';
@ -24,83 +26,274 @@ class RbacObjectScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<ObjectBloc>(context);
List<RBAC> objects = [];
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Objects Screen"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Object name *", "Object name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle("Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!.value['object_name'];
String? slug =
formKey.currentState!.value['slug'];
String? short = formKey
.currentState!.value['shorthand'];
parent.read<ObjectBloc>().add(
AddRbacObject(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
actions:
context.watch<ObjectBloc>().state is ObjectLoadingState ||
context.watch<ObjectBloc>().state is ObjectAddedState ||
context.watch<ObjectBloc>().state is ObjectErrorState ||
context.watch<ObjectBloc>().state is ObjectDeletedState ||
context.watch<ObjectBloc>().state is ObjectUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Object name *",
"Object name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacObject(
objectId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc.add(DeleteRbacObject(
objectId: rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Role found :("),
),
items: objects,
searchLabel: "Search Object",
suggestion: const Center(
child: Text("Search object by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Object name *", "Object name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration:
normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator:
FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand",
decoration: normalTextFieldStyle(
"Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!
.value['object_name'];
String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey
.currentState!
.value['shorthand'];
parent.read<ObjectBloc>().add(
AddRbacObject(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -162,7 +355,7 @@ class RbacObjectScreen extends StatelessWidget {
context.read<ObjectBloc>().add(GetObjects());
});
} else {
errorAlert(context, "Delete Failed", "Object Delete Failed",
errorAlert(context, "Delete Failed", "Object Deletion Failed",
() {
Navigator.of(context).pop();
context.read<ObjectBloc>().add(GetObjects());
@ -174,6 +367,7 @@ class RbacObjectScreen extends StatelessWidget {
final parent = context;
if (state is ObjectLoaded) {
if (state.objects.isNotEmpty) {
objects = state.objects;
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../theme-data.dart/box_shadow.dart';
@ -24,82 +26,276 @@ class RbacOperationScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<OperationBloc>(context);
List<RBAC> operations = [];
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
title: const Text("Operations Screen"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Operation"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Operation name *", "Operation name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
centerTitle: true,
actions: context.watch<OperationBloc>().state
is OperationLoadingState ||
context.watch<OperationBloc>().state is OperationErrorState ||
context.watch<OperationBloc>().state is OperationAddedState ||
context.watch<OperationBloc>().state is OperationDeletedState ||
context.watch<OperationBloc>().state is OperationUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder:
(BuildContext context) {
return AlertDialog(
title: const Text(
"Update Operation"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Operation name *",
"Operation name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue: rbac
.shorthand,
validator: FormBuilderValidators
.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
onPressed:
() {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacOperation(
operationId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text(
"Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
context
.read<OperationBloc>()
.add(DeleteRbacOperation(
operationId: rbac.id!));
}, "Delete?", "Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Operation found :("),
),
items: operations,
searchLabel: "Search Operation",
suggestion: const Center(
child: Text("Search operation by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Operation"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Operation name *", "Operation name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration:
normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"),
name: "shorthand",
decoration: normalTextFieldStyle(
"Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey.currentState!
.value['object_name'];
String? slug = formKey
.currentState!.value['slug'];
String? short = formKey
.currentState!
.value['shorthand'];
parent.read<OperationBloc>().add(
AddRbacOperation(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle("Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!.value['object_name'];
String? slug =
formKey.currentState!.value['slug'];
String? short = formKey
.currentState!.value['shorthand'];
parent.read<OperationBloc>().add(
AddRbacOperation(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -162,8 +358,8 @@ class RbacOperationScreen extends StatelessWidget {
context.read<OperationBloc>().add(GetOperations());
});
} else {
errorAlert(context, "Delete Failed", "Operation Delete Failed",
() {
errorAlert(
context, "Delete Failed", "Operation Deletion Failed", () {
Navigator.of(context).pop();
context.read<OperationBloc>().add(GetOperations());
});
@ -174,6 +370,7 @@ class RbacOperationScreen extends StatelessWidget {
final parent = context;
if (state is OperationsLoaded) {
if (state.operations.isNotEmpty) {
operations = state.operations;
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -190,18 +387,22 @@ class RbacOperationScreen extends StatelessWidget {
children: [
Expanded(
child: Row(
children: [
CircleAvatar(child: Text('${index+1}'),),
const SizedBox(width: 12,),
Text(state.operations[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
],
)),
children: [
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Text(state.operations[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
],
)),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
@ -211,7 +412,8 @@ class RbacOperationScreen extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Update Operation"),
title: const Text(
"Update Operation"),
content: FormBuilder(
key: formKey,
child: Column(
@ -355,7 +557,7 @@ class RbacOperationScreen extends StatelessWidget {
});
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
message: "No Operation available. Please click + to add.");
}
}
if (state is OperationErrorState) {

View File

@ -7,7 +7,9 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
@ -32,6 +34,8 @@ class RbacPermissionScreen extends StatelessWidget {
List<RBAC> operations = [];
List<ValueItem> valueItemOperations = [];
List<ValueItem> selectedValueItemOperations = [];
List<RBACPermission> permissions = [];
final bloc = BlocProvider.of<PermissionBloc>(context);
final formKey = GlobalKey<FormBuilderState>();
BuildContext? parent;
return Scaffold(
@ -39,103 +43,189 @@ class RbacPermissionScreen extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
title: const Text("Permissions Screen"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemOperations = operations.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Permission"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "object",
decoration:
normalTextFieldStyle("Permission", "Permission"),
items: objects.isEmpty
? []
: objects.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? object) {
selectedObject = object;
},
actions: context.watch<PermissionBloc>().state is PermissonLoadingState ||
context.watch<PermissionBloc>().state is PermissionErrorState ||
context.watch<PermissionBloc>().state is PermissionDeletedState ||
context.watch<PermissionBloc>().state is PermissionAddedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBACPermission rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(
"${rbac.object?.name} - ${rbac.operation?.name}",
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc.add(DeleteRbacPermission(
permissionId: rbac.id!));
}, "Delete?", "Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBACPermission rbac) {
return [
rbac.object!.name! + rbac.operation!.name!
];
},
failure: const Center(
child: Text("No permission found :("),
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemOperations = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Operations",
padding: const EdgeInsets.all(8),
options: valueItemOperations,
selectionType: SelectionType.multi,
chipConfig:
const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemOperations
.isNotEmpty) {
int assignerId = id;
int objectId = selectedObject!.id!;
items: permissions,
searchLabel: "Search Permission",
suggestion: const Center(
child: Text("Search permission by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
showDialog(
context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemOperations = operations.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Permission"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "object",
decoration: normalTextFieldStyle(
"Permission", "Permission"),
items: objects.isEmpty
? []
: objects.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? object) {
selectedObject = object;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemOperations =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Operations",
padding: const EdgeInsets.all(8),
options: valueItemOperations,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemOperations
.isNotEmpty) {
int assignerId = id;
int objectId = selectedObject!.id!;
List<int> opIds = [];
for (var operation in operations) {
selectedValueItemOperations
.forEach((element) {
if (element.label.toLowerCase() ==
operation.name?.toLowerCase()) {
opIds.add(operation.id!);
List<int> opIds = [];
for (var operation in operations) {
selectedValueItemOperations
.forEach((element) {
if (element.label
.toLowerCase() ==
operation.name
?.toLowerCase()) {
opIds.add(operation.id!);
}
});
}
Navigator.pop(context);
parent!.read<PermissionBloc>().add(
AddRbacPermission(
assignerId: assignerId,
objectId: objectId,
operationIds: opIds));
}
});
}
Navigator.pop(context);
parent!.read<PermissionBloc>().add(
AddRbacPermission(
assignerId: assignerId,
objectId: objectId,
operationIds: opIds));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -179,8 +269,8 @@ class RbacPermissionScreen extends StatelessWidget {
context.read<PermissionBloc>().add(GetPermissions());
});
} else {
errorAlert(context, "Delete Failed", "Permission Delete Failed",
() {
errorAlert(
context, "Delete Failed", "Permission Deletion Failed", () {
Navigator.of(context).pop();
context.read<PermissionBloc>().add(GetPermissions());
});
@ -193,6 +283,7 @@ class RbacPermissionScreen extends StatelessWidget {
objects = state.objects;
operations = state.operations;
if (state.permissions.isNotEmpty) {
permissions = state.permissions;
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -209,41 +300,39 @@ class RbacPermissionScreen extends StatelessWidget {
children: [
Expanded(
child: Row(
children: [
CircleAvatar(
children: [
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Flexible(
child: Text(
"${state.permissions[index].object?.name} - ${state.permissions[index].operation?.name}",
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
),
],
)),
Flexible(
child: Text(
"${state.permissions[index].object?.name} - ${state.permissions[index].operation?.name}",
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
),
],
)),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 1) {
if (value == 1) {
confirmAlert(context, () {
context.read<PermissionBloc>().add(
DeleteRbacPermission(
permissionId: state.permissions[index].id!));
context.read<PermissionBloc>().add(
DeleteRbacPermission(
permissionId: state
.permissions[index].id!));
}, "Delete?", "Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Remove",
value: 1,
@ -271,8 +360,9 @@ class RbacPermissionScreen extends StatelessWidget {
}
if (state is PermissionErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
parent!.read<PermissionBloc>().add(GetPermissions());
message: state.message,
onpressed: () {
parent!.read<PermissionBloc>().add(GetPermissions());
});
}
return Container();

View File

@ -5,9 +5,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/models/value_item.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission_assignment/permission_assignment_bloc.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/rbac.dart';
@ -15,7 +13,6 @@ import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/global_context.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
@ -40,91 +37,111 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
title: const Text("Permission Assignment"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
valueItemPermission = permissions.map((e) {
return ValueItem(
label: "${e.object!.name} - ${e.operation!.name}",
value: e.id.toString());
}).toList();
return AlertDialog(
title: const Text("Add Permission"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected: (List<ValueItem> selectedOptions) {
selectedValueItemPermission = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Operations",
padding: const EdgeInsets.all(8),
options: valueItemPermission,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon: const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!.saveAndValidate() &&
selectedValueItemPermission.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> opIds =
selectedValueItemPermission.map((e) {
return int.parse(e.value!);
}).toList();
Navigator.pop(context);
parent.read<PermissionAssignmentBloc>().add(
AddPersmissionAssignment(
assignerId: assignerId,
opsId: opIds,
roleId: roleId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
actions: context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentLoadingScreen ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentErrorState ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentAddedState ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentDeletedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
valueItemPermission = permissions.map((e) {
return ValueItem(
label: "${e.object!.name} - ${e.operation!.name}",
value: e.id.toString());
}).toList();
return AlertDialog(
title: const Text("Add Permission"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration:
normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemPermission =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Operations",
padding: const EdgeInsets.all(8),
options: valueItemPermission,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemPermission
.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> opIds =
selectedValueItemPermission
.map((e) {
return int.parse(e.value!);
}).toList();
Navigator.pop(context);
parent
.read<
PermissionAssignmentBloc>()
.add(AddPersmissionAssignment(
assignerId: assignerId,
opsId: opIds,
roleId: roleId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -183,7 +200,6 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
}
},
builder: (context, state) {
if (state is PermissionAssignmentLoadedState) {
if (state.permissionAssignments.isNotEmpty) {
permissions = state.permissions;

View File

@ -25,6 +25,7 @@ class RbacRoleScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bloc = BlocProvider.of<RoleBloc>(context);
final formKey = GlobalKey<FormBuilderState>();
List<RBAC> roles = [];
return Scaffold(
@ -32,102 +33,274 @@ class RbacRoleScreen extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
title: const Text("Role Screen"),
actions: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: primary),
builder: (RBAC rbac) {
return ListTile(
title: Text(rbac.name!),
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Role found :("),
),
items: roles,
searchLabel: "Search Role",
suggestion: const Center(
child: Text("Search role by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Role"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Role name *", "Role name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle("Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!.value['object_name'];
String? slug =
formKey.currentState!.value['slug'];
String? short = formKey
.currentState!.value['shorthand'];
parent.read<RoleBloc>().add(AddRbacRole(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
actions:
context.watch<RoleBloc>().state is RoleLoadingState ||
context.watch<RoleBloc>().state is RoleErrorState ||
context.watch<RoleBloc>().state is RoleDeletedState? ||
context.watch<RoleBloc>().state is RoleAddedState? ||
context.watch<RoleBloc>().state is RoleUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight
.w500,
color: primary)),
),
],
)),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Role"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Role name *",
"Role name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacRole(
roleId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc
.add(DeleteRbacRole(
roleId: rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Role found :("),
),
items: roles,
searchLabel: "Search Role",
suggestion: const Center(
child: Text("Search role by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Role"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderTextField(
name: "object_name",
decoration: normalTextFieldStyle(
"Role name *", "Role name "),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
name: "slug",
decoration:
normalTextFieldStyle("Slug ", "Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
validator:
FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand",
decoration: normalTextFieldStyle(
"Shorthand ", "Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
String name = formKey
.currentState!
.value['object_name'];
String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey
.currentState!
.value['shorthand'];
parent.read<RoleBloc>().add(
AddRbacRole(
id: id,
name: name,
shorthand: short,
slug: slug));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),

View File

@ -36,7 +36,7 @@ class RbacRoleAssignment extends StatelessWidget {
centerTitle: true,
backgroundColor: primary,
title: const Text("User Roles Screens"),
actions: [
actions: context.watch<RoleAssignmentBloc>().state is RoleAssignmentLoadingState || context.watch<RoleAssignmentBloc>().state is RoleAssignmentErrorState || context.watch<RoleAssignmentBloc>().state is UserNotExistError || context.watch<RoleAssignmentBloc>().state is RoleAddedState? []: [
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
@ -131,13 +131,13 @@ class RbacRoleAssignment extends StatelessWidget {
if (state is AssignedRoleDeletedState) {
if (state.success) {
successAlert(context, "Delete Successfull!",
"Role Module Deleted Successfully", () {
"Role Deleted Successfully", () {
Navigator.of(context).pop();
context.read<RoleAssignmentBloc>().add(LoadAssignedRole());
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
context, "Delete Failed", "Role Deletion Failed", () {
Navigator.of(context).pop();
context.read<RoleAssignmentBloc>().add(LoadAssignedRole());
});

View File

@ -36,7 +36,7 @@ class RbacRoleExtendScreen extends StatelessWidget {
elevation: 0,
backgroundColor: primary,
title: const Text("Role Extend"),
actions: [
actions: context.watch<RoleExtendBloc>().state is RoleExtendLoadingState || context.watch<RoleExtendBloc>().state is RoleExtendErrorState || context.watch<RoleExtendBloc>().state is RoleExtendAddedState || context.watch<RoleExtendBloc>().state is RoleExtendDeletedState? []:[
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,

View File

@ -34,100 +34,114 @@ class RbacRoleModuleScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
title: const Text("Role Modules Screen"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemModules = modules.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemModules = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Modules",
padding: const EdgeInsets.all(8),
options: valueItemModules,
selectionType: SelectionType.multi,
chipConfig:
const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemModules.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> modulesId = [];
for (var module in modules) {
selectedValueItemModules
.forEach((element) {
if (element.label.toLowerCase() ==
module.name?.toLowerCase()) {
modulesId.add(module.id!);
title: const Text("Role Module Screen" ),
centerTitle: true,
actions: context.watch<RoleModuleBloc>().state
is RoleModuleLoadingState ||
context.watch<RoleModuleBloc>().state is RoleModuleErrorState ||
context.watch<RoleModuleBloc>().state is RoleModuleAddedState ||
context.watch<RoleModuleBloc>().state is RoleModuleDeletedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemModules = modules.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration:
normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemModules =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Modules",
padding: const EdgeInsets.all(8),
options: valueItemModules,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemModules
.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> modulesId = [];
for (var module in modules) {
selectedValueItemModules
.forEach((element) {
if (element.label
.toLowerCase() ==
module.name
?.toLowerCase()) {
modulesId.add(module.id!);
}
});
}
Navigator.of(context).pop();
parent.read<RoleModuleBloc>().add(
AddRoleModule(
assignerId: assignerId,
roleId: roleId,
moduleIds: modulesId));
}
});
}
Navigator.of(context).pop();
parent.read<RoleModuleBloc>().add(
AddRoleModule(
assignerId: assignerId,
roleId: roleId,
moduleIds: modulesId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -156,7 +170,7 @@ class RbacRoleModuleScreen extends StatelessWidget {
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
context, "Delete Failed", "Role Module Deletion Failed", () {
Navigator.of(context).pop();
context.read<RoleModuleBloc>().add(GetRoleModules());
});
@ -258,20 +272,22 @@ class RbacRoleModuleScreen extends StatelessWidget {
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold),
.copyWith(
color: primary, fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
message: "No Role Module available. Please click + to add.");
}
}
if (state is RoleModuleErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<RoleModuleBloc>().add(GetRoleModules());
message: state.message,
onpressed: () {
context.read<RoleModuleBloc>().add(GetRoleModules());
});
}
return Container();

View File

@ -0,0 +1,307 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../model/rbac/rbac.dart';
import '../../../theme-data.dart/btn-style.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../theme-data.dart/form-style.dart';
import '../../../utils/alerts.dart';
import '../../../utils/global_context.dart';
import '../../../widgets/empty_data.dart';
class RbacRoleUnderScreen extends StatelessWidget {
final int id;
const RbacRoleUnderScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final parent = context;
Map<String, List<Content>> rolesUnder = {};
List<RBAC> roles = [];
RBAC? selectedRole;
List<ValueItem> valueItemRoles = [];
List<ValueItem> selectedValueItemRoles = [];
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Assignable Roles"),
actions: context.watch<RolesUnderBloc>().state
is RoleUnderLoadingState? ||
context.watch<RolesUnderBloc>().state is RoleUnderErrorState ||
context.watch<RolesUnderBloc>().state
is RoleUnderDeletedState ||
context.watch<RolesUnderBloc>().state is RoleUnderAddedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemRoles = roles.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Under"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle(
"Main Role", "Main Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemRoles = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Roles Under",
padding: const EdgeInsets.all(8),
options: valueItemRoles,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemRoles
.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> rolesId = [];
for (var role in roles) {
selectedValueItemRoles
.forEach((element) {
if (element.label
.toLowerCase() ==
role.name?.toLowerCase()) {
rolesId.add(role.id!);
}
});
}
Navigator.of(context).pop();
parent.read<RolesUnderBloc>().add(
AddRoleUnder(
roleId: roleId,
roleUnderIds: rolesId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<RolesUnderBloc, RolesUnderState>(
listener: (context, state) {
if (state is RoleUnderLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is RoleUnderLoadedState ||
state is RoleUnderErrorState ||
state is RoleUnderDeletedState ||
state is RoleUnderAddedState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////Deleted State
if (state is RoleUnderDeletedState) {
if (state.success) {
successAlert(
context, "Delete Successfull!", "Role Deleted Successfully",
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
////Added State
if (state is RoleUnderAddedState) {
if (state.response['success']) {
successAlert(
context, "Adding Successfull!", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(context, "Adding Failed", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
},
builder: (context, state) {
if (state is RoleUnderLoadedState) {
rolesUnder = {};
roles = state.roles;
if (state.rolesUnder.isNotEmpty) {
for (var roleUnder in state.rolesUnder) {
if (!rolesUnder.keys
.contains(roleUnder.roleUnderMain.name!.toLowerCase())) {
rolesUnder.addAll(
{roleUnder.roleUnderMain.name!.toLowerCase(): []});
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
} else {
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
}
}
}
if (state.rolesUnder.isNotEmpty) {
return GroupListView(
sectionsCount: rolesUnder.keys.toList().length,
countOfItemInSection: (int section) {
return rolesUnder.values.toList()[section].length;
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
trailing: IconButton(
color: Colors.grey.shade500,
icon: const Icon(Icons.delete),
onPressed: () {
confirmAlert(context,(){
context.read<RolesUnderBloc>().add(DeleteRoleUnder(roleUnderId:rolesUnder.values .toList()[index.section][index.index].id));
}, "Delete", "Delete Role?");
},
),
title: Row(
children: [
CircleAvatar(
child: Text("${index.index + 1}",
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: Colors.white))),
const SizedBox(
width: 20,
),
Expanded(
child: Text(
rolesUnder.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
),
],
),
);
},
separatorBuilder: (context, index) {
return const Divider();
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: Colors.white,
dense: true,
title: Text(
rolesUnder.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
color: primary, fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
}
}
if (state is RoleUnderErrorState) {
return SomethingWentWrong(
message: state.message,
onpressed: () {
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
return Container();
},
),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -1,296 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../model/rbac/rbac.dart';
import '../../../theme-data.dart/btn-style.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../theme-data.dart/form-style.dart';
import '../../../utils/alerts.dart';
import '../../../utils/global_context.dart';
import '../../../widgets/empty_data.dart';
class RbacRoleUnderScreen extends StatelessWidget {
final int id;
const RbacRoleUnderScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final parent = context;
Map<String, List<Content>> rolesUnder = {};
List<RBAC> roles = [];
RBAC? selectedRole;
List<ValueItem> valueItemRoles = [];
List<ValueItem> selectedValueItemRoles = [];
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Assignable Roles"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemRoles = roles.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Under"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle(
"Main Role", "Main Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemRoles = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Roles Under",
padding: const EdgeInsets.all(8),
options: valueItemRoles,
selectionType: SelectionType.multi,
chipConfig:
const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemRoles.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> rolesId = [];
for (var role in roles) {
selectedValueItemRoles
.forEach((element) {
if (element.label.toLowerCase() ==
role.name?.toLowerCase()) {
rolesId.add(role.id!);
}
});
}
Navigator.of(context).pop();
parent.read<RolesUnderBloc>().add(
AddRoleUnder(
roleId: roleId,
roleUnderIds: rolesId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<RolesUnderBloc, RolesUnderState>(
listener: (context, state) {
if (state is RoleUnderLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is RoleUnderLoadedState ||
state is RoleUnderErrorState ||
state is RoleUnderDeletedState ||
state is RoleUnderAddedState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////Deleted State
if (state is RoleUnderDeletedState) {
if (state.success) {
successAlert(context, "Delete Successfull!",
"Role Deleted Successfully", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
////Added State
if (state is RoleUnderAddedState) {
if (state.response['success']) {
successAlert(
context, "Adding Successfull!", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(context, "Adding Failed", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
},
builder: (context, state) {
if (state is RoleUnderLoadedState) {
rolesUnder = {};
roles = state.roles;
if (state.rolesUnder.isNotEmpty) {
for (var roleUnder in state.rolesUnder) {
if (!rolesUnder.keys
.contains(roleUnder.roleUnderMain.name!.toLowerCase())) {
rolesUnder.addAll(
{roleUnder.roleUnderMain.name!.toLowerCase(): []});
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
} else {
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
}
}
}
if (state.rolesUnder.isNotEmpty) {
return GroupListView(
sectionsCount: rolesUnder.keys.toList().length,
countOfItemInSection: (int section) {
return rolesUnder.values.toList()[section].length;
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
trailing: IconButton(
color: Colors.grey.shade500,
icon: const Icon(Icons.delete),
onPressed: () {
context.read<RolesUnderBloc>().add(DeleteRoleUnder(
roleUnderId: rolesUnder.values
.toList()[index.section][index.index]
.id));
},
),
title: Row(
children: [
CircleAvatar(
child: Text("${index.index + 1}",
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: Colors.white))),
const SizedBox(
width: 20,
),
Expanded(
child: Text(
rolesUnder.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)
),
),
],
),
);
},
separatorBuilder: (context, index) {
return const Divider();
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: Colors.white,
dense: true,
title: Text(
rolesUnder.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
}
}
if (state is RoleUnderErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
return Container();
},
),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -5,7 +5,6 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart';
import 'package:unit2/model/rbac/rbac_station.dart';
import 'package:unit2/model/utils/agency.dart';
@ -62,436 +61,469 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
centerTitle: true,
backgroundColor: primary,
title: const Text("Station Screen"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;
mainParentStations = [];
mainParent = stations.isEmpty ? true : false;
for (RbacStation station in stations) {
if (station.hierarchyOrderNo == 1) {
mainParentStations.add(station);
}
}
actions: context.watch<StationBloc>().state is StationLoadingState ||
context.watch<StationBloc>().state is StationErrorState ||
context.watch<StationBloc>().state is RbacStationAddedState ||
context.watch<StationBloc>().state is FilterStationState
? []
: [
AddLeading(onPressed: () {
BuildContext parent = context;
mainParentStations = [];
mainParent = stations.isEmpty ? true : false;
for (RbacStation station in stations) {
if (station.hierarchyOrderNo == 1) {
mainParentStations.add(station);
}
}
/////Add new tation
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Station"),
content: SingleChildScrollView(
child: FormBuilder(
key: formKey,
child: StatefulBuilder(builder: (context, setState) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
////is main parent
FormBuilderSwitch(
initialValue: mainParent,
activeColor: second,
onChanged: (value) {
setState(() {
mainParent = !mainParent;
});
},
decoration: normalTextFieldStyle(
"is Main Parent?", 'is Main Parent?'),
name: 'main-parent',
title: Text(mainParent ? "YES" : "NO"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
SizedBox(
height: mainParent ? 0 : 8,
),
//// selected main parent
SizedBox(
child: mainParent == true
? const SizedBox.shrink()
: FormBuilderDropdown<RbacStation>(
decoration: normalTextFieldStyle(
"Main Parent Station",
"Main Parent Station"),
name: "parent-stations",
items: mainParentStations.isEmpty
? []
: mainParentStations.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e.stationName!),
);
}).toList(),
onChanged: (RbacStation? e) {
setState(() {
selectedMainParentStation = e;
parentStations = [];
for (RbacStation station
in stations) {
if (station.mainParentStation ==
selectedMainParentStation!
.id) {
parentStations.add(station);
}
}
parentStations.add(
selectedMainParentStation!);
});
},
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
),
),
SizedBox(
height: mainParent ? 0 : 8,
),
////parent station
SizedBox(
child: mainParent == true
? const SizedBox.shrink()
: FormBuilderDropdown<RbacStation>(
decoration: normalTextFieldStyle(
"Parent Station", "Parent Station"),
name: "parent-stations",
onChanged: (RbacStation? e) {
setState(() {
selectedParentStation = e;
});
},
items: parentStations.isEmpty
? []
: parentStations.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e.stationName!),
);
}).toList(),
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
),
),
const SizedBox(
height: 12,
),
////Station Type
SearchField(
itemHeight: 50,
suggestionsDecoration: searchFieldDecoration(),
suggestions: stationTypes
.map((StationType stationType) =>
SearchFieldListItem(
stationType.typeName!,
item: stationType,
child: Padding(
padding:
const EdgeInsets.symmetric(
horizontal: 10),
child: ListTile(
title: Text(
stationType.typeName!,
overflow: TextOverflow.visible,
)),
)))
.toList(),
validator: (station) {
if (station!.isEmpty) {
return "This field is required";
}
return null;
},
focusNode: stationTypeFocusNode,
searchInputDecoration:
normalTextFieldStyle("Station Type *", "")
.copyWith(
suffixIcon: GestureDetector(
onTap: () => stationTypeFocusNode.unfocus(),
child: const Icon(Icons.arrow_drop_down),
)),
onSuggestionTap: (position) {
setState(() {
selectedStationType = position.item!;
stationTypeFocusNode.unfocus();
});
},
emptyWidget: EmptyWidget(
title: "Add StationType",
controller: addStationTypeController,
onpressed: () {
setState(() {
StationType stationType = StationType(
id: null,
typeName:
addStationTypeController.text,
color: null,
order: null,
isActive: null,
group: null);
stationTypes.add(stationType);
Navigator.pop(context);
});
}),
),
const SizedBox(
height: 12,
),
////Position title
FormBuilderDropdown(
decoration: normalTextFieldStyle(
"Head Position", "Head Position"),
name: "head-position",
items: positions.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e.title!),
);
}).toList(),
onChanged: (title) {
selectedPositiontitle = title;
},
),
const SizedBox(
height: 12,
),
////is within parent
FormBuilderSwitch(
initialValue: true,
activeColor: second,
onChanged: (value) {
setState(() {
isWithinParent = value!;
});
},
decoration: normalTextFieldStyle(
"Location of the station within this parent?",
'Location of the station within this parent?'),
name: 'isWithinParent',
title: Text(isWithinParent ? "YES" : "NO"),
),
const SizedBox(
height: 12,
),
Row(
//// Station Name
children: [
Flexible(
child: FormBuilderTextField(
validator:
FormBuilderValidators.required(
errorText:
"This Field is required"),
decoration: normalTextFieldStyle(
"Station name", "Station name"),
name: "station-name"),
),
const SizedBox(
width: 12,
),
//// Acronym
Flexible(
child: FormBuilderTextField(
validator:
FormBuilderValidators.required(
errorText:
"This Field is required"),
decoration: normalTextFieldStyle(
"Acronym", "Acronym"),
name: "acronym"),
),
],
),
const SizedBox(
height: 12,
),
FormBuilderTextField(
////Description
decoration: normalTextFieldStyle(
"Station description",
"Station description"),
name: "station-description"),
const SizedBox(
height: 12,
),
Row(
children: [
Flexible(
////Code
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Code", "Code"),
name: "code"),
),
const SizedBox(
width: 12,
),
Flexible(
//// Full Code
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Full Code", "Full Code"),
name: "fullcode"),
),
],
),
const SizedBox(
height: 12,
),
////is Hospital
FormBuilderSwitch(
initialValue: isHospital,
activeColor: second,
onChanged: (value) {
setState(() {
isHospital = !isHospital;
});
},
decoration:
normalTextFieldStyle("Is Hospital", ''),
name: 'isHospital',
title: Text(isHospital == true ? "YES" : "NO"),
),
const SizedBox(
height: 20,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
RbacStation? newStation;
if (formKey.currentState!
.saveAndValidate()) {
String? stationName = formKey
.currentState!
.value['station-name'];
String? acronym = formKey
.currentState!.value['acronym'];
String? code = formKey
.currentState!.value['code'];
String? fullcode = formKey
.currentState!.value['fullcode'];
String? description = formKey
.currentState!
.value['station-description'];
newStation = RbacStation(
id: null,
stationName: stationName,
stationType: selectedStationType,
hierarchyOrderNo: mainParent
? 1
: selectedParentStation!
.hierarchyOrderNo! +
1,
headPosition:
selectedPositiontitle?.title,
governmentAgency:
GovernmentAgency(
agencyid:
selectedAgencyId,
agencyname: null,
agencycatid: null,
privateEntity: null,
contactinfoid: null),
acronym: acronym,
parentStation: mainParent
? null
: selectedParentStation!.id!,
code: code,
fullcode: fullcode,
childStationInfo: null,
islocationUnderParent:
isWithinParent,
mainParentStation: mainParent
? null
: selectedMainParentStation!
.id!,
description: description,
ishospital: isHospital,
isactive: true,
sellingStation: null);
Navigator.pop(context);
rbacStationBloc.add(AddRbacStation(
station: newStation));
}
/////Add new tation
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Station"),
content: SingleChildScrollView(
child: FormBuilder(
key: formKey,
child:
StatefulBuilder(builder: (context, setState) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
////is main parent
FormBuilderSwitch(
initialValue: mainParent,
activeColor: second,
onChanged: (value) {
setState(() {
mainParent = !mainParent;
});
},
child: const Text("Add"))),
],
);
}),
),
),
);
});
}),
////Filter
IconButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text(
"Select agency to filter stations",
textAlign: TextAlign.center,
),
content: SizedBox(
child: // //// Filter Agencies
Padding(
padding: const EdgeInsets.all(8),
child: SearchField(
inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 100,
focusNode: agencyFocusNode,
suggestions: agencies
.map((Agency agency) =>
SearchFieldListItem(agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!,
overflow: TextOverflow.visible,
),
)))
.toList(),
searchInputDecoration:
normalTextFieldStyle("Filter", "").copyWith(
suffixIcon: IconButton(
icon: const Icon(Icons.arrow_drop_down),
onPressed: () {
agencyFocusNode.unfocus();
},
)),
onSuggestionTap: (agency) {
agencyFocusNode.unfocus();
selectedAgencyId = agency.item!.id!;
print(selectedAgencyId);
Navigator.pop(context);
rbacStationBloc.add(FilterStation(
agencyId: selectedAgencyId));
},
validator: (agency) {
if (agency!.isEmpty) {
return "This field is required";
}
return null;
},
emptyWidget: const Center(
child: Text("No result found..."),
)),
decoration: normalTextFieldStyle(
"is Main Parent?", 'is Main Parent?'),
name: 'main-parent',
title: Text(mainParent ? "YES" : "NO"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
SizedBox(
height: mainParent ? 0 : 8,
),
//// selected main parent
SizedBox(
child: mainParent == true
? const SizedBox.shrink()
: FormBuilderDropdown<RbacStation>(
decoration: normalTextFieldStyle(
"Main Parent Station",
"Main Parent Station"),
name: "parent-stations",
items: mainParentStations.isEmpty
? []
: mainParentStations.map((e) {
return DropdownMenuItem(
value: e,
child: Text(
e.stationName!),
);
}).toList(),
onChanged: (RbacStation? e) {
setState(() {
selectedMainParentStation = e;
parentStations = [];
for (RbacStation station
in stations) {
if (station
.mainParentStation ==
selectedMainParentStation!
.id) {
parentStations
.add(station);
}
}
parentStations.add(
selectedMainParentStation!);
});
},
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
),
SizedBox(
height: mainParent ? 0 : 8,
),
////parent station
SizedBox(
child: mainParent == true
? const SizedBox.shrink()
: FormBuilderDropdown<RbacStation>(
decoration: normalTextFieldStyle(
"Parent Station",
"Parent Station"),
name: "parent-stations",
onChanged: (RbacStation? e) {
setState(() {
selectedParentStation = e;
});
},
items: parentStations.isEmpty
? []
: parentStations.map((e) {
return DropdownMenuItem(
value: e,
child: Text(
e.stationName!),
);
}).toList(),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
),
const SizedBox(
height: 12,
),
////Station Type
SearchField(
itemHeight: 50,
suggestionsDecoration:
searchFieldDecoration(),
suggestions: stationTypes
.map((StationType stationType) =>
SearchFieldListItem(
stationType.typeName!,
item: stationType,
child: Padding(
padding: const EdgeInsets
.symmetric(
horizontal: 10),
child: ListTile(
title: Text(
stationType.typeName!,
overflow:
TextOverflow.visible,
)),
)))
.toList(),
validator: (station) {
if (station!.isEmpty) {
return "This field is required";
}
return null;
},
focusNode: stationTypeFocusNode,
searchInputDecoration:
normalTextFieldStyle(
"Station Type *", "")
.copyWith(
suffixIcon: GestureDetector(
onTap: () =>
stationTypeFocusNode.unfocus(),
child:
const Icon(Icons.arrow_drop_down),
)),
onSuggestionTap: (position) {
setState(() {
selectedStationType = position.item!;
stationTypeFocusNode.unfocus();
});
},
emptyWidget: EmptyWidget(
title: "Add StationType",
controller: addStationTypeController,
onpressed: () {
setState(() {
StationType stationType =
StationType(
id: null,
typeName:
addStationTypeController
.text,
color: null,
order: null,
isActive: null,
group: null);
stationTypes.add(stationType);
Navigator.pop(context);
});
}),
),
const SizedBox(
height: 12,
),
////Position title
FormBuilderDropdown(
decoration: normalTextFieldStyle(
"Head Position", "Head Position"),
name: "head-position",
items: positions.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e.title!),
);
}).toList(),
onChanged: (title) {
selectedPositiontitle = title;
},
),
const SizedBox(
height: 12,
),
////is within parent
FormBuilderSwitch(
initialValue: true,
activeColor: second,
onChanged: (value) {
setState(() {
isWithinParent = value!;
});
},
decoration: normalTextFieldStyle(
"Location of the station within this parent?",
'Location of the station within this parent?'),
name: 'isWithinParent',
title:
Text(isWithinParent ? "YES" : "NO"),
),
const SizedBox(
height: 12,
),
Row(
//// Station Name
children: [
Flexible(
child: FormBuilderTextField(
validator: FormBuilderValidators
.required(
errorText:
"This Field is required"),
decoration: normalTextFieldStyle(
"Station name",
"Station name"),
name: "station-name"),
),
const SizedBox(
width: 12,
),
//// Acronym
Flexible(
child: FormBuilderTextField(
validator: FormBuilderValidators
.required(
errorText:
"This Field is required"),
decoration: normalTextFieldStyle(
"Acronym", "Acronym"),
name: "acronym"),
),
],
),
const SizedBox(
height: 12,
),
FormBuilderTextField(
////Description
decoration: normalTextFieldStyle(
"Station description",
"Station description"),
name: "station-description"),
const SizedBox(
height: 12,
),
Row(
children: [
Flexible(
////Code
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Code", "Code"),
name: "code"),
),
const SizedBox(
width: 12,
),
Flexible(
//// Full Code
child: FormBuilderTextField(
decoration: normalTextFieldStyle(
"Full Code", "Full Code"),
name: "fullcode"),
),
],
),
const SizedBox(
height: 12,
),
////is Hospital
FormBuilderSwitch(
initialValue: isHospital,
activeColor: second,
onChanged: (value) {
setState(() {
isHospital = !isHospital;
});
},
decoration: normalTextFieldStyle(
"Is Hospital", ''),
name: 'isHospital',
title: Text(
isHospital == true ? "YES" : "NO"),
),
const SizedBox(
height: 20,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
RbacStation? newStation;
if (formKey.currentState!
.saveAndValidate()) {
String? stationName = formKey
.currentState!
.value['station-name'];
String? acronym = formKey
.currentState!
.value['acronym'];
String? code = formKey
.currentState!
.value['code'];
String? fullcode = formKey
.currentState!
.value['fullcode'];
String? description =
formKey.currentState!.value[
'station-description'];
newStation = RbacStation(
id: null,
stationName: stationName,
stationType:
selectedStationType,
hierarchyOrderNo: mainParent
? 1
: selectedParentStation!
.hierarchyOrderNo! +
1,
headPosition:
selectedPositiontitle
?.title,
governmentAgency:
GovernmentAgency(
agencyid:
selectedAgencyId,
agencyname: null,
agencycatid: null,
privateEntity: null,
contactinfoid:
null),
acronym: acronym,
parentStation:
mainParent
? null
: selectedParentStation!
.id!,
code: code,
fullcode: fullcode,
childStationInfo: null,
islocationUnderParent:
isWithinParent,
mainParentStation: mainParent
? null
: selectedMainParentStation!
.id!,
description: description,
ishospital: isHospital,
isactive: true,
sellingStation: null);
Navigator.pop(context);
rbacStationBloc.add(
AddRbacStation(
station: newStation));
}
},
child: const Text("Add"))),
],
);
}),
),
),
),
);
});
},
icon: const Icon(Icons.filter_list))
],
);
});
}),
////Filter
IconButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text(
"Select agency to filter stations",
textAlign: TextAlign.center,
),
content: SizedBox(
child: // //// Filter Agencies
Padding(
padding: const EdgeInsets.all(8),
child: SearchField(
inputFormatters: [
UpperCaseTextFormatter()
],
itemHeight: 100,
focusNode: agencyFocusNode,
suggestions: agencies
.map((Agency agency) =>
SearchFieldListItem(agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!,
overflow:
TextOverflow.visible,
),
)))
.toList(),
searchInputDecoration:
normalTextFieldStyle("Filter", "")
.copyWith(
suffixIcon: IconButton(
icon: const Icon(Icons.arrow_drop_down),
onPressed: () {
agencyFocusNode.unfocus();
},
)),
onSuggestionTap: (agency) {
agencyFocusNode.unfocus();
selectedAgencyId = agency.item!.id!;
print(selectedAgencyId);
Navigator.pop(context);
rbacStationBloc.add(FilterStation(
agencyId: selectedAgencyId));
},
validator: (agency) {
if (agency!.isEmpty) {
return "This field is required";
}
return null;
},
emptyWidget: const Center(
child: Text("No result found..."),
)),
),
),
);
});
},
icon: const Icon(Icons.filter_list))
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -643,7 +675,7 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
boxShadow: []),
padding:
const EdgeInsets
.only(
.only(
left: 30),
child: Row(
children: [
@ -652,7 +684,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
children: [
Padding(
padding:
const EdgeInsets.all(
const EdgeInsets
.all(
6),
child:
Text(
@ -720,7 +753,7 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
box1()
.copyWith(boxShadow: []),
padding: const EdgeInsets
.only(
.only(
left:
50),
child:
@ -873,7 +906,9 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
return SomethingWentWrong(
message: state.message,
onpressed: () {
context.read<StationBloc>().add(GetStations(agencyId: selectedAgencyId));
context
.read<StationBloc>()
.add(GetStations(agencyId: selectedAgencyId));
});
}

View File

@ -1,7 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_svg/svg.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:intl/intl.dart';
import 'package:qr_flutter/qr_flutter.dart';
@ -44,45 +45,45 @@ class BasicInfo extends StatelessWidget {
alignment: Alignment.center,
children: [
const CoverImage(),
// Positioned(
// top: blockSizeVertical * 15.5,
// child: Stack(
// alignment: Alignment.center,
// children: [
// CachedNetworkImage(
// imageUrl: fileUrl,
// imageBuilder: (context, imageProvider) =>
// Container(
// width: 160,
// height: 160,
// decoration: BoxDecoration(
// border: Border.all(
// color: Colors.black26, width: 3),
// shape: BoxShape.circle,
// image: DecorationImage(
// image: imageProvider,
// fit: BoxFit.cover),
// ),
// ),
// placeholder: (context, url) =>
// const CircularProgressIndicator(),
// errorWidget: (context, url, error) =>
// Container(
// width: 160,
// height: 160,
// decoration: BoxDecoration(
// border: Border.all(
// color: Colors.white, width: 3),
// shape: BoxShape.circle,
// ),
// child: SvgPicture.asset(
// 'assets/svgs/male.svg',
// ),
// ),
// ),
// ],
// ),
// ),
Positioned(
top: blockSizeVertical * 15.5,
child: Stack(
alignment: Alignment.center,
children: [
CachedNetworkImage(
imageUrl: fileUrl,
imageBuilder: (context, imageProvider) =>
Container(
width: 160,
height: 160,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black26, width: 3),
shape: BoxShape.circle,
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover),
),
),
placeholder: (context, url) =>
const CircularProgressIndicator(),
errorWidget: (context, url, error) =>
Container(
width: 160,
height: 160,
decoration: BoxDecoration(
border: Border.all(
color: Colors.white, width: 3),
shape: BoxShape.circle,
),
child: SvgPicture.asset(
'assets/svgs/male.svg',
),
),
),
],
),
),
Positioned(
top: 10,
left: 20,
@ -135,13 +136,14 @@ class BuildInformation extends StatelessWidget {
@override
Widget build(BuildContext context) {
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
globalFistname = globalFistname ?? userData.user!.login!.user!.firstName!.toUpperCase();
globalLastname =globalLastname ?? userData.user!.login!.user!.lastName!.toUpperCase();
globalMiddleName = globalMiddleName == null
? (userData.employeeInfo == null
globalFistname =
globalFistname ?? userData.employeeInfo!.profile!.firstName!.toUpperCase();
globalLastname =
globalLastname ?? userData.employeeInfo!.profile!.lastName!.toUpperCase();
globalMiddleName = globalMiddleName ??
(userData.employeeInfo == null
? ''
: userData.employeeInfo!.profile?.middleName?.toUpperCase())
: '';
: userData.employeeInfo!.profile?.middleName?.toUpperCase());
globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase();
globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate;
final uuid = userData.employeeInfo!.uuid;

View File

@ -26,7 +26,7 @@ import 'package:unit2/screens/superadmin/permission_assignment/permission_assign
import 'package:unit2/screens/superadmin/role/role_screen.dart';
import 'package:unit2/screens/superadmin/role_assignment.dart/role_assignment_screen.dart';
import 'package:unit2/screens/superadmin/role_extend/role_extend_screen.dart';
import 'package:unit2/screens/superadmin/roles_under/roles_under_screen.dart';
import 'package:unit2/screens/superadmin/roles_under/assignable_roles.dart';
import 'package:unit2/screens/superadmin/stations/stations_screen.dart';
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';

View File

@ -18,9 +18,9 @@ class _MenuScreenState extends State<MenuScreen> {
@override
Widget build(BuildContext context) {
final String firstName =globalFistname??
widget.userData!.user!.login!.user!.firstName!.toUpperCase();
widget.userData!.employeeInfo!.profile!.firstName!.toUpperCase();
final String lastname = globalLastname??
widget.userData!.user!.login!.user!.lastName!.toUpperCase();
widget.userData!.employeeInfo!.profile!.lastName!.toUpperCase();
return Drawer(
child: SizedBox(
height: screenHeight,

View File

@ -1,5 +1,6 @@
import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cool_alert/cool_alert.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -35,13 +36,13 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
player = AudioPlayer();
super.initState();
}
@override
void dispose() {
player?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -73,83 +74,86 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
progress!.dismiss();
}
if (state is ScanSuccess) {
Future.delayed(const Duration(seconds: 1), () async{
await player?.play(AssetSource("success.mp3"));
Future.delayed(const Duration(seconds: 1), () async {
await player?.play(AssetSource("success.mp3"));
});
context.read<PassCheckBloc>().add(ScanQr(token: state.token));
}
if (state is QRInvalid) {
Future.delayed(const Duration(seconds: 1), ()async {
Future.delayed(const Duration(seconds: 1), () async {
await player?.play(AssetSource("invalid.mp3"));
});
context.read<PassCheckBloc>().add(ScanQr(token: state.token));
}
if (state is ScanFailed) {
Future.delayed(const Duration(seconds: 1), ()async {
await player?.play(AssetSource("fail.mp3"));
Future.delayed(const Duration(seconds: 1), () async {
await player?.play(AssetSource("fail.mp3"));
});
context.read<PassCheckBloc>().add(ScanQr(token: state.token));
}
if (state is IncomingScanState) {
CoolAlert.show(
barrierDismissible: false,
context: context,
type: CoolAlertType.loading,
text: "Enter Temperature",
widget: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: FormBuilder(
key: formKey,
child: Column(
children: [
const SizedBox(
height: 24,
AwesomeDialog(
dismissOnBackKeyPress: false,
context: context,
dialogType: DialogType.info,
dismissOnTouchOutside: false,
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
child: FormBuilder(
key: formKey,
child: Column(
children: [
const Text("Enter Temperature",style: TextStyle(color: Colors.black),),
const SizedBox(
height: 24,
),
FormBuilderTextField(
keyboardType: TextInputType.number,
name: "temp",
decoration:
normalTextFieldStyle("Temperature", ""),
validator: numericRequired),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.infinity,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
child: const Text(submit),
onPressed: () {
if (formKey.currentState!.saveAndValidate()) {
double temperature = double.parse(
formKey.currentState!.value['temp']);
context.read<PassCheckBloc>().add(
PerformIncomingPostLog(
temp: temperature));
Navigator.of(context).pop();
}
},
),
FormBuilderTextField(
keyboardType: TextInputType.number,
name: "temp",
decoration:
normalTextFieldStyle("Temperature", ""),
validator: numericRequired),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.infinity,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
child: const Text(submit),
onPressed: () {
if (formKey.currentState!.saveAndValidate()) {
double temperature = double.parse(
formKey.currentState!.value['temp']);
context.read<PassCheckBloc>().add(
PerformIncomingPostLog(
temp: temperature));
Navigator.of(context).pop();
}
},
),
)
],
)),
));
)
],
)),
),
).show();
}
if (state is OutGoingScanState) {
CoolAlert.show(
barrierDismissible: false,
context: context,
type: CoolAlertType.loading,
text: "Enter Destination",
widget: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
AwesomeDialog(
dismissOnBackKeyPress: false,
context: context,
dialogType: DialogType.info,
dismissOnTouchOutside: false,
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24,vertical: 24),
child: FormBuilder(
key: formKey,
child: Column(
children: [
const Text("Enter Destination"),
const SizedBox(
height: 24,
),
@ -185,7 +189,8 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
)
],
)),
));
)).show();
}
},
builder: (context, state) {
@ -302,28 +307,56 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
children: [
SelectedState(
//TODO add api data
title: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
title: state.roleIdRoleName.roleName
.toLowerCase() ==
"41" ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'qr code scanner' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'office/branch chief' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'registration in-charge'
? state.assignedArea.stationName
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'barangay chairperson'
? state.assignedArea.brgydesc
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'purok president'
? state.assignedArea.purokdesc
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'establishment point-person'
? "Agency"
: "",
subtitle: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
subtitle: state.roleIdRoleName.roleName
.toLowerCase() ==
"41" ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'qr code scanner' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'office/branch chief' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'registration in-charge'
? "Station"
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'barangay chairperson'
? "Barangay"
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'purok president'
? "Purok"
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
: state.roleIdRoleName.roleName
.toLowerCase() ==
'establishment point-person'
? "Agency"
: "",
),

View File

@ -14,7 +14,7 @@ class AgencyServices {
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientSecret
};
String path = Url.instance.postAgencies();
String path = Url.instance.agencies();
Future<List<Agency>> getAgencies() async {
List<Agency> agencies = [];

View File

@ -111,7 +111,6 @@ class RbacModuleServices {
Future<bool> deleteRbacModule({required int moduleId}) async {
bool success = false;
String path = "${Url.instance.getModules()}$moduleId/";
try {
http.Response response = await Request.instance
.deleteRequest(path: '${path+moduleId.toString()}/', headers: headers, body: {}, param: {});

View File

@ -67,7 +67,6 @@ class RbacRoleExtendServices {
Future<bool> delete({required int roleExtendId}) async {
bool success = false;
String path = "${Url.instance.getRoleExtend()}$roleExtendId/";
try {
http.Response response = await Request.instance.deleteRequest(
path: '${path + roleExtendId.toString()}/',

View File

@ -3,7 +3,8 @@ import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
filter: {"#": RegExp(r'^[0-9][0-9]*$')
},
type: MaskAutoCompletionType.lazy,
initialText: "0");

View File

@ -18,7 +18,7 @@ class Request {
Map<String, String>? param}) async {
Response response;
try {
response = await get(Uri.http(host, path!, param), headers: headers)
response = await get(Uri.https(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
// Fluttertoast.showToast(
@ -60,7 +60,7 @@ class Request {
Map<String, String>? param}) async {
Response response;
try {
response = await post(Uri.http(host, path!, param),
response = await post(Uri.https(host, path!, param),
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
@ -103,7 +103,7 @@ class Request {
required Map<String, dynamic>? param}) async {
Response response;
try {
response = await put(Uri.http(host, path, param),
response = await put(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body));
} on TimeoutException catch (_) {
// Fluttertoast.showToast(
@ -187,7 +187,7 @@ class Request {
required Map<String, dynamic>? param}) async {
Response response;
try {
response = await delete(Uri.http(host, path, param),
response = await delete(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {

View File

@ -5,8 +5,8 @@ class Url {
String host() {
// return '192.168.10.183:3000';
// return 'agusandelnorte.gov.ph';
return "192.168.10.219:3000";
return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000";
// return "192.168.10.241";
// return "192.168.10.221:3004";
// return "playweb.agusandelnorte.gov.ph";
@ -15,8 +15,8 @@ class Url {
}
String prefixHost() {
// return "https";
return "http";
return "https";
// return "http";
}
String authentication() {