add search functions to superadmin screens
parent
ba89592496
commit
deeca18962
|
@ -51,10 +51,13 @@ class LearningDevelopmentBloc
|
|||
attachmentCategories =
|
||||
await AttachmentServices.instance.getCategories();
|
||||
}
|
||||
if(learningsAndDevelopments.isEmpty){
|
||||
List<LearningDevelopement> learnings = await LearningDevelopmentServices
|
||||
.instance
|
||||
.getLearningDevelopments(event.profileId, event.token);
|
||||
learningsAndDevelopments = learnings;
|
||||
}
|
||||
|
||||
emit(LearningDevelopmentLoadedState(
|
||||
learningsAndDevelopment: learningsAndDevelopments,attachmentCategory: attachmentCategories));
|
||||
} catch (e) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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});
|
||||
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -25,7 +25,8 @@ class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
|
|||
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()));
|
||||
}
|
||||
|
@ -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);
|
||||
if (!ids.contains(newRoleModule.id)) {
|
||||
roleModules.add(newRoleModule);
|
||||
}
|
||||
emit(RoleModuleAddedState(response: statusResponse));
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
if (!ids.contains(newRoleUnder.id)) {
|
||||
rolesUnder.add(newRoleUnder);
|
||||
emit(RoleUnderAddedState(response: statusResponse));
|
||||
}
|
||||
});
|
||||
emit(RoleUnderAddedState(response: statusResponse));
|
||||
} else {
|
||||
emit(RoleUnderAddedState(response: statusResponse));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,15 +48,27 @@ 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(
|
||||
return WillPopScope(
|
||||
onWillPop: () async{
|
||||
setState(() {
|
||||
|
||||
});
|
||||
return true;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primary,
|
||||
centerTitle: true,
|
||||
|
@ -71,11 +83,12 @@ class ProfileInfo extends StatelessWidget {
|
|||
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!;
|
||||
}
|
||||
print(profile.lastName);
|
||||
return BlocConsumer<ProfileBloc, ProfileState>(
|
||||
listener: (
|
||||
context,
|
||||
|
@ -186,6 +199,10 @@ class ProfileInfo extends StatelessWidget {
|
|||
.basicInfo
|
||||
.citizenships)),
|
||||
child: CitizenShipScreen(
|
||||
citizenships: state
|
||||
.profileInformation
|
||||
.basicInfo
|
||||
.citizenships,
|
||||
profileId: profileId!, token: token!),
|
||||
);
|
||||
}));
|
||||
|
@ -402,6 +419,7 @@ class ProfileInfo extends StatelessWidget {
|
|||
}
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,12 +25,206 @@ 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: [
|
||||
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(
|
||||
|
@ -53,17 +249,20 @@ class RbacModuleScreen extends StatelessWidget {
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "slug",
|
||||
decoration: normalTextFieldStyle("Slug ", "Slug"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Slug ", "Slug"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.maxLength(50,
|
||||
errorText: "Max characters only 50"),
|
||||
validator:
|
||||
FormBuilderValidators.maxLength(50,
|
||||
errorText:
|
||||
"Max characters only 50"),
|
||||
name: "shorthand",
|
||||
decoration:
|
||||
normalTextFieldStyle("Shorthand ", "Shorthand"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Shorthand ", "Shorthand"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -72,17 +271,20 @@ class RbacModuleScreen extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
String name = formKey
|
||||
.currentState!.value['object_name'];
|
||||
String? slug =
|
||||
formKey.currentState!.value['slug'];
|
||||
.currentState!
|
||||
.value['object_name'];
|
||||
String? slug = formKey
|
||||
.currentState!
|
||||
.value['slug'];
|
||||
String? short = formKey
|
||||
.currentState!.value['shorthand'];
|
||||
.currentState!
|
||||
.value['shorthand'];
|
||||
parent.read<ModuleBloc>().add(
|
||||
AddRbacModule(
|
||||
id: id,
|
||||
|
@ -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),
|
||||
|
@ -191,8 +394,12 @@ class RbacModuleScreen extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(child: Text('${index+1}'),),
|
||||
const SizedBox(width: 12,),
|
||||
CircleAvatar(
|
||||
child: Text('${index + 1}'),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(state.module[index].name!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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,16 +32,25 @@ 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: [
|
||||
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,
|
||||
context:
|
||||
NavigationService.navigatorKey.currentState!.context,
|
||||
builder: (BuildContext context) {
|
||||
valueItemObjects = objects.map((e) {
|
||||
return ValueItem(label: e.name!, value: e.name);
|
||||
|
@ -58,8 +66,8 @@ class RbacModuleObjectsScreen extends StatelessWidget {
|
|||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "module",
|
||||
decoration:
|
||||
normalTextFieldStyle("Module", "Module"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Module", "Module"),
|
||||
items: modules.isEmpty
|
||||
? []
|
||||
: modules.map((e) {
|
||||
|
@ -76,7 +84,8 @@ class RbacModuleObjectsScreen extends StatelessWidget {
|
|||
MultiSelectDropDown(
|
||||
onOptionSelected:
|
||||
(List<ValueItem> selectedOptions) {
|
||||
selectedValueItemObjects = selectedOptions;
|
||||
selectedValueItemObjects =
|
||||
selectedOptions;
|
||||
},
|
||||
borderColor: Colors.grey,
|
||||
borderWidth: 1,
|
||||
|
@ -85,10 +94,11 @@ class RbacModuleObjectsScreen extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(8),
|
||||
options: valueItemObjects,
|
||||
selectionType: SelectionType.multi,
|
||||
chipConfig:
|
||||
const ChipConfig(wrapType: WrapType.wrap),
|
||||
chipConfig: const ChipConfig(
|
||||
wrapType: WrapType.wrap),
|
||||
dropdownHeight: 300,
|
||||
optionTextStyle: const TextStyle(fontSize: 16),
|
||||
optionTextStyle:
|
||||
const TextStyle(fontSize: 16),
|
||||
selectedOptionIcon:
|
||||
const Icon(Icons.check_circle),
|
||||
),
|
||||
|
@ -99,27 +109,31 @@ class RbacModuleObjectsScreen extends StatelessWidget {
|
|||
height: 50,
|
||||
width: double.maxFinite,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate() &&
|
||||
selectedValueItemObjects.isNotEmpty) {
|
||||
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()) {
|
||||
if (element.label
|
||||
.toLowerCase() ==
|
||||
object.name
|
||||
?.toLowerCase()) {
|
||||
objectId.add(object.id!);
|
||||
}
|
||||
});
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
parent.read<ModuleObjectsBloc>().add(
|
||||
AddRbacModuleObjects(
|
||||
parent
|
||||
.read<ModuleObjectsBloc>()
|
||||
.add(AddRbacModuleObjects(
|
||||
assignerId: assignerId,
|
||||
moduleId: moduleId,
|
||||
objectsId: objectId));
|
||||
|
@ -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,19 +283,22 @@ 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: () {
|
||||
message: state.message,
|
||||
onpressed: () {
|
||||
parent.read<ModuleObjectsBloc>().add(GetModuleObjects());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,12 +26,197 @@ 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: [
|
||||
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(
|
||||
|
@ -54,17 +241,20 @@ class RbacObjectScreen extends StatelessWidget {
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "slug",
|
||||
decoration: normalTextFieldStyle("Slug ", "Slug"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Slug ", "Slug"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.maxLength(50,
|
||||
errorText: "Max characters only 50"),
|
||||
validator:
|
||||
FormBuilderValidators.maxLength(50,
|
||||
errorText:
|
||||
"Max characters only 50"),
|
||||
name: "shorthand",
|
||||
decoration:
|
||||
normalTextFieldStyle("Shorthand ", "Shorthand"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Shorthand ", "Shorthand"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -73,17 +263,20 @@ class RbacObjectScreen extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
String name = formKey
|
||||
.currentState!.value['object_name'];
|
||||
String? slug =
|
||||
formKey.currentState!.value['slug'];
|
||||
.currentState!
|
||||
.value['object_name'];
|
||||
String? slug = formKey
|
||||
.currentState!
|
||||
.value['slug'];
|
||||
String? short = formKey
|
||||
.currentState!.value['shorthand'];
|
||||
.currentState!
|
||||
.value['shorthand'];
|
||||
parent.read<ObjectBloc>().add(
|
||||
AddRbacObject(
|
||||
id: id,
|
||||
|
@ -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),
|
||||
|
|
|
@ -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,11 +26,203 @@ 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: [
|
||||
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(
|
||||
|
@ -53,7 +247,8 @@ class RbacOperationScreen extends StatelessWidget {
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "slug",
|
||||
decoration: normalTextFieldStyle("Slug ", "Slug"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Slug ", "Slug"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
|
@ -62,8 +257,8 @@ class RbacOperationScreen extends StatelessWidget {
|
|||
validator: FormBuilderValidators.maxLength(50,
|
||||
errorText: "Max characters only 50"),
|
||||
name: "shorthand",
|
||||
decoration:
|
||||
normalTextFieldStyle("Shorthand ", "Shorthand"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Shorthand ", "Shorthand"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -72,17 +267,18 @@ class RbacOperationScreen extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
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 name = formKey.currentState!
|
||||
.value['object_name'];
|
||||
String? slug = formKey
|
||||
.currentState!.value['slug'];
|
||||
String? short = formKey
|
||||
.currentState!.value['shorthand'];
|
||||
.currentState!
|
||||
.value['shorthand'];
|
||||
parent.read<OperationBloc>().add(
|
||||
AddRbacOperation(
|
||||
id: id,
|
||||
|
@ -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),
|
||||
|
@ -191,8 +388,12 @@ class RbacOperationScreen extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(child: Text('${index+1}'),),
|
||||
const SizedBox(width: 12,),
|
||||
CircleAvatar(
|
||||
child: Text('${index + 1}'),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(state.operations[index].name!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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,10 +43,92 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
title: const Text("Permissions Screen"),
|
||||
actions: [
|
||||
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 :("),
|
||||
),
|
||||
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,
|
||||
context:
|
||||
NavigationService.navigatorKey.currentState!.context,
|
||||
builder: (BuildContext context) {
|
||||
valueItemOperations = operations.map((e) {
|
||||
return ValueItem(label: e.name!, value: e.name);
|
||||
|
@ -58,8 +144,8 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "object",
|
||||
decoration:
|
||||
normalTextFieldStyle("Permission", "Permission"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Permission", "Permission"),
|
||||
items: objects.isEmpty
|
||||
? []
|
||||
: objects.map((e) {
|
||||
|
@ -76,7 +162,8 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
MultiSelectDropDown(
|
||||
onOptionSelected:
|
||||
(List<ValueItem> selectedOptions) {
|
||||
selectedValueItemOperations = selectedOptions;
|
||||
selectedValueItemOperations =
|
||||
selectedOptions;
|
||||
},
|
||||
borderColor: Colors.grey,
|
||||
borderWidth: 1,
|
||||
|
@ -85,10 +172,11 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(8),
|
||||
options: valueItemOperations,
|
||||
selectionType: SelectionType.multi,
|
||||
chipConfig:
|
||||
const ChipConfig(wrapType: WrapType.wrap),
|
||||
chipConfig: const ChipConfig(
|
||||
wrapType: WrapType.wrap),
|
||||
dropdownHeight: 300,
|
||||
optionTextStyle: const TextStyle(fontSize: 16),
|
||||
optionTextStyle:
|
||||
const TextStyle(fontSize: 16),
|
||||
selectedOptionIcon:
|
||||
const Icon(Icons.check_circle),
|
||||
),
|
||||
|
@ -99,8 +187,8 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
height: 50,
|
||||
width: double.maxFinite,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate() &&
|
||||
|
@ -113,8 +201,10 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
for (var operation in operations) {
|
||||
selectedValueItemOperations
|
||||
.forEach((element) {
|
||||
if (element.label.toLowerCase() ==
|
||||
operation.name?.toLowerCase()) {
|
||||
if (element.label
|
||||
.toLowerCase() ==
|
||||
operation.name
|
||||
?.toLowerCase()) {
|
||||
opIds.add(operation.id!);
|
||||
}
|
||||
});
|
||||
|
@ -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),
|
||||
|
@ -233,17 +324,15 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
elevation: 3,
|
||||
onSelected: (value) {
|
||||
if (value == 1) {
|
||||
|
||||
confirmAlert(context, () {
|
||||
context.read<PermissionBloc>().add(
|
||||
DeleteRbacPermission(
|
||||
permissionId: state.permissions[index].id!));
|
||||
permissionId: state
|
||||
.permissions[index].id!));
|
||||
}, "Delete?", "Confirm Delete?");
|
||||
|
||||
}
|
||||
},
|
||||
menuItems: [
|
||||
|
||||
popMenuItem(
|
||||
text: "Remove",
|
||||
value: 1,
|
||||
|
@ -271,7 +360,8 @@ class RbacPermissionScreen extends StatelessWidget {
|
|||
}
|
||||
if (state is PermissionErrorState) {
|
||||
return SomethingWentWrong(
|
||||
message: state.message, onpressed: () {
|
||||
message: state.message,
|
||||
onpressed: () {
|
||||
parent!.read<PermissionBloc>().add(GetPermissions());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,7 +37,16 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
title: const Text("Permission Assignment"),
|
||||
actions: [
|
||||
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,
|
||||
|
@ -61,7 +67,8 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "role",
|
||||
decoration: normalTextFieldStyle("Role", "Role"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Role", "Role"),
|
||||
items: roles.isEmpty
|
||||
? []
|
||||
: roles.map((e) {
|
||||
|
@ -76,8 +83,10 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
height: 12,
|
||||
),
|
||||
MultiSelectDropDown(
|
||||
onOptionSelected: (List<ValueItem> selectedOptions) {
|
||||
selectedValueItemPermission = selectedOptions;
|
||||
onOptionSelected:
|
||||
(List<ValueItem> selectedOptions) {
|
||||
selectedValueItemPermission =
|
||||
selectedOptions;
|
||||
},
|
||||
borderColor: Colors.grey,
|
||||
borderWidth: 1,
|
||||
|
@ -86,10 +95,13 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(8),
|
||||
options: valueItemPermission,
|
||||
selectionType: SelectionType.multi,
|
||||
chipConfig: const ChipConfig(wrapType: WrapType.wrap),
|
||||
chipConfig: const ChipConfig(
|
||||
wrapType: WrapType.wrap),
|
||||
dropdownHeight: 300,
|
||||
optionTextStyle: const TextStyle(fontSize: 16),
|
||||
selectedOptionIcon: const Icon(Icons.check_circle),
|
||||
optionTextStyle:
|
||||
const TextStyle(fontSize: 16),
|
||||
selectedOptionIcon:
|
||||
const Icon(Icons.check_circle),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -98,20 +110,25 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
height: 50,
|
||||
width: double.maxFinite,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!.saveAndValidate() &&
|
||||
selectedValueItemPermission.isNotEmpty) {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate() &&
|
||||
selectedValueItemPermission
|
||||
.isNotEmpty) {
|
||||
int assignerId = id;
|
||||
int roleId = selectedRole!.id!;
|
||||
List<int> opIds =
|
||||
selectedValueItemPermission.map((e) {
|
||||
selectedValueItemPermission
|
||||
.map((e) {
|
||||
return int.parse(e.value!);
|
||||
}).toList();
|
||||
Navigator.pop(context);
|
||||
parent.read<PermissionAssignmentBloc>().add(
|
||||
AddPersmissionAssignment(
|
||||
parent
|
||||
.read<
|
||||
PermissionAssignmentBloc>()
|
||||
.add(AddPersmissionAssignment(
|
||||
assignerId: assignerId,
|
||||
opsId: opIds,
|
||||
roleId: roleId));
|
||||
|
@ -183,7 +200,6 @@ class RbacPermissionAssignmentScreen extends StatelessWidget {
|
|||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
|
||||
if (state is PermissionAssignmentLoadedState) {
|
||||
if (state.permissionAssignments.isNotEmpty) {
|
||||
permissions = state.permissions;
|
||||
|
|
|
@ -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,16 +33,181 @@ class RbacRoleScreen extends StatelessWidget {
|
|||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
title: const Text("Role Screen"),
|
||||
actions: [
|
||||
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: primary),
|
||||
barTheme: ThemeData(cardColor: Colors.white),
|
||||
builder: (RBAC rbac) {
|
||||
return ListTile(
|
||||
title: Text(rbac.name!),
|
||||
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) {
|
||||
|
@ -82,17 +248,20 @@ class RbacRoleScreen extends StatelessWidget {
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "slug",
|
||||
decoration: normalTextFieldStyle("Slug ", "Slug"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Slug ", "Slug"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
FormBuilderTextField(
|
||||
validator: FormBuilderValidators.maxLength(50,
|
||||
errorText: "Max characters only 50"),
|
||||
validator:
|
||||
FormBuilderValidators.maxLength(50,
|
||||
errorText:
|
||||
"Max characters only 50"),
|
||||
name: "shorthand",
|
||||
decoration:
|
||||
normalTextFieldStyle("Shorthand ", "Shorthand"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Shorthand ", "Shorthand"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -101,18 +270,22 @@ class RbacRoleScreen extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate()) {
|
||||
String name = formKey
|
||||
.currentState!.value['object_name'];
|
||||
String? slug =
|
||||
formKey.currentState!.value['slug'];
|
||||
.currentState!
|
||||
.value['object_name'];
|
||||
String? slug = formKey
|
||||
.currentState!
|
||||
.value['slug'];
|
||||
String? short = formKey
|
||||
.currentState!.value['shorthand'];
|
||||
parent.read<RoleBloc>().add(AddRbacRole(
|
||||
.currentState!
|
||||
.value['shorthand'];
|
||||
parent.read<RoleBloc>().add(
|
||||
AddRbacRole(
|
||||
id: id,
|
||||
name: name,
|
||||
shorthand: short,
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -34,11 +34,19 @@ class RbacRoleModuleScreen extends StatelessWidget {
|
|||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primary,
|
||||
title: const Text("Role Modules Screen"),
|
||||
actions: [
|
||||
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,
|
||||
context:
|
||||
NavigationService.navigatorKey.currentState!.context,
|
||||
builder: (BuildContext context) {
|
||||
valueItemModules = modules.map((e) {
|
||||
return ValueItem(label: e.name!, value: e.name);
|
||||
|
@ -54,7 +62,8 @@ class RbacRoleModuleScreen extends StatelessWidget {
|
|||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "role",
|
||||
decoration: normalTextFieldStyle("Role", "Role"),
|
||||
decoration:
|
||||
normalTextFieldStyle("Role", "Role"),
|
||||
items: roles.isEmpty
|
||||
? []
|
||||
: roles.map((e) {
|
||||
|
@ -71,7 +80,8 @@ class RbacRoleModuleScreen extends StatelessWidget {
|
|||
MultiSelectDropDown(
|
||||
onOptionSelected:
|
||||
(List<ValueItem> selectedOptions) {
|
||||
selectedValueItemModules = selectedOptions;
|
||||
selectedValueItemModules =
|
||||
selectedOptions;
|
||||
},
|
||||
borderColor: Colors.grey,
|
||||
borderWidth: 1,
|
||||
|
@ -80,10 +90,11 @@ class RbacRoleModuleScreen extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(8),
|
||||
options: valueItemModules,
|
||||
selectionType: SelectionType.multi,
|
||||
chipConfig:
|
||||
const ChipConfig(wrapType: WrapType.wrap),
|
||||
chipConfig: const ChipConfig(
|
||||
wrapType: WrapType.wrap),
|
||||
dropdownHeight: 300,
|
||||
optionTextStyle: const TextStyle(fontSize: 16),
|
||||
optionTextStyle:
|
||||
const TextStyle(fontSize: 16),
|
||||
selectedOptionIcon:
|
||||
const Icon(Icons.check_circle),
|
||||
),
|
||||
|
@ -94,20 +105,23 @@ class RbacRoleModuleScreen extends StatelessWidget {
|
|||
height: 50,
|
||||
width: double.maxFinite,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!
|
||||
.saveAndValidate() &&
|
||||
selectedValueItemModules.isNotEmpty) {
|
||||
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()) {
|
||||
if (element.label
|
||||
.toLowerCase() ==
|
||||
module.name
|
||||
?.toLowerCase()) {
|
||||
modulesId.add(module.id!);
|
||||
}
|
||||
});
|
||||
|
@ -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,19 +272,21 @@ 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: () {
|
||||
message: state.message,
|
||||
onpressed: () {
|
||||
context.read<RoleModuleBloc>().add(GetRoleModules());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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});
|
||||
}
|
|
@ -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});
|
||||
}
|
|
@ -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,7 +61,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
title: const Text("Station Screen"),
|
||||
actions: [
|
||||
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 = [];
|
||||
|
@ -82,7 +86,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
content: SingleChildScrollView(
|
||||
child: FormBuilder(
|
||||
key: formKey,
|
||||
child: StatefulBuilder(builder: (context, setState) {
|
||||
child:
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
@ -119,7 +124,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
: mainParentStations.map((e) {
|
||||
return DropdownMenuItem(
|
||||
value: e,
|
||||
child: Text(e.stationName!),
|
||||
child: Text(
|
||||
e.stationName!),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (RbacStation? e) {
|
||||
|
@ -128,18 +134,20 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
parentStations = [];
|
||||
for (RbacStation station
|
||||
in stations) {
|
||||
if (station.mainParentStation ==
|
||||
if (station
|
||||
.mainParentStation ==
|
||||
selectedMainParentStation!
|
||||
.id) {
|
||||
parentStations.add(station);
|
||||
parentStations
|
||||
.add(station);
|
||||
}
|
||||
}
|
||||
parentStations.add(
|
||||
selectedMainParentStation!);
|
||||
});
|
||||
},
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
),
|
||||
|
@ -153,7 +161,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
? const SizedBox.shrink()
|
||||
: FormBuilderDropdown<RbacStation>(
|
||||
decoration: normalTextFieldStyle(
|
||||
"Parent Station", "Parent Station"),
|
||||
"Parent Station",
|
||||
"Parent Station"),
|
||||
name: "parent-stations",
|
||||
onChanged: (RbacStation? e) {
|
||||
setState(() {
|
||||
|
@ -165,11 +174,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
: parentStations.map((e) {
|
||||
return DropdownMenuItem(
|
||||
value: e,
|
||||
child: Text(e.stationName!),
|
||||
child: Text(
|
||||
e.stationName!),
|
||||
);
|
||||
}).toList(),
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This field is required"),
|
||||
),
|
||||
|
@ -180,21 +190,22 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
////Station Type
|
||||
SearchField(
|
||||
itemHeight: 50,
|
||||
suggestionsDecoration: searchFieldDecoration(),
|
||||
|
||||
suggestionsDecoration:
|
||||
searchFieldDecoration(),
|
||||
suggestions: stationTypes
|
||||
.map((StationType stationType) =>
|
||||
SearchFieldListItem(
|
||||
stationType.typeName!,
|
||||
item: stationType,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal: 10),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
stationType.typeName!,
|
||||
overflow: TextOverflow.visible,
|
||||
overflow:
|
||||
TextOverflow.visible,
|
||||
)),
|
||||
)))
|
||||
.toList(),
|
||||
|
@ -206,11 +217,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
},
|
||||
focusNode: stationTypeFocusNode,
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle("Station Type *", "")
|
||||
normalTextFieldStyle(
|
||||
"Station Type *", "")
|
||||
.copyWith(
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () => stationTypeFocusNode.unfocus(),
|
||||
child: const Icon(Icons.arrow_drop_down),
|
||||
onTap: () =>
|
||||
stationTypeFocusNode.unfocus(),
|
||||
child:
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
)),
|
||||
onSuggestionTap: (position) {
|
||||
setState(() {
|
||||
|
@ -223,10 +237,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
controller: addStationTypeController,
|
||||
onpressed: () {
|
||||
setState(() {
|
||||
StationType stationType = StationType(
|
||||
StationType stationType =
|
||||
StationType(
|
||||
id: null,
|
||||
typeName:
|
||||
addStationTypeController.text,
|
||||
addStationTypeController
|
||||
.text,
|
||||
color: null,
|
||||
order: null,
|
||||
isActive: null,
|
||||
|
@ -270,7 +286,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
"Location of the station within this parent?",
|
||||
'Location of the station within this parent?'),
|
||||
name: 'isWithinParent',
|
||||
title: Text(isWithinParent ? "YES" : "NO"),
|
||||
title:
|
||||
Text(isWithinParent ? "YES" : "NO"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -280,12 +297,13 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
children: [
|
||||
Flexible(
|
||||
child: FormBuilderTextField(
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This Field is required"),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Station name", "Station name"),
|
||||
"Station name",
|
||||
"Station name"),
|
||||
name: "station-name"),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -294,8 +312,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
//// Acronym
|
||||
Flexible(
|
||||
child: FormBuilderTextField(
|
||||
validator:
|
||||
FormBuilderValidators.required(
|
||||
validator: FormBuilderValidators
|
||||
.required(
|
||||
errorText:
|
||||
"This Field is required"),
|
||||
decoration: normalTextFieldStyle(
|
||||
|
@ -349,10 +367,11 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
isHospital = !isHospital;
|
||||
});
|
||||
},
|
||||
decoration:
|
||||
normalTextFieldStyle("Is Hospital", ''),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Is Hospital", ''),
|
||||
name: 'isHospital',
|
||||
title: Text(isHospital == true ? "YES" : "NO"),
|
||||
title: Text(
|
||||
isHospital == true ? "YES" : "NO"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
|
@ -361,8 +380,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(primary,
|
||||
Colors.transparent, second),
|
||||
onPressed: () {
|
||||
RbacStation? newStation;
|
||||
if (formKey.currentState!
|
||||
|
@ -371,25 +390,30 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
.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'];
|
||||
.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,
|
||||
stationType:
|
||||
selectedStationType,
|
||||
hierarchyOrderNo: mainParent
|
||||
? 1
|
||||
: selectedParentStation!
|
||||
.hierarchyOrderNo! +
|
||||
1,
|
||||
headPosition:
|
||||
selectedPositiontitle?.title,
|
||||
selectedPositiontitle
|
||||
?.title,
|
||||
governmentAgency:
|
||||
GovernmentAgency(
|
||||
agencyid:
|
||||
|
@ -397,11 +421,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
agencyname: null,
|
||||
agencycatid: null,
|
||||
privateEntity: null,
|
||||
contactinfoid: null),
|
||||
contactinfoid:
|
||||
null),
|
||||
acronym: acronym,
|
||||
parentStation: mainParent
|
||||
parentStation:
|
||||
mainParent
|
||||
? null
|
||||
: selectedParentStation!.id!,
|
||||
: selectedParentStation!
|
||||
.id!,
|
||||
code: code,
|
||||
fullcode: fullcode,
|
||||
childStationInfo: null,
|
||||
|
@ -416,7 +443,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
isactive: true,
|
||||
sellingStation: null);
|
||||
Navigator.pop(context);
|
||||
rbacStationBloc.add(AddRbacStation(
|
||||
rbacStationBloc.add(
|
||||
AddRbacStation(
|
||||
station: newStation));
|
||||
}
|
||||
},
|
||||
|
@ -445,7 +473,9 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SearchField(
|
||||
inputFormatters: [UpperCaseTextFormatter()],
|
||||
inputFormatters: [
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
itemHeight: 100,
|
||||
focusNode: agencyFocusNode,
|
||||
suggestions: agencies
|
||||
|
@ -455,12 +485,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
child: ListTile(
|
||||
title: Text(
|
||||
agency.name!,
|
||||
overflow: TextOverflow.visible,
|
||||
overflow:
|
||||
TextOverflow.visible,
|
||||
),
|
||||
)))
|
||||
.toList(),
|
||||
searchInputDecoration:
|
||||
normalTextFieldStyle("Filter", "").copyWith(
|
||||
normalTextFieldStyle("Filter", "")
|
||||
.copyWith(
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
onPressed: () {
|
||||
|
@ -652,7 +684,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
|
|||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(
|
||||
const EdgeInsets
|
||||
.all(
|
||||
6),
|
||||
child:
|
||||
Text(
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,36 +74,37 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
|
|||
progress!.dismiss();
|
||||
}
|
||||
if (state is ScanSuccess) {
|
||||
Future.delayed(const Duration(seconds: 1), () async{
|
||||
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 {
|
||||
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,
|
||||
AwesomeDialog(
|
||||
dismissOnBackKeyPress: false,
|
||||
context: context,
|
||||
type: CoolAlertType.loading,
|
||||
text: "Enter Temperature",
|
||||
widget: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
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,
|
||||
),
|
||||
|
@ -136,20 +138,22 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
|
|||
)
|
||||
],
|
||||
)),
|
||||
));
|
||||
),
|
||||
).show();
|
||||
}
|
||||
if (state is OutGoingScanState) {
|
||||
CoolAlert.show(
|
||||
barrierDismissible: false,
|
||||
AwesomeDialog(
|
||||
dismissOnBackKeyPress: false,
|
||||
context: context,
|
||||
type: CoolAlertType.loading,
|
||||
text: "Enter Destination",
|
||||
widget: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
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"
|
||||
: "",
|
||||
),
|
||||
|
|
|
@ -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 = [];
|
||||
|
|
|
@ -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: {});
|
||||
|
|
|
@ -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()}/',
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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 (_) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue