tested profile screen

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-08-20 17:36:16 +08:00
parent 14dd524c71
commit 7cc0ab1f56
47 changed files with 1307 additions and 276 deletions

View File

@ -49,27 +49,6 @@ class OrganizationMembershipBloc
agencies: agencies, agencies: agencies,
agencyCategory: agencyCategory)); agencyCategory: agencyCategory));
}); });
////SHOW ADD ORG MEMBERSHIP FORM
on<ShowAddOrgMembershipForm>((event, emit) async {
emit(OrgmembershipLoadingState());
try {
if (agencies.isEmpty) {
List<Agency> newAgencies =
await ProfileUtilities.instance.getAgecies();
agencies = newAgencies;
}
if (agencyCategory.isEmpty) {
List<Category> newAgencyCategories =
await ProfileUtilities.instance.agencyCategory();
agencyCategory = newAgencyCategories;
}
emit(AddOrgMembershipState(
agencies: agencies, agencyCategories: agencyCategory));
} catch (e) {
emit(OrganizationMembershipErrorState(message: e.toString()));
}
});
//// ADD ORGMEMBERSHIP //// ADD ORGMEMBERSHIP
on<AddOrgMembership>((event, emit) async { on<AddOrgMembership>((event, emit) async {
try { try {

View File

@ -1,9 +1,7 @@
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/model/location/barangay.dart'; import 'package:unit2/model/location/barangay.dart';
import 'package:unit2/model/location/subdivision.dart'; import 'package:unit2/model/location/subdivision.dart';
import 'package:unit2/model/profile/voluntary_works.dart';
import 'package:unit2/sevices/profile/address_service.dart'; import 'package:unit2/sevices/profile/address_service.dart';
import '../../../../model/location/city.dart'; import '../../../../model/location/city.dart';

View File

@ -17,16 +17,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
List<ProfileOtherInfo> indigencies = []; List<ProfileOtherInfo> indigencies = [];
List<ProfileOtherInfo> disabilities = []; List<ProfileOtherInfo> disabilities = [];
List<ProfileOtherInfo> genders = []; List<ProfileOtherInfo> genders = [];
List<String> bloodType = [ List<String> bloodType = ["A+", "B+", "A-", "B-", "AB+", "AB-", "O+", "O-"];
"A+",
"B+",
"A-",
"B-",
"AB+",
"AB-",
"O+",
"O-"
];
List<String> nameExtensions = [ List<String> nameExtensions = [
"NONE", "NONE",
"N/A", "N/A",
@ -56,9 +47,12 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
on<LoadProfile>((event, emit) async { on<LoadProfile>((event, emit) async {
emit(ProfileLoading()); emit(ProfileLoading());
try { try {
ProfileInformation? profileInformation = if (globalProfileInformation == null) {
await ProfileService.instance.getProfile(event.token, event.userID); ProfileInformation? profileInformation = await ProfileService.instance
.getProfile(event.token, event.userID);
globalProfileInformation = profileInformation; globalProfileInformation = profileInformation;
}
emit(ProfileLoaded(profileInformation: globalProfileInformation!)); emit(ProfileLoaded(profileInformation: globalProfileInformation!));
} catch (e) { } catch (e) {
emit(ProfileErrorState(mesage: e.toString())); emit(ProfileErrorState(mesage: e.toString()));
@ -79,22 +73,34 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
if (religions.isEmpty) { if (religions.isEmpty) {
religions = await ProfileOtherInfoServices.instace religions = await ProfileOtherInfoServices.instace
.getReligions(token: event.token); .getReligions(token: event.token);
religions.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
if (genders.isEmpty) { if (genders.isEmpty) {
genders = await ProfileOtherInfoServices.instace genders = await ProfileOtherInfoServices.instace
.getGenders(token: event.token); .getGenders(token: event.token);
genders.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
if (ethnicities.isEmpty) { if (ethnicities.isEmpty) {
ethnicities = await ProfileOtherInfoServices.instace ethnicities = await ProfileOtherInfoServices.instace
.getEthnicity(token: event.token); .getEthnicity(token: event.token);
ethnicities.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
if (disabilities.isEmpty) { if (disabilities.isEmpty) {
disabilities = await ProfileOtherInfoServices.instace disabilities = await ProfileOtherInfoServices.instace
.getDisability(token: event.token); .getDisability(token: event.token);
disabilities.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
if (indigencies.isEmpty) { if (indigencies.isEmpty) {
indigencies = await ProfileOtherInfoServices.instace indigencies = await ProfileOtherInfoServices.instace
.getIndigency(token: event.token); .getIndigency(token: event.token);
indigencies.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
emit(BasicInformationEditingState( emit(BasicInformationEditingState(
primaryInformation: currentProfileInformation!, primaryInformation: currentProfileInformation!,

View File

@ -3,7 +3,6 @@ import 'package:equatable/equatable.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/sevices/profile/volunatary_services.dart'; import 'package:unit2/sevices/profile/volunatary_services.dart';
import 'package:unit2/utils/profile_utilities.dart'; import 'package:unit2/utils/profile_utilities.dart';
import '../../../model/location/city.dart'; import '../../../model/location/city.dart';
import '../../../model/location/country.dart'; import '../../../model/location/country.dart';
import '../../../model/location/provinces.dart'; import '../../../model/location/provinces.dart';
@ -13,7 +12,6 @@ import '../../../model/utils/agency.dart';
import '../../../model/utils/category.dart'; import '../../../model/utils/category.dart';
import '../../../model/utils/position.dart'; import '../../../model/utils/position.dart';
import '../../../utils/location_utilities.dart'; import '../../../utils/location_utilities.dart';
part 'voluntary_work_event.dart'; part 'voluntary_work_event.dart';
part 'voluntary_work_state.dart'; part 'voluntary_work_state.dart';

View File

@ -1,17 +1,14 @@
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/model/profile/work_history.dart';
import 'package:unit2/model/utils/agency.dart'; import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/model/utils/agency_position.dart'; import 'package:unit2/model/utils/agency_position.dart';
import 'package:unit2/model/utils/position.dart'; import 'package:unit2/model/utils/position.dart';
import 'package:unit2/sevices/profile/work_history_services.dart'; import 'package:unit2/sevices/profile/work_history_services.dart';
import 'package:unit2/utils/profile_utilities.dart'; import 'package:unit2/utils/profile_utilities.dart';
import '../../../model/profile/attachment.dart'; import '../../../model/profile/attachment.dart';
import '../../../model/utils/category.dart'; import '../../../model/utils/category.dart';
import '../../../utils/attachment_services.dart'; import '../../../utils/attachment_services.dart';
part 'workHistory_event.dart'; part 'workHistory_event.dart';
part 'workHistory_state.dart'; part 'workHistory_state.dart';

View File

@ -1,9 +1,7 @@
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
import 'package:unit2/model/rbac/role_extend.dart'; import 'package:unit2/model/rbac/role_extend.dart';
import 'package:unit2/sevices/roles/rbac_operations/role_extend_services.dart'; import 'package:unit2/sevices/roles/rbac_operations/role_extend_services.dart';
import '../../../../model/rbac/rbac.dart'; import '../../../../model/rbac/rbac.dart';
import '../../../../sevices/roles/rbac_operations/role_services.dart'; import '../../../../sevices/roles/rbac_operations/role_services.dart';

View File

@ -0,0 +1,79 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/model/rbac/role_under.dart';
import '../../../../../sevices/roles/est_point_person/est_point_person_role_assignment_services.dart';
import '../../../../../sevices/roles/rbac_operations/role_services.dart';
import '../../../../../sevices/roles/rbac_operations/roles_under_services.dart';
part 'est_point_person_assinable_role_event.dart';
part 'est_point_person_assinable_role_state.dart';
class EstPointPersonAssinableRoleBloc extends Bloc<
EstPointPersonAssinableRoleEvent, EstPointPersonAssinableRoleState> {
EstPointPersonAssinableRoleBloc()
: super(EstPointPersonAssinableRoleInitial()) {
List<RBAC> rolesUnder = [];
List<RBAC> roles = [];
RBAC? mainRole;
on<GetEstPointPersonAssignableRoles>((event, emit) async {
emit(EstPointPersonAssignableRoleLoadingState());
try {
if (rolesUnder.isEmpty) {
List<RolesUnder> rolesUnders = await EstPointPersonRoleAssignment
.instance
.getRolesUnder(roleId: event.roleId);
for (var roleUnder in rolesUnders) {
RBAC roleChild = roleUnder.roleUnderChild;
roleChild.id = roleUnder.id;
rolesUnder.add(roleUnder.roleUnderChild);
}
}
if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles();
}
RBAC role = roles.firstWhere((e) => e.id == event.roleId);
mainRole = role;
emit(EstPointPersonAssignableRoleLoaded(
roles: roles, rolesUnder: rolesUnder, mainRole: role));
} catch (e) {
emit(EstPointPersonAssignableErrorState(message: e.toString()));
}
});
on<AddEstPointPersonAssignableRoles>((event, emit) async {
try {
emit(EstPointPersonAssignableRoleLoadingState());
Map<dynamic, dynamic> statusResponse = await RbacRoleUnderServices
.instance
.add(roleId: event.mainRoleId, rolesId: event.rolesUnder);
if (statusResponse['success']) {
emit(EstPointPersonAssignableRoleLoaded(
mainRole: mainRole!, roles: roles, rolesUnder: rolesUnder));
} else {
emit(EstPointPersonAssignableRoleLoaded(
mainRole: mainRole!, roles: roles, rolesUnder: rolesUnder));
}
} catch (e) {
emit(EstPointPersonAssignableErrorState(message: e.toString()));
}
});
on<DeleteEstPointPersonAssignableRoles>((event, emit) async {
emit(EstPointPersonAssignableRoleLoadingState());
try {
bool success = await RbacRoleUnderServices.instance
.deleteRbacRoleUnder(roleUnderId: event.roleId);
if (success) {
rolesUnder.removeWhere((element) => element.id == event.roleId);
emit(EstPointPersonAssignableDeletedState(success: success));
} else {
emit(EstPointPersonAssignableDeletedState(success: success));
}
} catch (e) {
emit(EstPointPersonAssignableErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,28 @@
part of 'est_point_person_assinable_role_bloc.dart';
abstract class EstPointPersonAssinableRoleEvent extends Equatable {
const EstPointPersonAssinableRoleEvent();
@override
List<Object> get props => [];
}
class GetEstPointPersonAssignableRoles
extends EstPointPersonAssinableRoleEvent {
final int roleId;
const GetEstPointPersonAssignableRoles({required this.roleId});
}
class AddEstPointPersonAssignableRoles
extends EstPointPersonAssinableRoleEvent {
final int mainRoleId;
final List<int> rolesUnder;
const AddEstPointPersonAssignableRoles(
{required this.mainRoleId, required this.rolesUnder});
}
class DeleteEstPointPersonAssignableRoles
extends EstPointPersonAssinableRoleEvent {
final int roleId;
const DeleteEstPointPersonAssignableRoles({required this.roleId});
}

View File

@ -0,0 +1,38 @@
part of 'est_point_person_assinable_role_bloc.dart';
abstract class EstPointPersonAssinableRoleState extends Equatable {
const EstPointPersonAssinableRoleState();
@override
List<Object> get props => [];
}
class EstPointPersonAssignableRoleLoadingState
extends EstPointPersonAssinableRoleState {}
class EstPointPersonAssignableErrorState
extends EstPointPersonAssinableRoleState {
final String message;
const EstPointPersonAssignableErrorState({required this.message});
}
class EstPointPersonAssginableRoleAssignState
extends EstPointPersonAssinableRoleState {
final Map<dynamic, dynamic> responseStatus;
const EstPointPersonAssginableRoleAssignState({required this.responseStatus});
}
class EstPointPersonAssinableRoleInitial
extends EstPointPersonAssinableRoleState {}
class EstPointPersonAssignableRoleLoaded
extends EstPointPersonAssinableRoleState {
final List<RBAC> roles;
final List<RBAC> rolesUnder;
final RBAC mainRole;
const EstPointPersonAssignableRoleLoaded({required this.roles, required this.rolesUnder, required this.mainRole});
}
class EstPointPersonAssignableDeletedState extends EstPointPersonAssinableRoleState {
final bool success;
const EstPointPersonAssignableDeletedState({required this.success});
}

View File

@ -0,0 +1,79 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/model/rbac/role_under.dart';
import '../../../../../model/rbac/rbac.dart';
import '../../../../../sevices/roles/est_point_person/est_point_person_role_assignment_services.dart';
import '../../../../../sevices/roles/rbac_operations/role_assignment_services.dart';
part 'est_role_assignment_event.dart';
part 'est_role_assignment_state.dart';
class EstRoleAssignmentBloc
extends Bloc<EstRoleAssignmentEvent, EstRoleAssignmentState> {
EstRoleAssignmentBloc() : super(EstRoleAssignmentInitial()) {
List<RolesUnder> rolesUnders = [];
List<AssignedRole> assignedRoles = [];
List<RBAC> assignableRoles = [];
on<GetEstPointPersonRolesUnder>((event, emit) async {
emit(EstPointPersonRoleLoadingState());
try {
if (assignedRoles.isEmpty) {
assignedRoles = await EstPointPersonRoleAssignment.instance
.getAssignedRoles(webuserId: event.userId);
}
if (rolesUnders.isEmpty) {
rolesUnders = await EstPointPersonRoleAssignment.instance
.getRolesUnder(roleId: 16);
}
for (var roleUnder in rolesUnders) {
assignableRoles.add(roleUnder.roleUnderChild);
}
emit(EstPointPersonRolesUnderLoadedState(
assignedRoles: assignedRoles,
rolesUnders: rolesUnders,
assignableRole: assignableRoles));
} catch (e) {
emit(EstPointPersonRolesUnderErrorState(message: e.toString()));
}
});
on<EstPointPersonAssignRole>((event, emit) async {
emit(EstPointPersonRoleLoadingState());
try {
Map<dynamic, dynamic> statusResponse =
await RbacRoleAssignmentServices.instance.add(
userId: event.userId,
assignerId: event.assingerId,
roles: event.rolesId);
if (statusResponse['success']) {
assignedRoles = [];
statusResponse['data'].forEach((var roles) {
AssignedRole newAssignRole = AssignedRole.fromJson(roles);
});
emit(EstPointPersonRoleUnderAddedState(response: statusResponse));
} else {
emit(EstPointPersonRoleUnderAddedState(response: statusResponse));
}
} catch (e) {
emit(EstPointPersonRolesUnderErrorState(message: e.toString()));
}
});
on<EstPointPersonDeleteAssignRole>((event, emit) async {
emit(EstPointPersonRoleLoadingState());
try {
bool success = await RbacRoleAssignmentServices.instance
.deleteAssignedRole(roleId: event.roleId);
if (success) {
assignedRoles.removeWhere((element) => element.id == event.roleId);
emit(EstPointPersonDeletedState(success: success));
} else {
emit(EstPointPersonDeletedState(success: success));
}
} catch (e) {
emit(EstPointPersonRolesUnderErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,25 @@
part of 'est_role_assignment_bloc.dart';
abstract class EstRoleAssignmentEvent extends Equatable {
const EstRoleAssignmentEvent();
@override
List<Object> get props => [];
}
class GetEstPointPersonRolesUnder extends EstRoleAssignmentEvent{
final int userId;
const GetEstPointPersonRolesUnder({required this.userId});
}
class EstPointPersonAssignRole extends EstRoleAssignmentEvent{
final int userId;
final List<int> rolesId;
final int assingerId;
const EstPointPersonAssignRole({required this.assingerId, required this.rolesId, required this.userId});
}
class EstPointPersonDeleteAssignRole extends EstRoleAssignmentEvent {
final int roleId;
const EstPointPersonDeleteAssignRole({required this.roleId});
}

View File

@ -0,0 +1,36 @@
part of 'est_role_assignment_bloc.dart';
abstract class EstRoleAssignmentState extends Equatable {
const EstRoleAssignmentState();
@override
List<Object> get props => [];
}
class EstPointPersonRolesUnderLoadedState extends EstRoleAssignmentState{
final List<RolesUnder> rolesUnders;
final List<AssignedRole> assignedRoles;
final List<RBAC> assignableRole;
const EstPointPersonRolesUnderLoadedState({required this.assignedRoles, required this.rolesUnders, required this.assignableRole});
}
class EstPointPersonRolesUnderErrorState extends EstRoleAssignmentState{
final String message;
const EstPointPersonRolesUnderErrorState({required this.message});
}
class EstPointPersonRoleLoadingState extends EstRoleAssignmentState{
}
class EstPointPersonRoleUnderAddedState extends EstRoleAssignmentState{
final Map<dynamic,dynamic> response;
const EstPointPersonRoleUnderAddedState({required this.response});
}
class EstPointPersonDeletedState extends EstRoleAssignmentState {
final bool success;
const EstPointPersonDeletedState({required this.success});
}
class EstRoleAssignmentInitial extends EstRoleAssignmentState {}

View File

@ -26,7 +26,6 @@ class RoleAssignmentBloc
fname = event.firstname; fname = event.firstname;
lname = event.lastname; lname = event.lastname;
fullname = "${event.firstname} ${event.lastname}"; fullname = "${event.firstname} ${event.lastname}";
try { try {
profile = await RbacRoleAssignmentServices.instance.searchUser( profile = await RbacRoleAssignmentServices.instance.searchUser(
page: 1, name: event.firstname, lastname: event.lastname); page: 1, name: event.firstname, lastname: event.lastname);

View File

@ -10,7 +10,7 @@ RBAC rbacFromJson(String str) => RBAC.fromJson(json.decode(str));
String rbacToJson(RBAC data) => json.encode(data.toJson()); String rbacToJson(RBAC data) => json.encode(data.toJson());
class RBAC { class RBAC {
final int? id; int? id;
final String? name; final String? name;
final String? slug; final String? slug;
final String? shorthand; final String? shorthand;

View File

@ -1,4 +1,6 @@
import '../../utils/category.dart';
class AgencyAssignedArea { class AgencyAssignedArea {
final bool? isactive; final bool? isactive;
final Area? area; final Area? area;
@ -51,25 +53,6 @@ class Area {
}; };
} }
class Category {
final int? id;
final IndustryClass? industryClass;
Category({
required this.id,
required this.industryClass,
});
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json["id"],
industryClass: json["industry_class"] == null?null:IndustryClass.fromJson(json["industry_class"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"industry_class": industryClass?.toJson(),
};
}
class IndustryClass { class IndustryClass {
final int? id; final int? id;

View File

@ -26,6 +26,7 @@ class AddressScreen extends StatelessWidget {
int? profileId; int? profileId;
String? token; String? token;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<AddressBloc>().state is AddAddressState?const Text("Add Address"):context.watch<AddressBloc>().state is EditAddressState?const Text("Edit Address"):const Text("Addresses"), title: context.watch<AddressBloc>().state is AddAddressState?const Text("Add Address"):context.watch<AddressBloc>().state is EditAddressState?const Text("Edit Address"):const Text("Addresses"),
centerTitle: true, centerTitle: true,

View File

@ -62,8 +62,8 @@ class _EditContactInformationScreenState
selectedServiceType = state.selectedServiceType; selectedServiceType = state.selectedServiceType;
selectedCommProvider = state.selectedProvider; selectedCommProvider = state.selectedProvider;
commServiceProviders = state.commServiceProviders; commServiceProviders = state.commServiceProviders;
primaryaContact = state.contactInfo.primary!; primaryaContact = state.contactInfo.primary;
active = state.contactInfo.active!; active = state.contactInfo.active;
numberMailController.text = state.contactInfo.numbermail!; numberMailController.text = state.contactInfo.numbermail!;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 24), padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 24),
@ -223,7 +223,7 @@ class _EditContactInformationScreenState
}); });
}, },
decoration: normalTextFieldStyle("", ''), decoration: normalTextFieldStyle("", ''),
name: 'overseas', name: 'primary',
title: const Text("Primary ?"), title: const Text("Primary ?"),
); );
}), }),
@ -241,7 +241,7 @@ class _EditContactInformationScreenState
}); });
}, },
decoration: normalTextFieldStyle("", ''), decoration: normalTextFieldStyle("", ''),
name: 'overseas', name: 'active',
title: const Text("Active ?"), title: const Text("Active ?"),
); );
}), }),

View File

@ -28,6 +28,7 @@ class ContactInformationScreen extends StatelessWidget {
String token; String token;
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<ContactBloc>().state is ContactAddingState title: context.watch<ContactBloc>().state is ContactAddingState
? const Text("Add Contact") ? const Text("Add Contact")

View File

@ -99,16 +99,9 @@ class _EditBasicProfileInfoScreenState
state.primaryInformation.disability!.toLowerCase()); state.primaryInformation.disability!.toLowerCase());
} }
state.genders.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
state.indigenous.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
state.disability.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
state.ethnicity.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
state.religion.insert(
0, ProfileOtherInfo(id: null, name: "NONE", description: null));
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
child: FormBuilder( child: FormBuilder(
@ -408,6 +401,9 @@ class _EditBasicProfileInfoScreenState
.toList(), .toList(),
onChanged: (e) { onChanged: (e) {
selectedEthnicity = e; selectedEthnicity = e;
print(selectedEthnicity!.name);
print(selectedEthnicity!
.id);
}, },
), ),
), ),
@ -444,6 +440,7 @@ class _EditBasicProfileInfoScreenState
Flexible( Flexible(
flex: 1, flex: 1,
child: DropdownButtonFormField<ProfileOtherInfo>( child: DropdownButtonFormField<ProfileOtherInfo>(
isExpanded: true, isExpanded: true,
value: selectedDisability, value: selectedDisability,
decoration: normalTextFieldStyle("Disability", ""), decoration: normalTextFieldStyle("Disability", ""),
@ -524,7 +521,7 @@ class _EditBasicProfileInfoScreenState
context.read<ProfileBloc>().add( context.read<ProfileBloc>().add(
EditBasicProfileInformation( EditBasicProfileInformation(
disabilityId: selectedDisability?.id, disabilityId: selectedDisability?.id,
ethnicityId: selectedDisability?.id, ethnicityId: selectedEthnicity?.id,
genderId: selectedGender?.id, genderId: selectedGender?.id,
indigencyId: selectedIndigency?.id, indigencyId: selectedIndigency?.id,
profileId: widget.profileId, profileId: widget.profileId,

View File

@ -29,6 +29,7 @@ class IdentificationsScreen extends StatelessWidget {
String? token; String? token;
int? profileId; int? profileId;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<IdentificationBloc>().state is IdentificationAddingState ? const Text("Add Identification"):context.watch<IdentificationBloc>().state is IdentificationEditingState?const Text("Edit Identification"):const Text("Identifications"), title: context.watch<IdentificationBloc>().state is IdentificationAddingState ? const Text("Add Identification"):context.watch<IdentificationBloc>().state is IdentificationEditingState?const Text("Edit Identification"):const Text("Identifications"),

View File

@ -28,8 +28,6 @@ class PrimaryInfo extends StatefulWidget {
class _PrimaryInfoState extends State<PrimaryInfo> { class _PrimaryInfoState extends State<PrimaryInfo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _formKey = GlobalKey<FormBuilderState>();
bool enabled = false; bool enabled = false;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
return Scaffold( return Scaffold(
@ -237,6 +235,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
maxLines: 2,
enabled: enabled, enabled: enabled,
name: height, name: height,
initialValue: state initialValue: state
@ -284,6 +283,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
maxLines: 2,
enabled: enabled, enabled: enabled,
name: height, name: height,
initialValue: state.primaryBasicInformation.ip ??= initialValue: state.primaryBasicInformation.ip ??=
@ -316,6 +316,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
maxLines: 2,
enabled: enabled, enabled: enabled,
name: height, name: height,
initialValue: state initialValue: state
@ -329,6 +330,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
maxLines: 2,
enabled: enabled, enabled: enabled,
name: width, name: width,
initialValue: state initialValue: state

View File

@ -558,7 +558,7 @@ class _EditEducationScreenState extends State<EditEducationScreen> {
yearGraduated: yearGraduated:
graduated ? yearGraduated.text : null, graduated ? yearGraduated.text : null,
unitsEarned: !graduated unitsEarned: !graduated
? int.parse(unitsController.text) ? int.tryParse(unitsController.text)
: null, : null,
attachments: null, attachments: null,
); );

View File

@ -7,10 +7,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/screens/profile/components/education/add_modal.dart'; import 'package:unit2/screens/profile/components/education/add_modal.dart';
@ -42,6 +39,7 @@ class EducationScreen extends StatelessWidget {
int profileId; int profileId;
String? token; String? token;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<EducationBloc>().state is AddEducationState title: context.watch<EducationBloc>().state is AddEducationState
? const FittedBox(child: Text("Add Educational Background")) ? const FittedBox(child: Text("Add Educational Background"))
@ -322,9 +320,12 @@ class EducationScreen extends StatelessWidget {
), ),
Column( Column(
children: honors children: honors
.map((Honor honor) => Text( .map((Honor honor) => Padding(
padding: const EdgeInsets.all(3.0),
child: Text(
"-${honor.name!.trim()}", "-${honor.name!.trim()}",
style: Theme.of(context).textTheme.labelMedium, style: Theme.of(context).textTheme.labelSmall,
),
)) ))
.toList(), .toList(),
), ),

View File

@ -8,10 +8,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/attachment.dart'; import 'package:unit2/model/profile/attachment.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
@ -49,7 +46,7 @@ class EligibiltyScreen extends StatelessWidget {
return true; return true;
}, },
child: Scaffold( child: Scaffold(
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<EligibilityBloc>().state is AddEligibilityState title: context.watch<EligibilityBloc>().state is AddEligibilityState
? const Text("Add Eligiblity") ? const Text("Add Eligiblity")

View File

@ -1316,6 +1316,7 @@ class _FamilyBackgroundScreenState extends State<FamilyBackgroundScreen> {
], ],
), ),
Container( Container(
child: children.isNotEmpty child: children.isNotEmpty
? Column( ? Column(
mainAxisSize: mainAxisSize:
@ -1332,7 +1333,7 @@ class _FamilyBackgroundScreenState extends State<FamilyBackgroundScreen> {
const EdgeInsets const EdgeInsets
.symmetric( .symmetric(
horizontal: 12, horizontal: 12,
vertical: 8), vertical: 0),
width: screenWidth, width: screenWidth,
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment:
@ -1645,7 +1646,7 @@ class _FamilyBackgroundScreenState extends State<FamilyBackgroundScreen> {
const EdgeInsets const EdgeInsets
.symmetric( .symmetric(
horizontal: 12, horizontal: 12,
vertical: 8), vertical: 0),
width: screenWidth, width: screenWidth,
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment:

View File

@ -8,10 +8,8 @@ import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/screens/profile/components/learning_development/edit_modal.dart'; import 'package:unit2/screens/profile/components/learning_development/edit_modal.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';

View File

@ -29,6 +29,7 @@ import '../../../../theme-data.dart/form-style.dart';
import '../../../../utils/formatters.dart'; import '../../../../utils/formatters.dart';
import '../../../../utils/global.dart'; import '../../../../utils/global.dart';
import '../../../../utils/location_utilities.dart'; import '../../../../utils/location_utilities.dart';
import '../../../../widgets/error_state.dart';
import '../../shared/add_for_empty_search.dart'; import '../../shared/add_for_empty_search.dart';
class AddLearningAndDevelopmentScreen extends StatefulWidget { class AddLearningAndDevelopmentScreen extends StatefulWidget {
@ -141,6 +142,21 @@ class _AddLearningAndDevelopmentScreenState
SizedBox( SizedBox(
child: show child: show
? SearchableDropdownFormField.paginated( ? SearchableDropdownFormField.paginated(
errorWidget: (value) {
return SomethingWentWrong(
message: value,
onpressed: () {
context
.read<
LearningDevelopmentBloc>()
.add(
GetLearningDevelopments(
profileId: widget
.profileId,
token:
widget.token));
});
},
noRecordTex: SizedBox( noRecordTex: SizedBox(
width: double.infinity, width: double.infinity,
height: 300, height: 300,
@ -189,12 +205,20 @@ class _AddLearningAndDevelopmentScreenState
paginatedRequest: (int page, paginatedRequest: (int page,
String? searchKey) async { String? searchKey) async {
List<ConductedTraining> List<ConductedTraining>
paginatedList=[];
try {
paginatedList = paginatedList =
await LearningDevelopmentServices await LearningDevelopmentServices
.instance .instance
.getConductedTrainings( .getConductedTrainings(
page: page, page: page,
key: searchKey ??= ""); key: searchKey ??= "");
} catch (e) {
context
.read<LearningDevelopmentBloc>()
.add(CallErrorState(
message: e.toString()));
}
return paginatedList.map((e) { return paginatedList.map((e) {
return SearchableDropdownMenuItem( return SearchableDropdownMenuItem(
value: e, value: e,
@ -442,8 +466,8 @@ class _AddLearningAndDevelopmentScreenState
width: screenWidth, width: screenWidth,
child: StatefulBuilder( child: StatefulBuilder(
builder: (context, setState) { builder: (context, setState) {
return StatefulBuilder( return StatefulBuilder(builder:
builder: (context,setState) { (context, setState) {
return Row( return Row(
children: [ children: [
//// FROM DATE //// FROM DATE
@ -458,7 +482,8 @@ class _AddLearningAndDevelopmentScreenState
use24HourFormat: use24HourFormat:
false, false,
icon: const Icon( icon: const Icon(
Icons.date_range), Icons
.date_range),
controller: controller:
fromDateController, fromDateController,
firstDate: firstDate:
@ -477,7 +502,8 @@ class _AddLearningAndDevelopmentScreenState
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
from = DateTime from = DateTime
.parse(value); .parse(
value);
}); });
}, },
initialDate: to == initialDate: to ==
@ -485,19 +511,19 @@ class _AddLearningAndDevelopmentScreenState
? DateTime.now() ? DateTime.now()
: to!.subtract( : to!.subtract(
const Duration( const Duration(
days: 1)), days:
1)),
timeHintText: timeHintText:
"Date of Examination/Conferment", "Date of Examination/Conferment",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle(
"From *", "From *",
"From *") "From *")
.copyWith( .copyWith(
prefixIcon: prefixIcon:
const Icon( const Icon(
Icons.date_range, Icons.date_range,
color: color: Colors
Colors.black87, .black87,
)), )),
initialValue: null, initialValue: null,
)), )),
@ -528,8 +554,8 @@ class _AddLearningAndDevelopmentScreenState
}, },
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
to = DateTime.parse( to = DateTime
value); .parse(value);
}); });
}, },
initialDate: from == initialDate: from ==
@ -548,8 +574,8 @@ class _AddLearningAndDevelopmentScreenState
prefixIcon: prefixIcon:
const Icon( const Icon(
Icons.date_range, Icons.date_range,
color: color: Colors
Colors.black87, .black87,
), ),
), ),
initialValue: null, initialValue: null,
@ -557,8 +583,7 @@ class _AddLearningAndDevelopmentScreenState
), ),
], ],
); );
} });
);
}), }),
), ),
const SizedBox( const SizedBox(

View File

@ -29,6 +29,7 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
int? profileId; int? profileId;
String? token; String? token;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<NonAcademicRecognitionBloc>().state title: context.watch<NonAcademicRecognitionBloc>().state
is AddNonAcademeRecognitionState is AddNonAcademeRecognitionState

View File

@ -1,3 +1,4 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
@ -18,8 +19,11 @@ import '../../../../../utils/formatters.dart';
class AddOrgMemberShipScreen extends StatefulWidget { class AddOrgMemberShipScreen extends StatefulWidget {
final int profileId; final int profileId;
final String token; final String token;
final List<Agency> agencies;
final List<Category> agencyCategories;
final Bloc bloc;
const AddOrgMemberShipScreen( const AddOrgMemberShipScreen(
{super.key, required this.profileId, required this.token}); {super.key, required this.profileId, required this.token, required this.agencies, required this.agencyCategories, required this.bloc});
@override @override
State<AddOrgMemberShipScreen> createState() => _AddOrgMemberShipScreenState(); State<AddOrgMemberShipScreen> createState() => _AddOrgMemberShipScreenState();
@ -45,20 +49,13 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<OrganizationMembershipBloc, OrganizationMembershipState>( return FormBuilder(
builder: (context, state) {
if (state is AddOrgMembershipState) {
return Padding(
padding: const EdgeInsets.all(24),
child: Card(
child: SingleChildScrollView(
child: FormBuilder(
key: _formKey, key: _formKey,
child: Container( child: Container(
padding: padding:
const EdgeInsets.symmetric(vertical:24, horizontal: 24), const EdgeInsets.symmetric(vertical:24, horizontal: 24),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
@ -71,14 +68,17 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 100, itemHeight: 100,
suggestions: state.agencies suggestions: widget.agencies
.map((Agency agency) => .map((Agency agency) =>
SearchFieldListItem(agency.name!, SearchFieldListItem(agency.name!,
item: agency, item: agency,
child: ListTile( child: ListTile(
title: Text( title: AutoSizeText(
agency.name!.toUpperCase(), agency.name!.toUpperCase(),
overflow: TextOverflow.visible, minFontSize: 12,
), ),
subtitle: Text( subtitle: Text(
agency.privateEntity == true agency.privateEntity == true
@ -179,7 +179,7 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
name: addAgencyController.text.toUpperCase(), name: addAgencyController.text.toUpperCase(),
category: null, category: null,
privateEntity: null); privateEntity: null);
state.agencies.insert(0, widget.agencies.insert(0,
newAgency!); newAgency!);
addAgencyController.clear(); addAgencyController.clear();
Navigator.pop(context); Navigator.pop(context);
@ -205,7 +205,7 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
? SearchField( ? SearchField(
focusNode: agencyCategoryFocusNode, focusNode: agencyCategoryFocusNode,
itemHeight: 70, itemHeight: 70,
suggestions: state.agencyCategories suggestions: widget.agencyCategories
.map((Category category) => .map((Category category) =>
SearchFieldListItem( SearchFieldListItem(
category.name!, category.name!,
@ -322,10 +322,8 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
category: selectedCategory, category: selectedCategory,
privateEntity: isPrivate); privateEntity: isPrivate);
} }
final progress = ProgressHUD.of(context); Navigator.of(context).pop();
progress!.showWithText("Loading..."); widget.bloc
context
.read<OrganizationMembershipBloc>()
.add(AddOrgMembership( .add(AddOrgMembership(
agency: newAgency!, agency: newAgency!,
profileId: widget.profileId, profileId: widget.profileId,
@ -339,13 +337,6 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
child: const Text(submit)), child: const Text(submit)),
) )
]), ]),
)), ));
),
),
);
}
return Container();
},
);
} }
} }

View File

@ -3,10 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/other_information/organization_memberships.dart'; import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/screens/profile/components/other_information/org_membership/add_modal.dart'; import 'package:unit2/screens/profile/components/other_information/org_membership/add_modal.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
@ -16,6 +15,7 @@ import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
import '../../../../bloc/profile/other_information/org_membership/organization_membership_bloc.dart'; import '../../../../bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import '../../../../model/utils/category.dart';
import '../../../../utils/alerts.dart'; import '../../../../utils/alerts.dart';
import '../../../../utils/global.dart'; import '../../../../utils/global.dart';
@ -25,7 +25,10 @@ class OrgMembershipsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String? token; String? token;
int profileId; int? profileId;
List<Agency> agencies = [];
List<Category> agencyCategory = [];
final orgBloc = BlocProvider.of<OrganizationMembershipBloc>(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: context.watch<OrganizationMembershipBloc>().state title: context.watch<OrganizationMembershipBloc>().state
@ -38,9 +41,12 @@ class OrgMembershipsScreen extends StatelessWidget {
is OrganizationMembershipLoaded is OrganizationMembershipLoaded
? [ ? [
AddLeading(onPressed: () { AddLeading(onPressed: () {
context showDialog(context: (context),builder: (BuildContext context){
.read<OrganizationMembershipBloc>() return AlertDialog(
.add(ShowAddOrgMembershipForm()); title: const Text("Add Organization Membership"),
content: AddOrgMemberShipScreen(profileId: profileId!, token: token!,agencies: agencies,agencyCategories: agencyCategory,bloc: orgBloc,),
);
});
}) })
] ]
: context.watch<OrganizationMembershipBloc>().state : context.watch<OrganizationMembershipBloc>().state
@ -124,6 +130,8 @@ class OrgMembershipsScreen extends StatelessWidget {
}, },
builder: (context, state) { builder: (context, state) {
if (state is OrganizationMembershipLoaded) { if (state is OrganizationMembershipLoaded) {
agencies = state.agencies;
agencyCategory = state.agencyCategory;
if (state.orgMemberships.isNotEmpty) { if (state.orgMemberships.isNotEmpty) {
return ListView.builder( return ListView.builder(
itemCount: state.orgMemberships.length, itemCount: state.orgMemberships.length,
@ -190,7 +198,7 @@ class OrgMembershipsScreen extends StatelessWidget {
OrganizationMembershipBloc>() OrganizationMembershipBloc>()
.add(DeleteOrgMemberShip( .add(DeleteOrgMemberShip(
profileId: profileId:
profileId, profileId!,
token: token!, token: token!,
org: state org: state
.orgMemberships[ .orgMemberships[
@ -225,13 +233,7 @@ class OrgMembershipsScreen extends StatelessWidget {
"You don't have any Orgazational Membership added. Please click + to add"); "You don't have any Orgazational Membership added. Please click + to add");
} }
} }
if (state is AddOrgMembershipState) {
return
AddOrgMemberShipScreen(
profileId: profileId,
token: token!,
);
}
if (state is OrganizationMembershipErrorState) { if (state is OrganizationMembershipErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, message: state.message,

View File

@ -123,9 +123,12 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
keyboardType: TextInputType.number,
inputFormatters: [mobileFormatter],
name: "mobile", name: "mobile",
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Tel./Mobile *", "Tel./Mobile"), "Mobile *",
"+63 (9xx) xxx - xxxx"),
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
), ),

View File

@ -88,7 +88,7 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
Flexible( Flexible(
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter(),mobileFormatter],
initialValue: state.ref.lastName, initialValue: state.ref.lastName,
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Last name *", "Last name *"), "Last name *", "Last name *"),

View File

@ -23,7 +23,7 @@ class ReferencesScreen extends StatelessWidget {
int? profileId; int? profileId;
String? token; String? token;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<ReferencesBloc>().state is AddReferenceState title: context.watch<ReferencesBloc>().state is AddReferenceState
? const Text("Add Personal Reference") ? const Text("Add Personal Reference")

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
@ -29,6 +28,7 @@ class VolunataryWorkScreen extends StatelessWidget {
int? profileId; int? profileId;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title:context.watch<VoluntaryWorkBloc>().state is AddVoluntaryWorkState? const FittedBox(child: Text("Add $voluntaryScreenTitle"),) :context.watch<VoluntaryWorkBloc>().state is EditVoluntaryWorks? const FittedBox(child: Text("Edit $voluntaryScreenTitle"),): const FittedBox(child: Text(voluntaryScreenTitle)), title:context.watch<VoluntaryWorkBloc>().state is AddVoluntaryWorkState? const FittedBox(child: Text("Add $voluntaryScreenTitle"),) :context.watch<VoluntaryWorkBloc>().state is EditVoluntaryWorks? const FittedBox(child: Text("Edit $voluntaryScreenTitle"),): const FittedBox(child: Text(voluntaryScreenTitle)),
backgroundColor: primary, backgroundColor: primary,
@ -302,7 +302,7 @@ class VolunataryWorkScreen extends StatelessWidget {
} }
if (state is VoluntaryWorkErrorState) { if (state is VoluntaryWorkErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.toString(), onpressed: () { message: state.message, onpressed: () {
context.read<VoluntaryWorkBloc>().add(GetVoluntarWorks(profileId: profileId!, token: token!)); context.read<VoluntaryWorkBloc>().add(GetVoluntarWorks(profileId: profileId!, token: token!));
}); });
} }

View File

@ -90,7 +90,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
StatefulBuilder(builder: (context, setState) { StatefulBuilder(builder: (context, setState) {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 100, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: box1(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => SearchFieldListItem( .map((PositionTitle position) => SearchFieldListItem(
@ -478,6 +478,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
), ),
////MONTHLY SALARY ////MONTHLY SALARY
FormBuilderTextField( FormBuilderTextField(
keyboardType: TextInputType.number,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
salary = value; salary = value;

View File

@ -9,9 +9,6 @@ import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/screens/profile/components/work_history/add_modal.dart'; import 'package:unit2/screens/profile/components/work_history/add_modal.dart';
@ -47,6 +44,7 @@ class WorkHistoryScreen extends StatelessWidget {
AttachmentCategory? selectedAttachmentCategory; AttachmentCategory? selectedAttachmentCategory;
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: context.watch<WorkHistoryBloc>().state is AddWorkHistoryState title: context.watch<WorkHistoryBloc>().state is AddWorkHistoryState
? const FittedBox(child: Text("Add Work History")) ? const FittedBox(child: Text("Add Work History"))

View File

@ -72,12 +72,17 @@ class ProfileInfo extends StatelessWidget {
profile = state.userData!.employeeInfo!.profile!; profile = state.userData!.employeeInfo!.profile!;
return BlocConsumer<ProfileBloc, ProfileState>( return BlocConsumer<ProfileBloc, ProfileState>(
listener: (context, state,){ listener: (
context,
state,
) {
if (state is ProfileLoading) { if (state is ProfileLoading) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if (state is ProfileLoaded || state is ProfileErrorState || state is BasicInformationEditingState) { if (state is ProfileLoaded ||
state is ProfileErrorState ||
state is BasicInformationEditingState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress?.dismiss(); progress?.dismiss();
} }
@ -110,10 +115,17 @@ class ProfileInfo extends StatelessWidget {
), ),
items: [ items: [
subMenu(Icons.person, "Primary", () { subMenu(Icons.person, "Primary", () {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider<ProfileBloc>.value(value: ProfileBloc()..add(GetPrimaryBasicInfo(primaryBasicInformation: profile)),child: PrimaryInfo(token: token!,profileId: profileId!,),); return BlocProvider<ProfileBloc>.value(
value: ProfileBloc()
..add(GetPrimaryBasicInfo(
primaryBasicInformation: profile)),
child: PrimaryInfo(
token: token!,
profileId: profileId!,
),
);
})); }));
}), }),
subMenu(Icons.home, "Addresses", () { subMenu(Icons.home, "Addresses", () {
@ -161,7 +173,6 @@ class ProfileInfo extends StatelessWidget {
subMenu(Icons.flag, "Citizenships", () { subMenu(Icons.flag, "Citizenships", () {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => CitizenshipBloc() create: (context) => CitizenshipBloc()
..add(GetCitizenship( ..add(GetCitizenship(
@ -169,7 +180,8 @@ class ProfileInfo extends StatelessWidget {
.profileInformation .profileInformation
.basicInfo .basicInfo
.citizenships)), .citizenships)),
child: CitizenShipScreen(profileId: profileId!,token: token!), child: CitizenShipScreen(
profileId: profileId!, token: token!),
); );
})); }));
}), }),
@ -368,13 +380,15 @@ class ProfileInfo extends StatelessWidget {
); );
} }
if (state is ProfileLoading) { if (state is ProfileLoading) {
return const LoadingScreen(); return const LoadingScreen();
} }
if (state is ProfileErrorState) { if (state is ProfileErrorState) {
return SomethingWentWrong(message: state.mesage, onpressed: (){ BlocProvider.of<ProfileBloc>( return SomethingWentWrong(
context) message: state.mesage,
.add(LoadProfile(token:token!, userID: profileId!));}); onpressed: () {
BlocProvider.of<ProfileBloc>(context).add(
LoadProfile(token: token!, userID: profileId!));
});
} }
return Container(); return Container();

View File

@ -10,9 +10,14 @@ import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/theme-data.dart/form-style.dart';
import '../../../../../bloc/rbac/rbac_operations/agency/agency_bloc.dart'; import '../../../../../bloc/rbac/rbac_operations/agency/agency_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/assign_area/assign_area_agency_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/assign_area/assign_area_agency_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_assignable/est_point_person_assinable_role_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_role_assignment/est_role_assignment_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart';
import '../../../../../sevices/roles/est_point_person/est_point_person_role_assignment_services.dart';
import '../../../../superadmin/agency.dart/agency_screen.dart'; import '../../../../superadmin/agency.dart/agency_screen.dart';
import '../../../roles/establishment_point_person/est_point_person_agecies.dart'; import '../../../roles/establishment_point_person/est_point_person_agecies.dart';
import '../../../roles/establishment_point_person/est_point_person_role_member_screen.dart';
import '../../../roles/establishment_point_person/est_point_person_role_under_screen.dart';
import '../../../roles/establishment_point_person/est_point_person_station.dart'; import '../../../roles/establishment_point_person/est_point_person_station.dart';
import './shared_card_label.dart'; import './shared_card_label.dart';
@ -204,6 +209,23 @@ class _DashBoardState extends State<DashBoard> {
); );
})); }));
} }
if (e.object.name!.toLowerCase() == "role member") {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
return BlocProvider<EstRoleAssignmentBloc>(
create: (context) => EstRoleAssignmentBloc()..add(GetEstPointPersonRolesUnder(userId: widget.userId)),
child: EstPointPersonRoleAssignmentScreen(id: widget.userId,),
);
}));
}
if (e.object.name!.toLowerCase() == 'assignable role') {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
return BlocProvider<EstPointPersonAssinableRoleBloc>(
create: (context) => EstPointPersonAssinableRoleBloc()..add(const GetEstPointPersonAssignableRoles(roleId: 16)),
child: EstPointPersonRoleUnderScreen(id: widget.userId,),
);
}));
}
////Station ////Station
if (e.object.name == 'Station') { if (e.object.name == 'Station') {
showDialog( showDialog(

View File

@ -75,9 +75,7 @@ class SuperAdminMenu extends StatelessWidget {
? CardLabel( ? CardLabel(
icon: iconGenerator(name: object.object.name!), icon: iconGenerator(name: object.object.name!),
title: title:
object.object.name!.toLowerCase() == 'assignable role' object.object.name!,
? "Role Assignment"
: object.object.name!,
ontap: () { ontap: () {
if (object.object.name == 'Role') { if (object.object.name == 'Role') {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(

View File

@ -0,0 +1,307 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.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:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/models/value_item.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/role/pass_check/est_point_person/est_point_person_role_assignment/est_role_assignment_bloc.dart';
import 'package:unit2/bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart';
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../../model/rbac/assigned_role.dart';
import '../../../../model/rbac/rbac.dart';
import '../../../../theme-data.dart/btn-style.dart';
import '../../../../theme-data.dart/colors.dart';
import '../../../../utils/alerts.dart';
import '../../../../utils/global_context.dart';
class EstPointPersonRoleAssignmentScreen extends StatelessWidget {
final int id;
const EstPointPersonRoleAssignmentScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
Map<String, List<Content>> assignedRoles = {};
List<AssignedRole> roles = [];
List<ValueItem> valueItemAssignableRoles = [];
List<ValueItem> selectedValueItemAssignableRoles = [];
List<RBAC> assignabledRoles = [];
List<Content> users = [];
List<int> userIds = [];
int? selectedUserId;
final formKey = GlobalKey<FormBuilderState>();
final parent = context;
return Scaffold(
appBar: AppBar(
title: const Text("Role Members"),
backgroundColor: primary,
actions: [
AddLeading(onPressed: () {
for (var role in roles) {
String fullname =
"${role.user!.firstName} ${role.user!.lastName}";
if (!userIds.contains(role.user!.id)) {
userIds.add(role.user!.id);
users.add(Content(id: role.user!.id, name: fullname));
}
}
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (context) {
valueItemAssignableRoles = assignabledRoles.map((e) {
return ValueItem(label: e.name!, value: e.id.toString());
}).toList();
return AlertDialog(
title: const Text("Assign Role to User"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown(
decoration: normalTextFieldStyle(
"Select Person", "Select Person"),
name: 'users',
onChanged: (value) {
selectedUserId = value!.id;
},
items: users.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e.name),
);
}).toList()),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemAssignableRoles =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Select Roles",
padding: const EdgeInsets.all(8),
options: valueItemAssignableRoles,
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(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
List<int> rolesId = [];
for (var role in assignabledRoles) {
selectedValueItemAssignableRoles
.forEach((element) {
if (element.value ==
role.id.toString()) {
rolesId.add(role.id!);
}
});
}
parent
.read<EstRoleAssignmentBloc>()
.add(EstPointPersonAssignRole(
rolesId: rolesId,
assingerId: id,
userId: selectedUserId!));
Navigator.pop(context);
}
},
child: const Text("Add"))),
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<EstRoleAssignmentBloc, EstRoleAssignmentState>(
builder: (context, state) {
if (state is EstPointPersonRolesUnderLoadedState) {
roles = state.assignedRoles;
assignabledRoles = state.assignableRole;
assignedRoles = {};
if (state.assignedRoles.isNotEmpty) {
for (var assignedRole in state.assignedRoles) {
String? fullName =
"${assignedRole.user!.firstName} ${assignedRole.user!.lastName}";
if (!assignedRoles.keys.contains(fullName)) {
assignedRoles.addAll({fullName: []});
assignedRoles[fullName]!.add(Content(
id: assignedRole.id!, name: assignedRole.role!.name));
} else {
assignedRoles[fullName]!.add(Content(
id: assignedRole.id!,
name: assignedRole.role!.name));
}
}
}
if (state.assignedRoles.isNotEmpty) {
return GroupListView(
sectionsCount: assignedRoles.keys.toList().length,
countOfItemInSection: (int section) {
return assignedRoles.values.toList()[section].length;
},
separatorBuilder: (context, index) {
return const Divider();
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
trailing: IconButton(
color: Colors.grey.shade600,
icon: const Icon(Icons.delete),
onPressed: () {
confirmAlert(context, () {
context.read<EstRoleAssignmentBloc>().add(
EstPointPersonDeleteAssignRole(
roleId: assignedRoles.values
.toList()[index.section][index.index]
.id));
}, "Delete?", "Confirm Delete?");
},
),
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(
assignedRoles.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(
fontWeight: FontWeight.w600,
color: primary),
),
),
],
),
);
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: second,
title: Text(
assignedRoles.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Colors.white),
),
);
},
);
} else {
return const EmptyData(message: "Empty");
}
}
if (state is EstPointPersonRolesUnderErrorState) {
return SomethingWentWrong(
message: "something went wrong. Please try again!",
onpressed: () {});
}
return Container();
}, listener: (context, state) {
if (state is EstPointPersonRoleLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
////Added State
if (state is EstPointPersonRoleUnderAddedState) {
if (state.response['success']) {
successAlert(
context, "Adding Successfull!", state.response['message'],
() {
Navigator.of(context).pop();
context
.read<EstRoleAssignmentBloc>()
.add(GetEstPointPersonRolesUnder(userId: id));
});
} else {
errorAlert(context, "Adding Failed", state.response['message'],
() {
Navigator.of(context).pop();
context
.read<EstRoleAssignmentBloc>()
.add(GetEstPointPersonRolesUnder(userId: id));
});
}
}
////Deleted State
if (state is EstPointPersonDeletedState) {
if (state.success) {
successAlert(
context, "Delete Successfull!", "Role Deleted Successfully",
() {
Navigator.of(context).pop();
context
.read<EstRoleAssignmentBloc>()
.add(GetEstPointPersonRolesUnder(userId: id));
});
} else {
errorAlert(context, "Delete Failed", "Role Delete Failed", () {
Navigator.of(context).pop();
context
.read<EstRoleAssignmentBloc>()
.add(GetEstPointPersonRolesUnder(userId: id));
});
}
}
if (state is EstPointPersonRolesUnderLoadedState ||
state is EstPointPersonRoleUnderAddedState ||
state is EstPointPersonRoleLoadingState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
}),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -0,0 +1,264 @@
import 'package:app_popup_menu/app_popup_menu.dart';
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:multi_dropdown/models/value_item.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.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';
import '../../../../bloc/role/pass_check/est_point_person/est_point_person_assignable/est_point_person_assinable_role_bloc.dart';
import '../../../../model/rbac/rbac.dart';
import '../../../../theme-data.dart/box_shadow.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.dart';
import '../../../../widgets/empty_data.dart';
class EstPointPersonRoleUnderScreen extends StatelessWidget {
final int id;
const EstPointPersonRoleUnderScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
List<RBAC> roles = [];
List<ValueItem> valueItemRoles = [];
List<ValueItem> selectedValueItemRoles = [];
RBAC? mainRole;
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Establishment Point Person Role Under Screen"),
actions: [
AddLeading(onPressed: () {
valueItemRoles = roles.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
BuildContext parent = context;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add New Role"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown(
decoration: normalTextFieldStyle("", ""),
initialValue: mainRole!.name,
name: "main-role",items:[] ,),
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: 8,
),
const SizedBox(
height: 12,
),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate()) {
List<int> rolesId = [];
for (var role in roles) {
selectedValueItemRoles
.forEach((element) {
if (element.label.toLowerCase() ==
role.name?.toLowerCase()) {
rolesId.add(role.id!);
}
});
}
Navigator.pop(context);
parent.read<EstPointPersonAssinableRoleBloc>().add(
AddEstPointPersonAssignableRoles(
mainRoleId: mainRole!.id!,
rolesUnder: rolesId));
}
},
child: const Text("Add"))),
],
),
),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<EstPointPersonAssinableRoleBloc, EstPointPersonAssinableRoleState>(
listener: (context, state) {
if (state is EstPointPersonAssignableRoleLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is EstPointPersonAssignableRoleLoaded ||
state is EstPointPersonAssginableRoleAssignState ||
state is EstPointPersonAssignableErrorState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////Added State
if (state is EstPointPersonAssginableRoleAssignState) {
if (state.responseStatus['success']) {
successAlert(
context, "Adding Successfull!", state.responseStatus['message'],
() {
Navigator.of(context).pop();
context.read<EstPointPersonAssinableRoleBloc>().add(GetEstPointPersonAssignableRoles(roleId:16 ));
});
} else {
errorAlert(context, "Adding Failed", state.responseStatus['message'],
() {
Navigator.of(context).pop();
context.read<EstPointPersonAssinableRoleBloc>().add(GetEstPointPersonAssignableRoles(roleId:16 ));
});
}
}
////Deleted State
if (state is EstPointPersonAssignableDeletedState) {
if (state.success) {
successAlert(
context, "Delete Successfull!", "Role Deleted Successfully",
() {
Navigator.of(context).pop();
context.read<EstPointPersonAssinableRoleBloc>().add(GetEstPointPersonAssignableRoles(roleId:16 ));
});
} else {
errorAlert(context, "Delete Failed", "Role Delete Failed", () {
Navigator.of(context).pop();
context.read<EstPointPersonAssinableRoleBloc>().add(GetEstPointPersonAssignableRoles(roleId:16 ));
});
}
}
},
builder: (context, state) {
final parent = context;
if (state is EstPointPersonAssignableRoleLoaded) {
roles = state.roles;
mainRole = state.mainRole;
if (state.rolesUnder.isNotEmpty) {
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
itemCount: state.rolesUnder.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Row(
children: [
CircleAvatar(child: Text('${index+1}'),),
const SizedBox(width: 12,),
Flexible(
child: Text(state.rolesUnder[index].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, () {
context.read<EstPointPersonAssinableRoleBloc>().add(
DeleteEstPointPersonAssignableRoles(
roleId:
state.rolesUnder[index].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,
)
],
);
});
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
}
}
if (state is EstPointPersonAssignableErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<RoleBloc>().add(GetRoles());
});
}
return Container();
},
),
),
);
}
}

View File

@ -68,7 +68,7 @@ class EducationService {
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.postRequest(path: path, param: {}, body: body, headers: headers); .postRequest(path: path, param: {}, body: body, headers: headers);
if (response.statusCode == 201) { if (response.statusCode == 2011) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;
} else { } else {
@ -150,7 +150,7 @@ class EducationService {
http.Response response = await Request.instance.deleteRequest( http.Response response = await Request.instance.deleteRequest(
path: path, headers: headers, body: body, param: params); path: path, headers: headers, body: body, param: params);
if (response.statusCode == 200) { if (response.statusCode == 2001) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
success = data['success']; success = data['success'];
} else { } else {

View File

@ -21,7 +21,7 @@ class ProfileOtherInfoServices{
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, headers: headers, param: {}); .getRequest(path: path, headers: headers, param: {});
if (response.statusCode == 200) { if (response.statusCode == 20012) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
if (data['data'] != null) { if (data['data'] != null) {
data['data'].forEach((var e) { data['data'].forEach((var e) {

View File

@ -0,0 +1,163 @@
import 'dart:convert';
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http;
import '../../../model/profile/basic_information/primary-information.dart';
import '../../../model/rbac/role_under.dart';
class EstPointPersonRoleAssignment {
static final EstPointPersonRoleAssignment _instance =
EstPointPersonRoleAssignment();
static EstPointPersonRoleAssignment get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<AssignedRole>> getAssignedRoles(
{required int webuserId}) async {
List<AssignedRole> assignedRoles = [];
String path = Url.instance.getRoleAssignment();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String, String> param = {
"created_by__id": webuserId.toString()
};
try {
http.Response response = await Request.instance
.getRequest(param: param, path: path, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
for (var role in data['data']) {
AssignedRole newRole = AssignedRole.fromJson(role);
assignedRoles.add(newRole);
}
}
}
} catch (e) {
throw e.toString();
}
return assignedRoles;
}
Future<List<RolesUnder>> getRolesUnder({required int roleId}) async {
List<RolesUnder> rolesUnder = [];
String path = Url.instance.getRolesUnder();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map<String,String> param={"role_under_main__id":roleId.toString()};
try {
http.Response response = await Request.instance
.getRequest(param: param, path: path, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
for (var roleUnd in data['data']) {
RolesUnder newRoleUnder = RolesUnder.fromJson(roleUnd);
rolesUnder.add(newRoleUnder);
}
}
}
} catch (e) {
throw e.toString();
}
return rolesUnder;
}
Future<bool> deleteAssignedRole({required int roleId}) async {
bool success = false;
String path = "${Url.instance.getRoleAssignment()}$roleId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try {
http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {});
if (response.statusCode == 200) {
success = true;
}
} catch (e) {
throw e.toString();
}
return success;
}
////Add
Future<Map<dynamic, dynamic>> add({
required int userId,
required int? assignerId,
required List<int> roles,
}) async {
String path = Url.instance.getRoleAssignment();
Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = {
"user_id": userId,
"roles": roles,
"assigner_user_id": assignerId,
};
try {
http.Response response = await Request.instance
.postRequest(path: path, body: body, headers: headers, param: {});
if (response.statusCode == 201) {
Map data = jsonDecode(response.body);
statusResponse = data;
} else {
Map data = jsonDecode(response.body);
String message = data['message'];
statusResponse.addAll({'message': message});
statusResponse.addAll(
{'success': false},
);
}
} catch (e) {
throw e.toString();
}
return statusResponse;
}
Future<Profile?> searchUser(
{required int page, required String name, required String lastname}) async {
String path = Url.instance.searchUsers();
Profile? user;
Map<String, String> params = {
"profile__last_name__icontains": lastname,
"profile__first_name__icontains": name,
"page": page.toString(),
"is_paginated": "true",
};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
http.Response response = await Request.instance
.getRequest(param: params, path: path, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
for(var profile in data['data']) {
int websuerId = profile['webuserid'];
Profile newUser = Profile.fromJson(profile['profile']);
newUser.webuserId = websuerId;
user= newUser;
break;
}
}
return user;
}
}

View File

@ -12,7 +12,7 @@ class AttachmentServices {
Future<List<AttachmentCategory>> getCategories() async { Future<List<AttachmentCategory>> getCategories() async {
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
String path = Url.instance.attachmentCategories(); String path = Url.instance.attachmentCategories()+"11232";
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
}; };

View File

@ -19,7 +19,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { 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)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
Fluttertoast.showToast( Fluttertoast.showToast(
@ -61,7 +61,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await post(Uri.http(host, path!, param), response = await post(Uri.https(host, path!, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
@ -104,7 +104,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response =await put(Uri.http(host,path,param),headers: headers,body: jsonEncode(body)); response =await put(Uri.https(host,path,param),headers: headers,body: jsonEncode(body));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: timeoutError, msg: timeoutError,
@ -186,7 +186,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await delete(Uri.http(host, path, param), response = await delete(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {

View File

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