recurrent task api integrated
parent
ed1337e16d
commit
99bcae1dc2
@ -0,0 +1,346 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/timer_model.dart';
|
||||
|
||||
class RecurrentWo {
|
||||
RecurrentWoData? recurrentWoData;
|
||||
String? message;
|
||||
String? title;
|
||||
String? innerMessage;
|
||||
int? responseCode;
|
||||
bool? isSuccess;
|
||||
|
||||
RecurrentWo(
|
||||
{this.recurrentWoData,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess});
|
||||
|
||||
RecurrentWo.fromJson(Map<String, dynamic> json) {
|
||||
recurrentWoData = json['data'] != null ? RecurrentWoData.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
title = json['title'];
|
||||
innerMessage = json['innerMessage'];
|
||||
responseCode = json['responseCode'];
|
||||
isSuccess = json['isSuccess'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (recurrentWoData != null) {
|
||||
data['data'] = recurrentWoData!.toJson();
|
||||
}
|
||||
data['message'] = message;
|
||||
data['title'] = title;
|
||||
data['innerMessage'] = innerMessage;
|
||||
data['responseCode'] = responseCode;
|
||||
data['isSuccess'] = isSuccess;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RecurrentWoData {
|
||||
int? id;
|
||||
Engineer? engineer;
|
||||
String? scheduleDate;
|
||||
Status? status;
|
||||
Site? site;
|
||||
Lookup? building;
|
||||
Lookup? floor;
|
||||
Lookup? department;
|
||||
Lookup? room;
|
||||
List<PlanRecurrentMedicalTaskRooms>? planRecurrentMedicalTaskRooms;
|
||||
List<Null>? planRecurrentTaskTimers;
|
||||
TimerModel? recurrentWoTimerModel = TimerModel();
|
||||
|
||||
RecurrentWoData(
|
||||
{this.id,
|
||||
this.engineer,
|
||||
this.scheduleDate,
|
||||
this.status,
|
||||
this.site,
|
||||
this.building,
|
||||
this.recurrentWoTimerModel,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.room,
|
||||
this.planRecurrentMedicalTaskRooms,
|
||||
this.planRecurrentTaskTimers});
|
||||
|
||||
RecurrentWoData.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
engineer = json['engineer'] != null
|
||||
? new Engineer.fromJson(json['engineer'])
|
||||
: null;
|
||||
scheduleDate = json['scheduleDate'];
|
||||
status =
|
||||
json['status'] != null ? Status.fromJson(json['status']) : null;
|
||||
site = json['site'] != null ? Site.fromJson(json['site']) : null;
|
||||
building= json["building"] == null ? null : Lookup.fromJson(json["building"]);
|
||||
floor= json["floor"] == null ? null : Lookup.fromJson(json["floor"]);
|
||||
department= json["department"] == null ? null : Lookup.fromJson(json["department"]);
|
||||
room= json["room"] == null ? null : Lookup.fromJson(json["room"]);
|
||||
if (json['planRecurrentMedicalTaskRooms'] != null) {
|
||||
planRecurrentMedicalTaskRooms = <PlanRecurrentMedicalTaskRooms>[];
|
||||
json['planRecurrentMedicalTaskRooms'].forEach((v) {
|
||||
planRecurrentMedicalTaskRooms!
|
||||
.add(PlanRecurrentMedicalTaskRooms.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['planRecurrentTaskTimers'] != null) {
|
||||
//TODO match with exact data and replace...
|
||||
// planRecurrentTaskTimers = <Null>[];
|
||||
// json['planRecurrentTaskTimers'].forEach((v) {
|
||||
// planRecurrentTaskTimers!.add(new Null.fromJson(v));
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
if (engineer != null) {
|
||||
data['engineer'] = engineer!.toJson();
|
||||
}
|
||||
data['scheduleDate'] = scheduleDate;
|
||||
if (status != null) {
|
||||
data['status'] = status!.toJson();
|
||||
}
|
||||
if (site != null) {
|
||||
data['site'] = site!.toJson();
|
||||
}
|
||||
|
||||
if (planRecurrentMedicalTaskRooms != null) {
|
||||
data['planRecurrentMedicalTaskRooms'] =
|
||||
planRecurrentMedicalTaskRooms!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (planRecurrentTaskTimers != null) {
|
||||
//TODO match with exact data and replace...
|
||||
// data['planRecurrentTaskTimers'] =
|
||||
// this.planRecurrentTaskTimers!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Engineer {
|
||||
String? userId;
|
||||
String? userName;
|
||||
String? email;
|
||||
String? employeeId;
|
||||
int? languageId;
|
||||
|
||||
Engineer(
|
||||
{this.userId,
|
||||
this.userName,
|
||||
this.email,
|
||||
this.employeeId,
|
||||
this.languageId});
|
||||
|
||||
Engineer.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['userId'];
|
||||
userName = json['userName'];
|
||||
email = json['email'];
|
||||
employeeId = json['employeeId'];
|
||||
languageId = json['languageId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userId'] = this.userId;
|
||||
data['userName'] = this.userName;
|
||||
data['email'] = this.email;
|
||||
data['employeeId'] = this.employeeId;
|
||||
data['languageId'] = this.languageId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Status {
|
||||
int? id;
|
||||
String? name;
|
||||
int? value;
|
||||
|
||||
Status({this.id, this.name, this.value});
|
||||
|
||||
Status.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
data['value'] = this.value;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Site {
|
||||
int? id;
|
||||
String? siteName;
|
||||
|
||||
Site({this.id, this.siteName});
|
||||
|
||||
Site.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
siteName = json['siteName'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['siteName'] = this.siteName;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PlanRecurrentMedicalTaskRooms {
|
||||
int? id;
|
||||
Room? room;
|
||||
List<PlanRecurrentMedicalTaskRoomTabs>? planRecurrentMedicalTaskRoomTabs;
|
||||
|
||||
PlanRecurrentMedicalTaskRooms(
|
||||
{this.id, this.room, this.planRecurrentMedicalTaskRoomTabs});
|
||||
|
||||
PlanRecurrentMedicalTaskRooms.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
room = json['room'] != null ? new Room.fromJson(json['room']) : null;
|
||||
if (json['planRecurrentMedicalTaskRoomTabs'] != null) {
|
||||
planRecurrentMedicalTaskRoomTabs = <PlanRecurrentMedicalTaskRoomTabs>[];
|
||||
json['planRecurrentMedicalTaskRoomTabs'].forEach((v) {
|
||||
planRecurrentMedicalTaskRoomTabs!
|
||||
.add(new PlanRecurrentMedicalTaskRoomTabs.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
if (this.room != null) {
|
||||
data['room'] = this.room!.toJson();
|
||||
}
|
||||
if (this.planRecurrentMedicalTaskRoomTabs != null) {
|
||||
data['planRecurrentMedicalTaskRoomTabs'] = this
|
||||
.planRecurrentMedicalTaskRoomTabs!
|
||||
.map((v) => v.toJson())
|
||||
.toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Room {
|
||||
int? id;
|
||||
String? roomId;
|
||||
|
||||
Room({this.id, this.roomId});
|
||||
|
||||
Room.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
roomId = json['roomId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['roomId'] = this.roomId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PlanRecurrentMedicalTaskRoomTabs {
|
||||
int? id;
|
||||
String? tabName;
|
||||
int? tabMedicalRoomId;
|
||||
List<PlanRecurrentMedicalTaskRoomTabAttributes>?
|
||||
planRecurrentMedicalTaskRoomTabAttributes;
|
||||
|
||||
PlanRecurrentMedicalTaskRoomTabs(
|
||||
{this.id,
|
||||
this.tabName,
|
||||
this.tabMedicalRoomId,
|
||||
this.planRecurrentMedicalTaskRoomTabAttributes});
|
||||
|
||||
PlanRecurrentMedicalTaskRoomTabs.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
tabName = json['tabName'];
|
||||
tabMedicalRoomId = json['tabMedicalRoomId'];
|
||||
if (json['planRecurrentMedicalTaskRoomTabAttributes'] != null) {
|
||||
planRecurrentMedicalTaskRoomTabAttributes =
|
||||
<PlanRecurrentMedicalTaskRoomTabAttributes>[];
|
||||
json['planRecurrentMedicalTaskRoomTabAttributes'].forEach((v) {
|
||||
planRecurrentMedicalTaskRoomTabAttributes!
|
||||
.add(new PlanRecurrentMedicalTaskRoomTabAttributes.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['tabName'] = this.tabName;
|
||||
data['tabMedicalRoomId'] = this.tabMedicalRoomId;
|
||||
if (this.planRecurrentMedicalTaskRoomTabAttributes != null) {
|
||||
data['planRecurrentMedicalTaskRoomTabAttributes'] = this
|
||||
.planRecurrentMedicalTaskRoomTabAttributes!
|
||||
.map((v) => v.toJson())
|
||||
.toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PlanRecurrentMedicalTaskRoomTabAttributes {
|
||||
int? id;
|
||||
Attribute? attribute;
|
||||
Null? attributeValue;
|
||||
|
||||
PlanRecurrentMedicalTaskRoomTabAttributes(
|
||||
{this.id, this.attribute, this.attributeValue});
|
||||
|
||||
PlanRecurrentMedicalTaskRoomTabAttributes.fromJson(
|
||||
Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
attribute = json['attribute'] != null
|
||||
? new Attribute.fromJson(json['attribute'])
|
||||
: null;
|
||||
attributeValue = json['attributeValue'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
if (this.attribute != null) {
|
||||
data['attribute'] = this.attribute!.toJson();
|
||||
}
|
||||
data['attributeValue'] = this.attributeValue;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Attribute {
|
||||
String? name;
|
||||
String? type;
|
||||
String? key;
|
||||
|
||||
Attribute({this.name, this.type, this.key});
|
||||
|
||||
Attribute.fromJson(Map<String, dynamic> json) {
|
||||
name = json['name'];
|
||||
type = json['type'];
|
||||
key = json['key'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['name'] = this.name;
|
||||
data['type'] = this.type;
|
||||
data['key'] = this.key;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/all_requests_and_count_model.dart';
|
||||
import 'package:test_sa/models/ppm/recurrent_wo.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/recurrent_work_order_view.dart';
|
||||
import '../../../../views/widgets/requests/request_status.dart';
|
||||
|
||||
class RecurrentWoItemView extends StatelessWidget {
|
||||
final RequestsDetails? requestDetails;
|
||||
final bool showShadow;
|
||||
|
||||
const RecurrentWoItemView({Key? key, this.requestDetails, this.showShadow = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (requestDetails != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
StatusLabel(
|
||||
label: requestDetails!.priority!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails!.priority!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails!.priority!),
|
||||
),
|
||||
8.width,
|
||||
StatusLabel(
|
||||
label: requestDetails!.status!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails!.status!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails!.status!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(
|
||||
requestDetails!.date?.toServiceRequestCardFormat ?? "",
|
||||
textAlign: TextAlign.end,
|
||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
||||
),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
(requestDetails?.nameOfType ?? context.translation.ppmRequest).heading5(context),
|
||||
8.height,
|
||||
'${context.translation.assetNumber}: ${requestDetails!.assetNo}'.bodyText(context),
|
||||
'${context.translation.assetSN}: ${requestDetails!.assetSN}'.bodyText(context),
|
||||
// '${context.translation.code}: ${request.code}'.bodyText(context),
|
||||
'${context.translation.requestNo}: ${requestDetails!.requestNo}'.bodyText(context),
|
||||
16.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
||||
),
|
||||
4.width,
|
||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
||||
print('data i got is ${requestDetails?.id}');
|
||||
|
||||
RecurrentWo recurrentWo = await Provider.of<AllRequestsProvider>(context,listen:false).getRecurrentWoById(context, id: requestDetails!.id!);
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => RecurrentWorkOrderView( recurrentWo: recurrentWo)));
|
||||
|
||||
});
|
||||
}
|
||||
return SizedBox();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue