add station for establishment point person and superadmin
parent
de4107e4e8
commit
14dd524c71
|
@ -2,7 +2,9 @@ import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:unit2/model/rbac/rbac_station.dart';
|
import 'package:unit2/model/rbac/rbac_station.dart';
|
||||||
import 'package:unit2/sevices/roles/rbac_operations/station_services.dart';
|
import 'package:unit2/sevices/roles/rbac_operations/station_services.dart';
|
||||||
|
import '../../../../model/rbac/station_type.dart';
|
||||||
import '../../../../model/utils/agency.dart';
|
import '../../../../model/utils/agency.dart';
|
||||||
|
import '../../../../model/utils/position.dart';
|
||||||
import '../../../../utils/profile_utilities.dart';
|
import '../../../../utils/profile_utilities.dart';
|
||||||
part 'station_event.dart';
|
part 'station_event.dart';
|
||||||
part 'station_state.dart';
|
part 'station_state.dart';
|
||||||
|
@ -11,6 +13,8 @@ class StationBloc extends Bloc<StationEvent, StationState> {
|
||||||
StationBloc() : super(StationInitial()) {
|
StationBloc() : super(StationInitial()) {
|
||||||
List<RbacStation> stations = [];
|
List<RbacStation> stations = [];
|
||||||
List<Agency> agencies = [];
|
List<Agency> agencies = [];
|
||||||
|
List<StationType> stationTypes = [];
|
||||||
|
List<PositionTitle> positions = [];
|
||||||
on<GetStations>((event, emit) async {
|
on<GetStations>((event, emit) async {
|
||||||
emit(StationLoadingState());
|
emit(StationLoadingState());
|
||||||
try {
|
try {
|
||||||
|
@ -22,13 +26,41 @@ class StationBloc extends Bloc<StationEvent, StationState> {
|
||||||
await ProfileUtilities.instance.getAgecies();
|
await ProfileUtilities.instance.getAgecies();
|
||||||
agencies = newAgencies;
|
agencies = newAgencies;
|
||||||
}
|
}
|
||||||
emit(StationLoadedState(stations: stations, agencies: agencies));
|
if (stationTypes.isEmpty) {
|
||||||
|
stationTypes = await RbacStationServices.instance.getStationTypes();
|
||||||
|
}
|
||||||
|
if (positions.isEmpty) {
|
||||||
|
positions = await RbacStationServices.instance.getPositionTitle();
|
||||||
|
}
|
||||||
|
emit(StationLoadedState(
|
||||||
|
stations: stations,
|
||||||
|
agencies: agencies,
|
||||||
|
stationTypes: stationTypes,
|
||||||
|
positions: positions));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(StationErrorState(message: e.toString()));
|
emit(StationErrorState(message: e.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
on<FilterStation>((event, emit)async {
|
on<AddRbacStation>((event, emit) async {
|
||||||
// emit(StationLoadingState());
|
emit(StationLoadingState());
|
||||||
|
try {
|
||||||
|
Map<dynamic, dynamic> statusResponse = await RbacStationServices
|
||||||
|
.instance
|
||||||
|
.addStation(station: event.station);
|
||||||
|
if (statusResponse['success']) {
|
||||||
|
RbacStation newStation = RbacStation.fromJson(statusResponse['data']);
|
||||||
|
stations.add(newStation);
|
||||||
|
emit(RbacStationAddedState(response: statusResponse));
|
||||||
|
} else {
|
||||||
|
emit(RbacStationAddedState(response: statusResponse));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(StationErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<FilterStation>((event, emit) async {
|
||||||
|
emit(StationLoadingState());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stations = await RbacStationServices.instance
|
stations = await RbacStationServices.instance
|
||||||
.getStations(agencyId: event.agencyId.toString());
|
.getStations(agencyId: event.agencyId.toString());
|
||||||
|
@ -38,10 +70,16 @@ class StationBloc extends Bloc<StationEvent, StationState> {
|
||||||
await ProfileUtilities.instance.getAgecies();
|
await ProfileUtilities.instance.getAgecies();
|
||||||
agencies = newAgencies;
|
agencies = newAgencies;
|
||||||
}
|
}
|
||||||
emit(StationLoadedState(stations: stations, agencies: agencies));
|
emit(StationLoadedState(
|
||||||
|
stations: stations,
|
||||||
|
agencies: agencies,
|
||||||
|
positions: positions,
|
||||||
|
stationTypes: stationTypes));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(StationErrorState(message: e.toString()));
|
emit(StationErrorState(message: e.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,17 @@ abstract class StationEvent extends Equatable {
|
||||||
class GetStations extends StationEvent {
|
class GetStations extends StationEvent {
|
||||||
final int agencyId;
|
final int agencyId;
|
||||||
const GetStations({required this.agencyId});
|
const GetStations({required this.agencyId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [agencyId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterStation extends StationEvent {
|
class FilterStation extends StationEvent {
|
||||||
final int agencyId;
|
final int agencyId;
|
||||||
const FilterStation({required this.agencyId});
|
const FilterStation({required this.agencyId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [agencyId];
|
||||||
|
}
|
||||||
|
class AddRbacStation extends StationEvent {
|
||||||
|
final RbacStation station;
|
||||||
|
const AddRbacStation({required this.station});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,11 @@ class StationInitial extends StationState {}
|
||||||
class StationLoadedState extends StationState {
|
class StationLoadedState extends StationState {
|
||||||
final List<Agency> agencies;
|
final List<Agency> agencies;
|
||||||
final List<RbacStation> stations;
|
final List<RbacStation> stations;
|
||||||
const StationLoadedState({required this.stations, required this.agencies});
|
final List<StationType> stationTypes;
|
||||||
|
final List<PositionTitle> positions;
|
||||||
|
const StationLoadedState({required this.stations, required this.agencies,required this.positions, required this.stationTypes});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [agencies,stations];
|
List<Object> get props => [agencies,stations,stationTypes,positions];
|
||||||
}
|
}
|
||||||
|
|
||||||
class StationLoadingState extends StationState {}
|
class StationLoadingState extends StationState {}
|
||||||
|
@ -27,6 +29,17 @@ class StationErrorState extends StationState {
|
||||||
}
|
}
|
||||||
|
|
||||||
class FilterStationState extends StationState {
|
class FilterStationState extends StationState {
|
||||||
final int agencyId;
|
final List<Agency> agencies;
|
||||||
const FilterStationState({required this.agencyId});
|
final List<RbacStation> stations;
|
||||||
|
final List<StationType> stationTypes;
|
||||||
|
final List<PositionTitle> positions;
|
||||||
|
const FilterStationState({required this.stations, required this.agencies,required this.positions, required this.stationTypes});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [agencies,stations,stationTypes,positions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RbacStationAddedState extends StationState{
|
||||||
|
final Map<dynamic,dynamic> response;
|
||||||
|
const RbacStationAddedState({required this.response});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
|
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
|
||||||
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
|
||||||
import 'package:unit2/model/utils/position.dart';
|
import 'package:unit2/model/utils/position.dart';
|
||||||
|
|
||||||
import '../../../../../model/rbac/rbac_station.dart';
|
import '../../../../../model/rbac/rbac_station.dart';
|
||||||
import '../../../../../model/utils/agency.dart';
|
import '../../../../../model/rbac/station_type.dart';
|
||||||
import '../../../../../sevices/roles/rbac_operations/station_services.dart';
|
import '../../../../../sevices/roles/rbac_operations/station_services.dart';
|
||||||
import '../../../../../utils/profile_utilities.dart';
|
|
||||||
|
|
||||||
part 'est_point_person_station_event.dart';
|
part 'est_point_person_station_event.dart';
|
||||||
part 'est_point_person_station_state.dart';
|
part 'est_point_person_station_state.dart';
|
||||||
|
|
||||||
|
@ -43,7 +39,7 @@ class EstPointPersonStationBloc
|
||||||
});
|
});
|
||||||
on<AddEstPointPersonStation>((event, emit) async {
|
on<AddEstPointPersonStation>((event, emit) async {
|
||||||
emit(EstPersonStationLoadingState());
|
emit(EstPersonStationLoadingState());
|
||||||
// try {
|
try {
|
||||||
Map<dynamic, dynamic> statusResponse = await RbacStationServices
|
Map<dynamic, dynamic> statusResponse = await RbacStationServices
|
||||||
.instance
|
.instance
|
||||||
.addStation(station: event.station);
|
.addStation(station: event.station);
|
||||||
|
@ -54,9 +50,9 @@ class EstPointPersonStationBloc
|
||||||
} else {
|
} else {
|
||||||
emit(EstPointPersonAddedState(response: statusResponse));
|
emit(EstPointPersonAddedState(response: statusResponse));
|
||||||
}
|
}
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// emit(EstPersonStationErrorState(message: e.toString()));
|
emit(EstPersonStationErrorState(message: e.toString()));
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import 'package:unit2/model/rbac/station_type.dart';
|
||||||
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
||||||
|
|
||||||
class RbacStation {
|
class RbacStation {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final rbacStationType = rbacStationTypeFromJson(jsonString);
|
||||||
|
|
||||||
|
|
||||||
|
class StationType {
|
||||||
|
final int? id;
|
||||||
|
final String? typeName;
|
||||||
|
final String? color;
|
||||||
|
final int? order;
|
||||||
|
final bool? isActive;
|
||||||
|
final String? group;
|
||||||
|
|
||||||
|
StationType({
|
||||||
|
required this.id,
|
||||||
|
required this.typeName,
|
||||||
|
required this.color,
|
||||||
|
required this.order,
|
||||||
|
required this.isActive,
|
||||||
|
required this.group,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory StationType.fromJson(Map<String, dynamic> json) => StationType(
|
||||||
|
id: json["id"],
|
||||||
|
typeName: json["type_name"],
|
||||||
|
color: json["color"],
|
||||||
|
order: json["order"],
|
||||||
|
isActive: json["is_active"],
|
||||||
|
group: json["group"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"type_name": typeName,
|
||||||
|
"color": color,
|
||||||
|
"order": order,
|
||||||
|
"is_active": isActive,
|
||||||
|
"group": group,
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
// final assignArea = assignAreaFromJson(jsonString);
|
// final assignArea = assignAreaFromJson(jsonString);
|
||||||
|
|
||||||
import '../../rbac/rbac_station.dart';
|
import '../../rbac/rbac_station.dart';
|
||||||
|
import '../../rbac/station_type.dart';
|
||||||
|
|
||||||
class StationAssignArea {
|
class StationAssignArea {
|
||||||
final bool? isactive;
|
final bool? isactive;
|
||||||
|
@ -132,38 +133,4 @@ class ChildStationInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class StationType {
|
|
||||||
final int? id;
|
|
||||||
final String? typeName;
|
|
||||||
final String? color;
|
|
||||||
final int? order;
|
|
||||||
final bool? isActive;
|
|
||||||
final String? group;
|
|
||||||
|
|
||||||
StationType({
|
|
||||||
required this.id,
|
|
||||||
required this.typeName,
|
|
||||||
required this.color,
|
|
||||||
required this.order,
|
|
||||||
required this.isActive,
|
|
||||||
required this.group,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory StationType.fromJson(Map<String, dynamic> json) => StationType(
|
|
||||||
id: json["id"],
|
|
||||||
typeName: json["type_name"],
|
|
||||||
color: json["color"],
|
|
||||||
order: json["order"],
|
|
||||||
isActive: json["is_active"],
|
|
||||||
group: json["group"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"id": id,
|
|
||||||
"type_name": typeName,
|
|
||||||
"color": color,
|
|
||||||
"order": order,
|
|
||||||
"is_active": isActive,
|
|
||||||
"group": group,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:app_popup_menu/app_popup_menu.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';
|
||||||
|
@ -9,29 +8,57 @@ import 'package:searchfield/searchfield.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.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/bloc/rbac/rbac_operations/station/station_bloc.dart';
|
||||||
import 'package:unit2/model/rbac/rbac_station.dart';
|
import 'package:unit2/model/rbac/rbac_station.dart';
|
||||||
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
|
import 'package:unit2/model/roles/pass_check/station_assign_area.dart';
|
||||||
|
import 'package:unit2/model/utils/agency.dart';
|
||||||
|
import 'package:unit2/model/utils/position.dart';
|
||||||
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||||
import 'package:unit2/widgets/error_state.dart';
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
import '../../../model/utils/agency.dart';
|
import '../../../../bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart';
|
||||||
import '../../../theme-data.dart/box_shadow.dart';
|
import '../../../../model/rbac/station_type.dart';
|
||||||
import '../../../theme-data.dart/btn-style.dart';
|
import '../../../../theme-data.dart/box_shadow.dart';
|
||||||
import '../../../theme-data.dart/colors.dart';
|
import '../../../../theme-data.dart/btn-style.dart';
|
||||||
import '../../../theme-data.dart/form-style.dart';
|
import '../../../../theme-data.dart/colors.dart';
|
||||||
import '../../../utils/alerts.dart';
|
import '../../../../theme-data.dart/form-style.dart';
|
||||||
|
import '../../../../utils/alerts.dart';
|
||||||
|
import '../../../../utils/global.dart';
|
||||||
|
import '../../../../widgets/empty_data.dart';
|
||||||
import '../../../utils/formatters.dart';
|
import '../../../utils/formatters.dart';
|
||||||
import '../../../utils/global.dart';
|
import '../../profile/shared/add_for_empty_search.dart';
|
||||||
import '../../../widgets/empty_data.dart';
|
|
||||||
|
|
||||||
class RbacStationScreen extends StatelessWidget {
|
class RbacStationScreen extends StatefulWidget {
|
||||||
final int id;
|
final int agencyId;
|
||||||
const RbacStationScreen({super.key, required this.id});
|
const RbacStationScreen({
|
||||||
|
required this.agencyId,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RbacStationScreen> createState() => _RbacStationScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RbacStationScreenState extends State<RbacStationScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final agencyFocusNode = FocusNode();
|
final rbacStationBloc = BlocProvider.of<StationBloc>(context);
|
||||||
List<RbacStation> stations = [];
|
List<RbacStation> stations = [];
|
||||||
final formKey = GlobalKey<FormBuilderState>();
|
final formKey = GlobalKey<FormBuilderState>();
|
||||||
Agency selectedAgency;
|
List<Map<dynamic, dynamic>> hierarchy = [];
|
||||||
|
bool mainParent = false;
|
||||||
|
bool isWithinParent = true;
|
||||||
|
bool isHospital = false;
|
||||||
|
List<StationType> stationTypes = [];
|
||||||
|
List<PositionTitle> positions = [];
|
||||||
|
List<RbacStation> mainParentStations = [];
|
||||||
|
List<RbacStation> parentStations = [];
|
||||||
|
List<Agency> agencies = [];
|
||||||
|
RbacStation? selectedMainParentStation;
|
||||||
|
RbacStation? selectedParentStation;
|
||||||
|
StationType? selectedStationType;
|
||||||
|
PositionTitle? selectedPositiontitle;
|
||||||
|
int selectedAgencyId = widget.agencyId;
|
||||||
|
final addStationTypeController = TextEditingController();
|
||||||
|
final stationTypeFocusNode = FocusNode();
|
||||||
|
final agencyFocusNode = FocusNode();
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
|
@ -40,43 +67,297 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
actions: [
|
actions: [
|
||||||
AddLeading(onPressed: () {
|
AddLeading(onPressed: () {
|
||||||
BuildContext parent = context;
|
BuildContext parent = context;
|
||||||
|
mainParentStations = [];
|
||||||
|
mainParent = stations.isEmpty ? true : false;
|
||||||
|
for (RbacStation station in stations) {
|
||||||
|
if (station.hierarchyOrderNo == 1) {
|
||||||
|
mainParentStations.add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////Add new tation
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text("Add New Station"),
|
title: const Text("Add New Station"),
|
||||||
content: FormBuilder(
|
content: SingleChildScrollView(
|
||||||
|
child: FormBuilder(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: StatefulBuilder(builder: (context, setState) {
|
||||||
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
FormBuilderTextField(
|
////is main parent
|
||||||
name: "object_name",
|
FormBuilderSwitch(
|
||||||
|
initialValue: mainParent,
|
||||||
|
activeColor: second,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
mainParent = !mainParent;
|
||||||
|
});
|
||||||
|
},
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Role name *", "Role name "),
|
"is Main Parent?", 'is Main Parent?'),
|
||||||
|
name: 'main-parent',
|
||||||
|
title: Text(mainParent ? "YES" : "NO"),
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
errorText: "This field is required"),
|
errorText: "This field is required"),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 8,
|
height: mainParent ? 0 : 8,
|
||||||
),
|
),
|
||||||
FormBuilderTextField(
|
//// selected main parent
|
||||||
name: "slug",
|
SizedBox(
|
||||||
decoration: normalTextFieldStyle("Slug ", "Slug"),
|
child: mainParent == true
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: FormBuilderDropdown<RbacStation>(
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Main Parent Station",
|
||||||
|
"Main Parent Station"),
|
||||||
|
name: "parent-stations",
|
||||||
|
items: mainParentStations.isEmpty
|
||||||
|
? []
|
||||||
|
: mainParentStations.map((e) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.stationName!),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (RbacStation? e) {
|
||||||
|
setState(() {
|
||||||
|
selectedMainParentStation = e;
|
||||||
|
parentStations = [];
|
||||||
|
for (RbacStation station
|
||||||
|
in stations) {
|
||||||
|
if (station.mainParentStation ==
|
||||||
|
selectedMainParentStation!
|
||||||
|
.id) {
|
||||||
|
parentStations.add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parentStations.add(
|
||||||
|
selectedMainParentStation!);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
),
|
||||||
FormBuilderTextField(
|
SizedBox(
|
||||||
validator: FormBuilderValidators.maxLength(50,
|
height: mainParent ? 0 : 8,
|
||||||
errorText: "Max characters only 50"),
|
),
|
||||||
name: "shorthand",
|
////parent station
|
||||||
decoration:
|
SizedBox(
|
||||||
normalTextFieldStyle("Shorthand ", "Shorthand"),
|
child: mainParent == true
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: FormBuilderDropdown<RbacStation>(
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Parent Station", "Parent Station"),
|
||||||
|
name: "parent-stations",
|
||||||
|
onChanged: (RbacStation? e) {
|
||||||
|
setState(() {
|
||||||
|
selectedParentStation = e;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: parentStations.isEmpty
|
||||||
|
? []
|
||||||
|
: parentStations.map((e) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.stationName!),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
|
////Station Type
|
||||||
|
SearchField(
|
||||||
|
itemHeight: 50,
|
||||||
|
suggestionsDecoration: box1(),
|
||||||
|
suggestions: stationTypes
|
||||||
|
.map((StationType stationType) =>
|
||||||
|
SearchFieldListItem(
|
||||||
|
stationType.typeName!,
|
||||||
|
item: stationType,
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
stationType.typeName!,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
)),
|
||||||
|
)))
|
||||||
|
.toList(),
|
||||||
|
validator: (station) {
|
||||||
|
if (station!.isEmpty) {
|
||||||
|
return "This field is required";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
focusNode: stationTypeFocusNode,
|
||||||
|
searchInputDecoration:
|
||||||
|
normalTextFieldStyle("Station Type *", "")
|
||||||
|
.copyWith(
|
||||||
|
suffixIcon: GestureDetector(
|
||||||
|
onTap: () => stationTypeFocusNode.unfocus(),
|
||||||
|
child: const Icon(Icons.arrow_drop_down),
|
||||||
|
)),
|
||||||
|
onSuggestionTap: (position) {
|
||||||
|
setState(() {
|
||||||
|
selectedStationType = position.item!;
|
||||||
|
stationTypeFocusNode.unfocus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
emptyWidget: EmptyWidget(
|
||||||
|
title: "Add StationType",
|
||||||
|
controller: addStationTypeController,
|
||||||
|
onpressed: () {
|
||||||
|
setState(() {
|
||||||
|
StationType stationType = StationType(
|
||||||
|
id: null,
|
||||||
|
typeName:
|
||||||
|
addStationTypeController.text,
|
||||||
|
color: null,
|
||||||
|
order: null,
|
||||||
|
isActive: null,
|
||||||
|
group: null);
|
||||||
|
stationTypes.add(stationType);
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
////Position title
|
||||||
|
FormBuilderDropdown(
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Head Position", "Head Position"),
|
||||||
|
name: "head-position",
|
||||||
|
items: positions.map((e) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.title!),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (title) {
|
||||||
|
selectedPositiontitle = title;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
////is within parent
|
||||||
|
FormBuilderSwitch(
|
||||||
|
initialValue: true,
|
||||||
|
activeColor: second,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
isWithinParent = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Location of the station within this parent?",
|
||||||
|
'Location of the station within this parent?'),
|
||||||
|
name: 'isWithinParent',
|
||||||
|
title: Text(isWithinParent ? "YES" : "NO"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
//// Station Name
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This Field is required"),
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Station name", "Station name"),
|
||||||
|
name: "station-name"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
//// Acronym
|
||||||
|
Flexible(
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This Field is required"),
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Acronym", "Acronym"),
|
||||||
|
name: "acronym"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
FormBuilderTextField(
|
||||||
|
////Description
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Station description",
|
||||||
|
"Station description"),
|
||||||
|
name: "station-description"),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
////Code
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Code", "Code"),
|
||||||
|
name: "code"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
//// Full Code
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Full Code", "Full Code"),
|
||||||
|
name: "fullcode"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
////is Hospital
|
||||||
|
FormBuilderSwitch(
|
||||||
|
initialValue: isHospital,
|
||||||
|
activeColor: second,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
isHospital = !isHospital;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Is Hospital", ''),
|
||||||
|
name: 'isHospital',
|
||||||
|
title: Text(isHospital == true ? "YES" : "NO"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 50,
|
height: 50,
|
||||||
|
@ -84,51 +365,91 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
style: mainBtnStyle(
|
style: mainBtnStyle(
|
||||||
primary, Colors.transparent, second),
|
primary, Colors.transparent, second),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
RbacStation? newStation;
|
||||||
if (formKey.currentState!
|
if (formKey.currentState!
|
||||||
.saveAndValidate()) {
|
.saveAndValidate()) {
|
||||||
String name = formKey
|
String? stationName = formKey
|
||||||
.currentState!.value['object_name'];
|
.currentState!
|
||||||
String? slug =
|
.value['station-name'];
|
||||||
formKey.currentState!.value['slug'];
|
String? acronym = formKey
|
||||||
String? short = formKey
|
.currentState!.value['acronym'];
|
||||||
.currentState!.value['shorthand'];
|
String? code = formKey
|
||||||
parent.read<RoleBloc>().add(AddRbacRole(
|
.currentState!.value['code'];
|
||||||
id: id,
|
String? fullcode = formKey
|
||||||
name: name,
|
.currentState!.value['fullcode'];
|
||||||
shorthand: short,
|
String? description = formKey
|
||||||
slug: slug));
|
.currentState!
|
||||||
|
.value['station-description'];
|
||||||
|
newStation = RbacStation(
|
||||||
|
id: null,
|
||||||
|
stationName: stationName,
|
||||||
|
stationType: selectedStationType,
|
||||||
|
hierarchyOrderNo: mainParent
|
||||||
|
? 1
|
||||||
|
: selectedParentStation!
|
||||||
|
.hierarchyOrderNo! +
|
||||||
|
1,
|
||||||
|
headPosition:
|
||||||
|
selectedPositiontitle?.title,
|
||||||
|
governmentAgency:
|
||||||
|
GovernmentAgency(
|
||||||
|
agencyid:
|
||||||
|
selectedAgencyId,
|
||||||
|
agencyname: null,
|
||||||
|
agencycatid: null,
|
||||||
|
privateEntity: null,
|
||||||
|
contactinfoid: null),
|
||||||
|
acronym: acronym,
|
||||||
|
parentStation: mainParent
|
||||||
|
? null
|
||||||
|
: selectedParentStation!.id!,
|
||||||
|
code: code,
|
||||||
|
fullcode: fullcode,
|
||||||
|
childStationInfo: null,
|
||||||
|
islocationUnderParent:
|
||||||
|
isWithinParent,
|
||||||
|
mainParentStation: mainParent
|
||||||
|
? null
|
||||||
|
: selectedMainParentStation!
|
||||||
|
.id!,
|
||||||
|
description: description,
|
||||||
|
ishospital: isHospital,
|
||||||
|
isactive: true,
|
||||||
|
sellingStation: null);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
rbacStationBloc.add(AddRbacStation(
|
||||||
|
station: newStation));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text("Add"))),
|
child: const Text("Add"))),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
],
|
////Filter
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text(
|
||||||
|
"Select agency to filter stations",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
body: ProgressHUD(
|
content: SizedBox(
|
||||||
padding: const EdgeInsets.all(24),
|
child: // //// Filter Agencies
|
||||||
backgroundColor: Colors.black87,
|
|
||||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
|
||||||
child: BlocConsumer<StationBloc, StationState>(
|
|
||||||
listener: (context, state) {},
|
|
||||||
builder: (context, state) {
|
|
||||||
final parent = context;
|
|
||||||
if (state is StationLoadedState) {
|
|
||||||
stations = state.stations;
|
|
||||||
if (state.stations.isNotEmpty) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: SearchField(
|
child: SearchField(
|
||||||
inputFormatters: [UpperCaseTextFormatter()],
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
itemHeight: 70,
|
itemHeight: 100,
|
||||||
focusNode: agencyFocusNode,
|
focusNode: agencyFocusNode,
|
||||||
suggestions: state.agencies
|
suggestions: agencies
|
||||||
.map((Agency agency) =>
|
.map((Agency agency) =>
|
||||||
SearchFieldListItem(agency.name!,
|
SearchFieldListItem(agency.name!,
|
||||||
item: agency,
|
item: agency,
|
||||||
|
@ -141,7 +462,6 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
searchInputDecoration:
|
searchInputDecoration:
|
||||||
normalTextFieldStyle("Filter", "").copyWith(
|
normalTextFieldStyle("Filter", "").copyWith(
|
||||||
prefixIcon: const Icon(Icons.filter_list),
|
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: const Icon(Icons.arrow_drop_down),
|
icon: const Icon(Icons.arrow_drop_down),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -150,9 +470,12 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
)),
|
)),
|
||||||
onSuggestionTap: (agency) {
|
onSuggestionTap: (agency) {
|
||||||
agencyFocusNode.unfocus();
|
agencyFocusNode.unfocus();
|
||||||
selectedAgency = agency.item!;
|
|
||||||
parent.read<StationBloc>().add(
|
selectedAgencyId = agency.item!.id!;
|
||||||
FilterStation(agencyId: selectedAgency.id!));
|
print(selectedAgencyId);
|
||||||
|
Navigator.pop(context);
|
||||||
|
rbacStationBloc.add(FilterStation(
|
||||||
|
agencyId: selectedAgencyId));
|
||||||
},
|
},
|
||||||
validator: (agency) {
|
validator: (agency) {
|
||||||
if (agency!.isEmpty) {
|
if (agency!.isEmpty) {
|
||||||
|
@ -164,12 +487,97 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
child: Text("No result found..."),
|
child: Text("No result found..."),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.filter_list))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: ProgressHUD(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
backgroundColor: Colors.black87,
|
||||||
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||||
|
child: BlocConsumer<StationBloc, StationState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
if (state is StationLoadingState) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.showWithText("Please wait...");
|
||||||
|
}
|
||||||
|
if (state is RbacStationAddedState) {
|
||||||
|
if (state.response['success']) {
|
||||||
|
successAlert(
|
||||||
|
context, "Adding Successfull!", state.response['message'],
|
||||||
|
() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<StationBloc>()
|
||||||
|
.add(GetStations(agencyId: selectedAgencyId));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Adding Failed", state.response['message'],
|
||||||
|
() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<StationBloc>()
|
||||||
|
.add(GetStations(agencyId: selectedAgencyId));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state is StationLoadedState ||
|
||||||
|
state is RbacStationAddedState ||
|
||||||
|
state is StationErrorState) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.dismiss();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
builder: (context, state) {
|
||||||
|
final parent = context;
|
||||||
|
if (state is StationLoadedState) {
|
||||||
|
stations = state.stations;
|
||||||
|
stationTypes = state.stationTypes;
|
||||||
|
positions = state.positions;
|
||||||
|
agencies = state.agencies;
|
||||||
|
int max = 0;
|
||||||
|
hierarchy = [];
|
||||||
|
for (RbacStation station in stations) {
|
||||||
|
if (station.hierarchyOrderNo != null) {
|
||||||
|
if (max < station.hierarchyOrderNo!) {
|
||||||
|
max = station.hierarchyOrderNo!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= max; i++) {
|
||||||
|
hierarchy.add({i: []});
|
||||||
|
}
|
||||||
|
for (var station in stations) {
|
||||||
|
if (station.hierarchyOrderNo != null) {
|
||||||
|
for (int i = 0; i <= max; i++) {
|
||||||
|
if (station.hierarchyOrderNo == i + 1) {
|
||||||
|
hierarchy[i][i + 1].add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stations.isNotEmpty && hierarchy[0][1].isNotEmpty) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 10),
|
vertical: 8, horizontal: 10),
|
||||||
itemCount: state.stations.length,
|
itemCount: hierarchy[0][1].length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
List<RbacStation> second = [];
|
||||||
|
if (max >= 2) {
|
||||||
|
for (var rbacStation in hierarchy[1][2]) {
|
||||||
|
if (rbacStation.parentStation ==
|
||||||
|
hierarchy[0][1][index].id) {
|
||||||
|
second.add(rbacStation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
@ -182,15 +590,15 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
const CircleAvatar(
|
||||||
child: Text('${index + 1}'),
|
child: Text('1'),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
state.stations[index]
|
hierarchy[0][1][index]
|
||||||
.stationName!,
|
.stationName!,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
|
@ -205,69 +613,261 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
////SECOND
|
||||||
|
SizedBox(
|
||||||
|
child: second.isNotEmpty
|
||||||
|
? Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: second.map((e) {
|
||||||
|
List<RbacStation> childs = [];
|
||||||
|
if (max >= 3) {
|
||||||
|
for (RbacStation station
|
||||||
|
in hierarchy[2][3]) {
|
||||||
|
if (station.parentStation ==
|
||||||
|
e.id) {
|
||||||
|
childs.add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
childs = [];
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: screenWidth,
|
||||||
|
decoration: box1()
|
||||||
|
.copyWith(
|
||||||
|
boxShadow: []),
|
||||||
|
padding:
|
||||||
|
const EdgeInsets
|
||||||
|
.only(
|
||||||
|
left: 30),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.all(
|
||||||
|
6),
|
||||||
|
child:
|
||||||
|
Text(
|
||||||
|
"2",
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyLarge,
|
||||||
|
selectionColor:
|
||||||
|
Colors.redAccent,
|
||||||
|
)),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 3,
|
width: 12,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
e
|
||||||
|
.stationName!,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium!
|
||||||
|
.copyWith(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: primary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
////THIRD
|
||||||
|
SizedBox(
|
||||||
|
child: childs.isNotEmpty
|
||||||
|
? Column(
|
||||||
|
mainAxisSize:
|
||||||
|
MainAxisSize
|
||||||
|
.min,
|
||||||
|
children: childs
|
||||||
|
.map((e) {
|
||||||
|
List<RbacStation>
|
||||||
|
childs = [];
|
||||||
|
if (max >= 4) {
|
||||||
|
for (RbacStation station
|
||||||
|
in hierarchy[
|
||||||
|
3]
|
||||||
|
[4]) {
|
||||||
|
if (station
|
||||||
|
.parentStation ==
|
||||||
|
e.id) {
|
||||||
|
childs.add(
|
||||||
|
station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
childs = [];
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width:
|
||||||
|
screenWidth,
|
||||||
|
decoration:
|
||||||
|
box1()
|
||||||
|
.copyWith(boxShadow: []),
|
||||||
|
padding: const EdgeInsets
|
||||||
|
.only(
|
||||||
|
left:
|
||||||
|
50),
|
||||||
|
child:
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
child: Text(
|
||||||
|
"3",
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
selectionColor: Colors.redAccent,
|
||||||
|
)),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(e.stationName!, style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500, color: primary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
////Fourth
|
||||||
|
SizedBox(
|
||||||
|
child: childs.isNotEmpty
|
||||||
|
? Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: childs.map((e) {
|
||||||
|
List<RbacStation> childs = [];
|
||||||
|
if (max > 4) {
|
||||||
|
for (RbacStation station in hierarchy[4][5]) {
|
||||||
|
if (station.parentStation == e.id) {
|
||||||
|
childs.add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
childs = [];
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: screenWidth,
|
||||||
|
decoration: box1().copyWith(boxShadow: []),
|
||||||
|
padding: const EdgeInsets.only(left: 80),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
child: Text(
|
||||||
|
"4",
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
selectionColor: Colors.redAccent,
|
||||||
|
)),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(e.stationName!, style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500, color: primary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
////Fifth
|
||||||
|
SizedBox(
|
||||||
|
child: childs.isNotEmpty
|
||||||
|
? Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: childs.map((e) {
|
||||||
|
List<RbacStation> childs = [];
|
||||||
|
if (max > 5) {
|
||||||
|
for (RbacStation station in hierarchy[5][6]) {
|
||||||
|
if (station.parentStation == e.id) {
|
||||||
|
childs.add(station);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
childs = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: screenWidth,
|
||||||
|
decoration: box1(),
|
||||||
|
padding: const EdgeInsets.only(left: 80),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const CircleAvatar(
|
||||||
|
child: Text('5'),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(e.stationName!, style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500, color: primary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
)
|
)
|
||||||
|
: const SizedBox()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
)
|
||||||
|
: const SizedBox()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
)
|
||||||
|
: const SizedBox
|
||||||
|
.shrink()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
)
|
||||||
|
: const SizedBox()),
|
||||||
|
const Divider(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Column(
|
return const EmptyData(
|
||||||
children: [
|
message: "No Station available. Please click + to add.");
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
child: SearchField(
|
|
||||||
|
|
||||||
inputFormatters: [UpperCaseTextFormatter()],
|
|
||||||
itemHeight: 70,
|
|
||||||
focusNode: agencyFocusNode,
|
|
||||||
suggestions: state.agencies
|
|
||||||
.map((Agency agency) =>
|
|
||||||
SearchFieldListItem(agency.name!,
|
|
||||||
item: agency,
|
|
||||||
child: ListTile(
|
|
||||||
title: Text(
|
|
||||||
agency.name!,
|
|
||||||
overflow: TextOverflow.visible,
|
|
||||||
),
|
|
||||||
)))
|
|
||||||
.toList(),
|
|
||||||
searchInputDecoration:
|
|
||||||
normalTextFieldStyle("Filter", "").copyWith(
|
|
||||||
prefixIcon: const Icon(Icons.filter_list),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_drop_down),
|
|
||||||
onPressed: () {
|
|
||||||
agencyFocusNode.unfocus();
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
onSuggestionTap: (agency) {
|
|
||||||
agencyFocusNode.unfocus();
|
|
||||||
selectedAgency = agency.item!;
|
|
||||||
parent.read<StationBloc>().add(
|
|
||||||
FilterStation(agencyId: selectedAgency.id!));
|
|
||||||
},
|
|
||||||
validator: (agency) {
|
|
||||||
if (agency!.isEmpty) {
|
|
||||||
return "This field is required";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
emptyWidget: const Center(
|
|
||||||
child: Text("No result found..."),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
const EmptyData(
|
|
||||||
message:
|
|
||||||
"No Station available. Please click + to add."),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state is StationErrorState) {
|
if (state is StationErrorState) {
|
||||||
|
@ -277,9 +877,7 @@ class RbacStationScreen extends StatelessWidget {
|
||||||
context.read<RoleBloc>().add(GetRoles());
|
context.read<RoleBloc>().add(GetRoles());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (state is StationLoadingState) {
|
|
||||||
return CircularProgressIndicator();
|
|
||||||
}
|
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -204,6 +204,7 @@ class _DashBoardState extends State<DashBoard> {
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
////Station
|
||||||
if (e.object.name == 'Station') {
|
if (e.object.name == 'Station') {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -227,8 +228,13 @@ class _DashBoardState extends State<DashBoard> {
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
|
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => EstPointPersonStationBloc()..add( EstPointPersonGetStations(agencyId: value.areaid!,)),
|
create: (context) => EstPointPersonStationBloc()
|
||||||
child: EstPointPersonStationScreen(agencyId: value!.areaid!,),
|
..add(EstPointPersonGetStations(
|
||||||
|
agencyId: value.areaid!,
|
||||||
|
)),
|
||||||
|
child: EstPointPersonStationScreen(
|
||||||
|
agencyId: value!.areaid!,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
|
|
@ -198,26 +198,15 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.object.name == 'Station') {
|
if (object.object.name == 'Station') {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => StationBloc()
|
create: (context) => StationBloc()
|
||||||
..add(const GetStations(agencyId: 1)),
|
..add(const GetStations(agencyId: 1)),
|
||||||
child: RbacStationScreen(
|
child: const RbacStationScreen(
|
||||||
id: id,
|
agencyId: 1,
|
||||||
),
|
|
||||||
);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (object.object.name == 'Station') {
|
|
||||||
Navigator.push(context, MaterialPageRoute(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return BlocProvider(
|
|
||||||
create: (context) => StationBloc()
|
|
||||||
..add(const GetStations(agencyId: 1)),
|
|
||||||
child: RbacStationScreen(
|
|
||||||
id: id,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -12,6 +12,7 @@ import 'package:unit2/model/utils/position.dart';
|
||||||
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||||
import 'package:unit2/widgets/error_state.dart';
|
import 'package:unit2/widgets/error_state.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 '../../../../model/rbac/station_type.dart';
|
||||||
import '../../../../theme-data.dart/box_shadow.dart';
|
import '../../../../theme-data.dart/box_shadow.dart';
|
||||||
import '../../../../theme-data.dart/btn-style.dart';
|
import '../../../../theme-data.dart/btn-style.dart';
|
||||||
import '../../../../theme-data.dart/colors.dart';
|
import '../../../../theme-data.dart/colors.dart';
|
||||||
|
@ -57,11 +58,13 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
AddLeading(onPressed: () {
|
AddLeading(onPressed: () {
|
||||||
BuildContext parent = context;
|
BuildContext parent = context;
|
||||||
mainParentStations = [];
|
mainParentStations = [];
|
||||||
|
mainParent = stations.isEmpty?true:false;
|
||||||
for (RbacStation station in stations) {
|
for (RbacStation station in stations) {
|
||||||
if (station.hierarchyOrderNo == 1) {
|
if (station.hierarchyOrderNo == 1) {
|
||||||
mainParentStations.add(station);
|
mainParentStations.add(station);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//// Add New Station
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
@ -90,8 +93,8 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
errorText: "This field is required"),
|
errorText: "This field is required"),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 8,
|
height: mainParent?0: 8,
|
||||||
),
|
),
|
||||||
//// selected main parent
|
//// selected main parent
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -132,8 +135,8 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
"This field is required"),
|
"This field is required"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 12,
|
height: mainParent?0: 8,
|
||||||
),
|
),
|
||||||
////parent station
|
////parent station
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -370,7 +373,7 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
id: null,
|
id: null,
|
||||||
stationName: stationName,
|
stationName: stationName,
|
||||||
stationType: selectedStationType,
|
stationType: selectedStationType,
|
||||||
hierarchyOrderNo:
|
hierarchyOrderNo:mainParent?1:
|
||||||
selectedParentStation!
|
selectedParentStation!
|
||||||
.hierarchyOrderNo! +
|
.hierarchyOrderNo! +
|
||||||
1,
|
1,
|
||||||
|
@ -385,15 +388,15 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
privateEntity: null,
|
privateEntity: null,
|
||||||
contactinfoid: null),
|
contactinfoid: null),
|
||||||
acronym: acronym,
|
acronym: acronym,
|
||||||
parentStation:
|
parentStation: mainParent?null: selectedParentStation!.id!,
|
||||||
selectedParentStation!.id!,
|
|
||||||
code: code,
|
code: code,
|
||||||
fullcode: fullcode,
|
fullcode: fullcode,
|
||||||
childStationInfo: null,
|
childStationInfo: null,
|
||||||
islocationUnderParent:
|
islocationUnderParent:
|
||||||
isWithinParent,
|
isWithinParent,
|
||||||
mainParentStation:
|
mainParentStation:
|
||||||
selectedMainParentStation!
|
mainParent?null:selectedMainParentStation!
|
||||||
.id!,
|
.id!,
|
||||||
description: description,
|
description: description,
|
||||||
ishospital: isHospital,
|
ishospital: isHospital,
|
||||||
|
@ -489,12 +492,14 @@ class EstPointPersonStationScreen extends StatelessWidget {
|
||||||
itemCount: hierarchy[0][1].length,
|
itemCount: hierarchy[0][1].length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
List<RbacStation> second = [];
|
List<RbacStation> second = [];
|
||||||
|
if(max >=2){
|
||||||
for (var rbacStation in hierarchy[1][2]) {
|
for (var rbacStation in hierarchy[1][2]) {
|
||||||
if (rbacStation.parentStation ==
|
if (rbacStation.parentStation ==
|
||||||
hierarchy[0][1][index].id) {
|
hierarchy[0][1][index].id) {
|
||||||
second.add(rbacStation);
|
second.add(rbacStation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import '../../../model/rbac/rbac_station.dart';
|
import '../../../model/rbac/rbac_station.dart';
|
||||||
|
import '../../../model/rbac/station_type.dart';
|
||||||
import '../../../model/roles/pass_check/station_assign_area.dart';
|
import '../../../model/roles/pass_check/station_assign_area.dart';
|
||||||
|
|
||||||
class RbacStationServices {
|
class RbacStationServices {
|
||||||
|
@ -99,12 +100,12 @@ class RbacStationServices {
|
||||||
};
|
};
|
||||||
String path = Url.instance.postStation();
|
String path = Url.instance.postStation();
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
Map body = {
|
Map body = {
|
||||||
"station_name": station.stationName,
|
"station_name": station.stationName,
|
||||||
"acronym": station.acronym,
|
"acronym": station.acronym,
|
||||||
"station_type_id": station.stationType?.id,
|
"station_type_id": station.stationType?.id,
|
||||||
"_station_type_name": station.stationType?.typeName,
|
"_station_type_name": station.stationType?.id != null?null:station.stationType?.typeName,
|
||||||
"parent_station_id": station.parentStation,
|
"parent_station_id": station.parentStation,
|
||||||
"hierarchy_order_no": station.hierarchyOrderNo,
|
"hierarchy_order_no": station.hierarchyOrderNo,
|
||||||
"agency_id": station.governmentAgency!.agencyid,
|
"agency_id": station.governmentAgency!.agencyid,
|
||||||
|
@ -129,9 +130,9 @@ class RbacStationServices {
|
||||||
{'success': false},
|
{'success': false},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// throw e.toString();
|
throw e.toString();
|
||||||
// }
|
}
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue