create task flow completed
parent
0fdbe8722e
commit
14e55c63e7
@ -0,0 +1,563 @@
|
||||
import 'package:test_sa/models/base.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/building.dart';
|
||||
import 'package:test_sa/models/new_models/floor.dart';
|
||||
import 'package:test_sa/models/new_models/site.dart';
|
||||
import 'package:test_sa/models/new_models/department.dart';
|
||||
import 'package:test_sa/models/new_models/room_model.dart';
|
||||
|
||||
class TaskRequestModel {
|
||||
final Data? data;
|
||||
final String? message;
|
||||
final String? title;
|
||||
final String? innerMessage;
|
||||
final int? responseCode;
|
||||
final bool? isSuccess;
|
||||
|
||||
TaskRequestModel({
|
||||
this.data,
|
||||
this.message,
|
||||
this.title,
|
||||
this.innerMessage,
|
||||
this.responseCode,
|
||||
this.isSuccess,
|
||||
});
|
||||
|
||||
factory TaskRequestModel.fromJson(Map<String, dynamic> json) => TaskRequestModel(
|
||||
data: json['data'] != null ? Data.fromJson(json['data']) : null,
|
||||
message: json['message'],
|
||||
title: json['title'],
|
||||
innerMessage: json['innerMessage'],
|
||||
responseCode: json['responseCode'],
|
||||
isSuccess: json['isSuccess'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'data': data?.toJson(),
|
||||
'message': message,
|
||||
'title': title,
|
||||
'innerMessage': innerMessage,
|
||||
'responseCode': responseCode,
|
||||
'isSuccess': isSuccess,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
final int? id;
|
||||
final String? taskJobNo;
|
||||
final User? userCreated;
|
||||
final List<TaskJobContactPerson>? taskJobContactPersons;
|
||||
final TaskTypeModel? taskType;
|
||||
final TaskJobStatus? taskJobStatus;
|
||||
final dynamic asset;
|
||||
final dynamic site;
|
||||
final dynamic building;
|
||||
final dynamic floor;
|
||||
final dynamic department;
|
||||
final dynamic room;
|
||||
final String? callComment;
|
||||
final List<TaskJobAttachment>? taskJobAttachments;
|
||||
final User? assignedEngineer;
|
||||
final List<dynamic>? taskJobAssistantEmployees;
|
||||
final List<dynamic>? taskJobActivityEngineerTimers;
|
||||
final List<TaskJobHistory>? taskJobHistories;
|
||||
final BuildingData? installationBuilding;
|
||||
final dynamic installationFloor;
|
||||
final dynamic installationDepartment;
|
||||
final String? serialNo;
|
||||
final String? installationDate;
|
||||
final dynamic completedAction;
|
||||
final dynamic impactStatus;
|
||||
final bool? isUserAcknowledge;
|
||||
final dynamic typeOfAlert;
|
||||
final dynamic riskLevel;
|
||||
final dynamic resource;
|
||||
final dynamic actionNeeded;
|
||||
final dynamic alertNo;
|
||||
final String? estimationDeliveryDate;
|
||||
final dynamic reasonOfFSCA;
|
||||
final dynamic correctiveActionDescription;
|
||||
final User? evaluatorUser;
|
||||
|
||||
Data({
|
||||
this.id,
|
||||
this.taskJobNo,
|
||||
this.userCreated,
|
||||
this.taskJobContactPersons,
|
||||
this.taskType,
|
||||
this.taskJobStatus,
|
||||
this.asset,
|
||||
this.site,
|
||||
this.building,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.room,
|
||||
this.callComment,
|
||||
this.taskJobAttachments,
|
||||
this.assignedEngineer,
|
||||
this.taskJobAssistantEmployees,
|
||||
this.taskJobActivityEngineerTimers,
|
||||
this.taskJobHistories,
|
||||
this.installationBuilding,
|
||||
this.installationFloor,
|
||||
this.installationDepartment,
|
||||
this.serialNo,
|
||||
this.installationDate,
|
||||
this.completedAction,
|
||||
this.impactStatus,
|
||||
this.isUserAcknowledge,
|
||||
this.typeOfAlert,
|
||||
this.riskLevel,
|
||||
this.resource,
|
||||
this.actionNeeded,
|
||||
this.alertNo,
|
||||
this.estimationDeliveryDate,
|
||||
this.reasonOfFSCA,
|
||||
this.correctiveActionDescription,
|
||||
this.evaluatorUser,
|
||||
});
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
id: json['id'],
|
||||
taskJobNo: json['taskJobNo'],
|
||||
userCreated: json['userCreated'] != null ? User.fromJson(json['userCreated']) : null,
|
||||
taskJobContactPersons: (json['taskJobContactPersons'] as List?)?.map((e) => TaskJobContactPerson.fromJson(e)).toList(),
|
||||
taskType: json['taskType'] != null ? TaskTypeModel.fromJson(json['taskType']) : null,
|
||||
taskJobStatus: json['taskJobStatus'] != null ? TaskJobStatus.fromJson(json['taskJobStatus']) : null,
|
||||
asset: json['asset'],
|
||||
site: json['site'],
|
||||
building: json['building'],
|
||||
floor: json['floor'],
|
||||
department: json['department'],
|
||||
room: json['room'],
|
||||
callComment: json['callComment'],
|
||||
taskJobAttachments: (json['taskJobAttachments'] as List?)?.map((e) => TaskJobAttachment.fromJson(e)).toList(),
|
||||
assignedEngineer: json['assignedEngineer'] != null ? User.fromJson(json['assignedEngineer']) : null,
|
||||
taskJobAssistantEmployees: json['taskJobAssistantEmployees'],
|
||||
taskJobActivityEngineerTimers: json['taskJobActivityEngineerTimers'],
|
||||
taskJobHistories: (json['taskJobHistories'] as List?)?.map((e) => TaskJobHistory.fromJson(e)).toList(),
|
||||
installationBuilding: json['installationBuilding'] != null ? BuildingData.fromJson(json['installationBuilding']) : null,
|
||||
installationFloor: json['installationFloor'],
|
||||
installationDepartment: json['installationDepartment'],
|
||||
serialNo: json['serialNo'],
|
||||
installationDate: json['installationDate'],
|
||||
completedAction: json['completedAction'],
|
||||
impactStatus: json['impactStatus'],
|
||||
isUserAcknowledge: json['isUserAcknowledge'],
|
||||
typeOfAlert: json['typeOfAlert'],
|
||||
riskLevel: json['riskLevel'],
|
||||
resource: json['resource'],
|
||||
actionNeeded: json['actionNeeded'],
|
||||
alertNo: json['alertNo'],
|
||||
estimationDeliveryDate: json['estimationDeliveryDate'],
|
||||
reasonOfFSCA: json['reasonOfFSCA'],
|
||||
correctiveActionDescription: json['correctiveActionDescription'],
|
||||
evaluatorUser: json['evaluatorUser'] != null ? User.fromJson(json['evaluatorUser']) : null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'taskJobNo': taskJobNo,
|
||||
'userCreated': userCreated?.toJson(),
|
||||
'taskJobContactPersons': taskJobContactPersons?.map((e) => e.toJson()).toList(),
|
||||
'taskType': taskType?.toJson(),
|
||||
'taskJobStatus': taskJobStatus?.toJson(),
|
||||
'asset': asset,
|
||||
'site': site,
|
||||
'building': building,
|
||||
'floor': floor,
|
||||
'department': department,
|
||||
'room': room,
|
||||
'callComment': callComment,
|
||||
'taskJobAttachments': taskJobAttachments?.map((e) => e.toJson()).toList(),
|
||||
'assignedEngineer': assignedEngineer?.toJson(),
|
||||
'taskJobAssistantEmployees': taskJobAssistantEmployees,
|
||||
'taskJobActivityEngineerTimers': taskJobActivityEngineerTimers,
|
||||
'taskJobHistories': taskJobHistories?.map((e) => e.toJson()).toList(),
|
||||
'installationBuilding': installationBuilding?.toJson(),
|
||||
'installationFloor': installationFloor,
|
||||
'installationDepartment': installationDepartment,
|
||||
'serialNo': serialNo,
|
||||
'installationDate': installationDate,
|
||||
'completedAction': completedAction,
|
||||
'impactStatus': impactStatus,
|
||||
'isUserAcknowledge': isUserAcknowledge,
|
||||
'typeOfAlert': typeOfAlert,
|
||||
'riskLevel': riskLevel,
|
||||
'resource': resource,
|
||||
'actionNeeded': actionNeeded,
|
||||
'alertNo': alertNo,
|
||||
'estimationDeliveryDate': estimationDeliveryDate,
|
||||
'reasonOfFSCA': reasonOfFSCA,
|
||||
'correctiveActionDescription': correctiveActionDescription,
|
||||
'evaluatorUser': evaluatorUser?.toJson(),
|
||||
};
|
||||
|
||||
Map<String, dynamic> createTaskJson() => {
|
||||
'id': id,
|
||||
'taskJobNo': taskJobNo,
|
||||
'userCreated': userCreated?.toJson(),
|
||||
'taskJobContactPersons': taskJobContactPersons?.map((e) => e.toJson()).toList(),
|
||||
'taskType': taskType?.toJson(),
|
||||
'taskJobStatus': taskJobStatus?.toJson(),
|
||||
'asset': asset,
|
||||
'site': site,
|
||||
'building': building,
|
||||
'floor': floor,
|
||||
'department': department,
|
||||
'room': room,
|
||||
'callComment': callComment,
|
||||
'taskJobAttachments': taskJobAttachments?.map((e) => e.toJson()).toList(),
|
||||
'assignedEngineer': assignedEngineer?.toJson(),
|
||||
'taskJobAssistantEmployees': taskJobAssistantEmployees,
|
||||
'taskJobActivityEngineerTimers': taskJobActivityEngineerTimers,
|
||||
'taskJobHistories': taskJobHistories?.map((e) => e.toJson()).toList(),
|
||||
'installationBuilding': installationBuilding?.toJson(),
|
||||
'installationFloor': installationFloor,
|
||||
'installationDepartment': installationDepartment,
|
||||
'serialNo': serialNo,
|
||||
'installationDate': installationDate,
|
||||
'completedAction': completedAction,
|
||||
'impactStatus': impactStatus,
|
||||
'isUserAcknowledge': isUserAcknowledge,
|
||||
'typeOfAlert': typeOfAlert,
|
||||
'riskLevel': riskLevel,
|
||||
'resource': resource,
|
||||
'actionNeeded': actionNeeded,
|
||||
'alertNo': alertNo,
|
||||
'estimationDeliveryDate': estimationDeliveryDate,
|
||||
'reasonOfFSCA': reasonOfFSCA,
|
||||
'correctiveActionDescription': correctiveActionDescription,
|
||||
'evaluatorUser': evaluatorUser?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class User {
|
||||
final String? userId;
|
||||
final String? userName;
|
||||
final String? email;
|
||||
final String? employeeId;
|
||||
final int? languageId;
|
||||
|
||||
User({this.userId, this.userName, this.email, this.employeeId, this.languageId});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
userId: json['userId'],
|
||||
userName: json['userName'],
|
||||
email: json['email'],
|
||||
employeeId: json['employeeId'],
|
||||
languageId: json['languageId'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'userId': userId,
|
||||
'userName': userName,
|
||||
'email': email,
|
||||
'employeeId': employeeId,
|
||||
'languageId': languageId,
|
||||
};
|
||||
}
|
||||
|
||||
class TaskJobContactPerson {
|
||||
final int? id;
|
||||
final User? user;
|
||||
|
||||
TaskJobContactPerson({this.id, this.user});
|
||||
|
||||
factory TaskJobContactPerson.fromJson(Map<String, dynamic> json) => TaskJobContactPerson(
|
||||
id: json['id'],
|
||||
user: json['user'] != null ? User.fromJson(json['user']) : null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'user': user?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class TaskTypeModel {
|
||||
final int? id;
|
||||
final String? typeName;
|
||||
final RelatedTo? relatedTo;
|
||||
final bool? linkWithMultiAssets;
|
||||
final List<dynamic>? taskTypeRoles;
|
||||
final bool? isInstallation;
|
||||
final bool? isRecallAndAlert;
|
||||
|
||||
TaskTypeModel({
|
||||
this.id,
|
||||
this.typeName,
|
||||
this.relatedTo,
|
||||
this.linkWithMultiAssets,
|
||||
this.taskTypeRoles,
|
||||
this.isInstallation,
|
||||
this.isRecallAndAlert,
|
||||
});
|
||||
|
||||
factory TaskTypeModel.fromJson(Map<String, dynamic> json) => TaskTypeModel(
|
||||
id: json['id'],
|
||||
typeName: json['typeName'],
|
||||
relatedTo: json['relatedTo'] != null ? RelatedTo.fromJson(json['relatedTo']) : null,
|
||||
linkWithMultiAssets: json['linkWithMultiAssets'],
|
||||
taskTypeRoles: json['taskTypeRoles'],
|
||||
isInstallation: json['isInstallation'],
|
||||
isRecallAndAlert: json['isRecallAndAlert'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'typeName': typeName,
|
||||
'relatedTo': relatedTo?.toJson(),
|
||||
'linkWithMultiAssets': linkWithMultiAssets,
|
||||
'taskTypeRoles': taskTypeRoles,
|
||||
'isInstallation': isInstallation,
|
||||
'isRecallAndAlert': isRecallAndAlert,
|
||||
};
|
||||
}
|
||||
|
||||
class RelatedTo {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final int? value;
|
||||
|
||||
RelatedTo({this.id, this.name, this.value});
|
||||
|
||||
factory RelatedTo.fromJson(Map<String, dynamic> json) => RelatedTo(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
class TaskJobStatus {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final int? value;
|
||||
|
||||
TaskJobStatus({this.id, this.name, this.value});
|
||||
|
||||
factory TaskJobStatus.fromJson(Map<String, dynamic> json) => TaskJobStatus(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
class TaskJobAttachment {
|
||||
final int? id;
|
||||
final String? name;
|
||||
|
||||
TaskJobAttachment({this.id, this.name});
|
||||
|
||||
factory TaskJobAttachment.fromJson(Map<String, dynamic> json) => TaskJobAttachment(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
class TaskJobHistory {
|
||||
final int? id;
|
||||
final RelatedTo? action;
|
||||
final TaskJobStatus? taskJobStatus;
|
||||
final User? user;
|
||||
final dynamic typeOfAlert;
|
||||
final dynamic riskLevel;
|
||||
final dynamic resource;
|
||||
final dynamic actionNeeded;
|
||||
final User? assignedEmployee;
|
||||
final dynamic alertNo;
|
||||
final String? estimationDeliveryDate;
|
||||
final String? createdDate;
|
||||
final BuildingData? installationBuilding;
|
||||
final dynamic installationFloor;
|
||||
final dynamic installationDepartment;
|
||||
final String? installationDate;
|
||||
final String? serialNo;
|
||||
|
||||
TaskJobHistory({
|
||||
this.id,
|
||||
this.action,
|
||||
this.taskJobStatus,
|
||||
this.user,
|
||||
this.typeOfAlert,
|
||||
this.riskLevel,
|
||||
this.resource,
|
||||
this.actionNeeded,
|
||||
this.assignedEmployee,
|
||||
this.alertNo,
|
||||
this.estimationDeliveryDate,
|
||||
this.createdDate,
|
||||
this.installationBuilding,
|
||||
this.installationFloor,
|
||||
this.installationDepartment,
|
||||
this.installationDate,
|
||||
this.serialNo,
|
||||
});
|
||||
|
||||
factory TaskJobHistory.fromJson(Map<String, dynamic> json) => TaskJobHistory(
|
||||
id: json['id'],
|
||||
action: json['action'] != null ? RelatedTo.fromJson(json['action']) : null,
|
||||
taskJobStatus: json['taskJobStatus'] != null ? TaskJobStatus.fromJson(json['taskJobStatus']) : null,
|
||||
user: json['user'] != null ? User.fromJson(json['user']) : null,
|
||||
typeOfAlert: json['typeOfAlert'],
|
||||
riskLevel: json['riskLevel'],
|
||||
resource: json['resource'],
|
||||
actionNeeded: json['actionNeeded'],
|
||||
assignedEmployee: json['assignedEmployee'] != null ? User.fromJson(json['assignedEmployee']) : null,
|
||||
alertNo: json['alertNo'],
|
||||
estimationDeliveryDate: json['estimationDeliveryDate'],
|
||||
createdDate: json['createdDate'],
|
||||
installationBuilding: json['installationBuilding'] != null ? BuildingData.fromJson(json['installationBuilding']) : null,
|
||||
installationFloor: json['installationFloor'],
|
||||
installationDepartment: json['installationDepartment'],
|
||||
installationDate: json['installationDate'],
|
||||
serialNo: json['serialNo'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'action': action?.toJson(),
|
||||
'taskJobStatus': taskJobStatus?.toJson(),
|
||||
'user': user?.toJson(),
|
||||
'typeOfAlert': typeOfAlert,
|
||||
'riskLevel': riskLevel,
|
||||
'resource': resource,
|
||||
'actionNeeded': actionNeeded,
|
||||
'assignedEmployee': assignedEmployee?.toJson(),
|
||||
'alertNo': alertNo,
|
||||
'estimationDeliveryDate': estimationDeliveryDate,
|
||||
'createdDate': createdDate,
|
||||
'installationBuilding': installationBuilding?.toJson(),
|
||||
'installationFloor': installationFloor,
|
||||
'installationDepartment': installationDepartment,
|
||||
'installationDate': installationDate,
|
||||
'serialNo': serialNo,
|
||||
};
|
||||
}
|
||||
|
||||
class BuildingData {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final int? value;
|
||||
|
||||
BuildingData({this.id, this.name, this.value});
|
||||
|
||||
factory BuildingData.fromJson(Map<String, dynamic> json) => BuildingData(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
value: json['value'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
class AddTaskModel {
|
||||
int? id;
|
||||
int? taskTypeId;
|
||||
List<int>? assetIds = [];
|
||||
Site? site;
|
||||
Building? building;
|
||||
Floor? floor;
|
||||
Department? department;
|
||||
Rooms? room;
|
||||
String? callComment;
|
||||
Lookup? typeOfAlert;
|
||||
Lookup? riskLevel;
|
||||
Lookup? resource;
|
||||
Lookup? actionNeeded;
|
||||
TaskEvaluatorUser? taskEvaluatorUser;
|
||||
String? alertNo;
|
||||
String? estimationDeliveryDate;
|
||||
List<TaskJobAttachment>? attachments;
|
||||
String? reasonOfFSCA;
|
||||
String? correctiveActionDescription;
|
||||
|
||||
AddTaskModel({
|
||||
this.id,
|
||||
this.taskTypeId,
|
||||
this.assetIds,
|
||||
this.site,
|
||||
this.building,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.room,
|
||||
this.callComment,
|
||||
this.typeOfAlert,
|
||||
this.riskLevel,
|
||||
this.resource,
|
||||
this.actionNeeded,
|
||||
this.alertNo,
|
||||
this.estimationDeliveryDate,
|
||||
this.attachments,
|
||||
this.reasonOfFSCA,
|
||||
this.taskEvaluatorUser,
|
||||
this.correctiveActionDescription,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'taskTypeId': taskTypeId,
|
||||
'assetIds': assetIds ?? [],
|
||||
'siteId': site?.id,
|
||||
'buildingId': building?.id,
|
||||
'floorId': floor?.id,
|
||||
'departmentId': department?.id,
|
||||
'roomId': room?.id,
|
||||
'callComment': callComment,
|
||||
'typeOfAlertId': typeOfAlert?.id,
|
||||
'riskLevelId': riskLevel?.id,
|
||||
'resourceId': resource?.id,
|
||||
'actionNeededId': actionNeeded?.id,
|
||||
'alertNo': alertNo,
|
||||
'estimationDeliveryDate': estimationDeliveryDate,
|
||||
'reasonOfFSCA': reasonOfFSCA,
|
||||
'correctiveActionDescription': correctiveActionDescription,
|
||||
'evaluatorUserId': taskEvaluatorUser?.userId,
|
||||
'attachments': attachments?.map((x) => x.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
class TaskEvaluatorUser extends Base {
|
||||
String? userId;
|
||||
String? userName;
|
||||
String? email;
|
||||
String? employeeId;
|
||||
int? languageId;
|
||||
|
||||
TaskEvaluatorUser({this.userId, this.userName, this.email, this.employeeId, this.languageId}) : super(name: userName, identifier: userId?.toString());
|
||||
|
||||
factory TaskEvaluatorUser.fromJson(Map<String, dynamic> json) {
|
||||
return TaskEvaluatorUser(userId: json['userId'], userName: json['userName'], email: json['email'], employeeId: json['employeeId'], languageId: json['languageId']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['userId'] = userId;
|
||||
data['userName'] = userName;
|
||||
data['email'] = email;
|
||||
data['employeeId'] = employeeId;
|
||||
data['languageId'] = languageId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
import 'package:test_sa/models/base.dart';
|
||||
|
||||
class TaskType extends Base{
|
||||
final int? id;
|
||||
final String? typeName;
|
||||
final RelatedTo? relatedTo;
|
||||
final bool? linkWithMultiAssets;
|
||||
final List<TaskTypeRole>? taskTypeRoles;
|
||||
final bool? isInstallation;
|
||||
final bool? isRecallAndAlert;
|
||||
|
||||
TaskType({
|
||||
this.id,
|
||||
this.typeName,
|
||||
this.relatedTo,
|
||||
this.linkWithMultiAssets,
|
||||
this.taskTypeRoles,
|
||||
this.isInstallation,
|
||||
this.isRecallAndAlert,
|
||||
}): super(name: typeName, identifier: id?.toString());
|
||||
|
||||
factory TaskType.fromJson(Map<String, dynamic> json) {
|
||||
return TaskType(
|
||||
id: json['id'] as int?,
|
||||
typeName: json['typeName'] as String?,
|
||||
relatedTo: json['relatedTo'] != null
|
||||
? RelatedTo.fromJson(json['relatedTo'])
|
||||
: null,
|
||||
linkWithMultiAssets: json['linkWithMultiAssets'] as bool?,
|
||||
taskTypeRoles: (json['taskTypeRoles'] as List<dynamic>?)
|
||||
?.map((e) => TaskTypeRole.fromJson(e))
|
||||
.toList(),
|
||||
isInstallation: json['isInstallation'] as bool?,
|
||||
isRecallAndAlert: json['isRecallAndAlert'] as bool?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RelatedTo {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final int? value;
|
||||
|
||||
RelatedTo({
|
||||
this.id,
|
||||
this.name,
|
||||
this.value,
|
||||
});
|
||||
|
||||
factory RelatedTo.fromJson(Map<String, dynamic> json) {
|
||||
return RelatedTo(
|
||||
id: json['id'] as int?,
|
||||
name: json['name'] as String?,
|
||||
value: json['value'] as int?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TaskTypeRole {
|
||||
final String? roleId;
|
||||
final String? roleName;
|
||||
final String? roleValue;
|
||||
|
||||
TaskTypeRole({
|
||||
this.roleId,
|
||||
this.roleName,
|
||||
this.roleValue,
|
||||
});
|
||||
|
||||
factory TaskTypeRole.fromJson(Map<String, dynamic> json) {
|
||||
return TaskTypeRole(
|
||||
roleId: json['roleId'] as String?,
|
||||
roleName: json['roleName'] as String?,
|
||||
roleValue: json['roleValue'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/task_request/task_request_model.dart';
|
||||
import 'package:test_sa/models/new_models/task_request/task_type_model.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
|
||||
|
||||
class TaskTypeProvider extends LoadingListNotifier<TaskType> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
print('get data called...');
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getTaskTypeByUserUrl);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => TaskType.fromJson(item)).toList();
|
||||
print('item lenght i got is ${items.length}');
|
||||
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
class TaskEvaluatorUserProvider extends LoadingListNotifier<TaskEvaluatorUser> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getTaskEvaluatorUser);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
List userListJson = json.decode(response.body);
|
||||
|
||||
items = userListJson.map((item) => TaskEvaluatorUser.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TaskJobTypeOfAlertProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.taskJobTypeOfAlert);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
class TaskJobRiskLevelProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.taskJobRiskLevel);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
class TaskJobResourceProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.taskJobResource);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
class TaskJobActionNeededProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.taskJobActionNeeded);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/new_models/task_request/task_request_model.dart';
|
||||
import 'package:test_sa/models/new_models/task_request/task_type_model.dart';
|
||||
import 'package:test_sa/models/service_request/pending_service_request_model.dart';
|
||||
import 'package:test_sa/models/service_request/service_report.dart';
|
||||
import 'package:test_sa/models/service_request/service_request.dart';
|
||||
import 'package:test_sa/models/service_request/service_request_search.dart';
|
||||
import 'package:test_sa/models/service_request/spare_parts.dart';
|
||||
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
|
||||
import 'package:test_sa/models/service_request/supplier_engineer_model.dart';
|
||||
import 'package:test_sa/models/timer_model.dart';
|
||||
|
||||
import '../../models/service_request/search_work_order.dart';
|
||||
import '../../models/service_request/wo_call_request.dart';
|
||||
import '../../models/user.dart';
|
||||
import '../../new_views/common_widgets/app_lazy_loading.dart';
|
||||
|
||||
class TaskRequestProvider extends ChangeNotifier {
|
||||
// number of items call in each request
|
||||
final pageItemNumber = 10;
|
||||
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int? stateCode;
|
||||
|
||||
|
||||
bool isLoading = false;
|
||||
|
||||
|
||||
|
||||
Future<void> addTask({
|
||||
required BuildContext context,
|
||||
required AddTaskModel task,
|
||||
}) async {
|
||||
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.post(URLs.addTaskUrl, body: task.toJson());
|
||||
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
notifyListeners();
|
||||
Fluttertoast.showToast(msg: context.translation.successfulRequestMessage);
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
Fluttertoast.showToast(msg: "${context.translation.failedRequestMessage} :${json.decode(response.body)['message']}");
|
||||
}
|
||||
Navigator.pop(context);
|
||||
} catch (error) {
|
||||
print(error);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue