document library CR implementation
parent
b9a354d2a2
commit
63d4c79a73
@ -1,30 +1,39 @@
|
||||
class AssetTransferAttachment {
|
||||
AssetTransferAttachment({
|
||||
this.id,
|
||||
this.attachmentName,
|
||||
});
|
||||
|
||||
AssetTransferAttachment.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
attachmentName = json['attachmentName'];
|
||||
}
|
||||
|
||||
num? id; // Now nullable
|
||||
String? attachmentName; // Now nullable
|
||||
|
||||
AssetTransferAttachment copyWith({
|
||||
num? id, // Parameter is now nullable
|
||||
String? attachmentName, // Parameter is now nullable
|
||||
}) =>
|
||||
AssetTransferAttachment(
|
||||
id: id ?? this.id,
|
||||
attachmentName: attachmentName ?? this.attachmentName,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['attachmentName'] = attachmentName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
//TODO: need to remove this class
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// class AssetTransferAttachment {
|
||||
// AssetTransferAttachment({
|
||||
// this.id,
|
||||
// this.attachmentName,
|
||||
// this.documentType,
|
||||
//
|
||||
// });
|
||||
//
|
||||
// AssetTransferAttachment.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// attachmentName = json['attachmentName'];
|
||||
// }
|
||||
//
|
||||
// num? id; // Now nullable
|
||||
// String? attachmentName; // Now nullable
|
||||
// Lookup ? documentType;
|
||||
//
|
||||
// AssetTransferAttachment copyWith({
|
||||
// num? id, // Parameter is now nullable
|
||||
// String? attachmentName, // Parameter is now nullable
|
||||
// Lookup? documentType, // Parameter is now nullable
|
||||
// }) =>
|
||||
// AssetTransferAttachment(
|
||||
// id: id ?? this.id,
|
||||
// attachmentName: attachmentName ?? this.attachmentName,
|
||||
// documentType: documentType ?? this.documentType,
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['attachmentName'] = attachmentName;
|
||||
// map['documentTypeId'] = documentType?.id;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,33 +1,287 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class GenericAttachmentModel {
|
||||
GenericAttachmentModel({this.id, this.name, this.originalName, this.createdBy, this.documentTypeId});
|
||||
GenericAttachmentModel({
|
||||
this.id,
|
||||
this.name,
|
||||
this.originalName,
|
||||
this.createdBy,
|
||||
this.documentType,
|
||||
this.attachmentDescription,
|
||||
this.attachmentURL,
|
||||
this.moduleReferenceId,
|
||||
this.attachmentTypeId,
|
||||
this.createdDate,
|
||||
this.modifiedBy,
|
||||
this.modifiedDate,
|
||||
this.supplierId,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? name;
|
||||
String? createdBy;
|
||||
String? originalName;
|
||||
Lookup? documentTypeId;
|
||||
Lookup? documentType;
|
||||
String? attachmentDescription;
|
||||
String? attachmentURL;
|
||||
num? moduleReferenceId;
|
||||
num? attachmentTypeId;
|
||||
String? createdDate;
|
||||
String? modifiedBy;
|
||||
String? modifiedDate;
|
||||
num? supplierId;
|
||||
|
||||
GenericAttachmentModel.fromJson(Map<String, dynamic> json, {bool convertToLink = false}) {
|
||||
id = json['id'];
|
||||
name = json['name'] ?? json['imageName'];
|
||||
name = json['name'] ?? json['attachmentName'] ?? json['imageName'];
|
||||
createdBy = json['createdBy'];
|
||||
documentType = json['documentType'];
|
||||
originalName = json['originalName'] ?? json['imageOriginalName'];
|
||||
|
||||
if (convertToLink) {
|
||||
name = URLs.getFileUrl(name);
|
||||
}
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromWorkOrderJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
createdBy = json['createdBy'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromLoanJson(Map<String, dynamic> json) {
|
||||
id = json['id']?.toInt();
|
||||
name = json['attachmentName'];
|
||||
attachmentDescription = json['attachmentDescription'];
|
||||
documentType = json['documentType'];
|
||||
moduleReferenceId = json['loanId'];
|
||||
attachmentTypeId = json['loanAttachmentTypeId'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromLoanDetailJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
attachmentDescription = json['attachmentDescription'];
|
||||
moduleReferenceId = json['loanId'];
|
||||
attachmentTypeId = json['loanAttachmentTypeId'];
|
||||
createdBy = json['createdBy'];
|
||||
createdDate = json['createdDate'];
|
||||
modifiedBy = json['modifiedBy'];
|
||||
modifiedDate = json['modifiedDate'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromPpmJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'] ?? json['name'];
|
||||
moduleReferenceId = json['visitId'];
|
||||
attachmentURL = json['attachmentURL'];
|
||||
}
|
||||
GenericAttachmentModel.fromSupplierJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'] ?? json['name'];
|
||||
supplierId = json['supplierId'];
|
||||
moduleReferenceId = json['visitId'];
|
||||
attachmentURL = json['attachmentURL'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromGasRefillJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
moduleReferenceId = json['gasRefillId'];
|
||||
documentType = json['documentType'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromIncidentJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
moduleReferenceId = json['incidentId'];
|
||||
attachmentDescription = json['attachmentDescription'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromAssetTransferJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromDemoJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
originalName = json['originalName'];
|
||||
moduleReferenceId = json['demoRequestId'];
|
||||
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromInternalAuditJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
|
||||
originalName = json['originalName'];
|
||||
createdBy = json['createdBy'];
|
||||
documentType = json['documentType'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromPreventiveVisitJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
documentType = json['documentType'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromAssetJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
attachmentURL = json['attachmentURL'];
|
||||
originalName = json['originalName'];
|
||||
}
|
||||
|
||||
GenericAttachmentModel.fromTrafJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['attachmentName'];
|
||||
moduleReferenceId = json['trafId'];
|
||||
documentType = json['documentType'];
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['createdBy'] = createdBy;
|
||||
data['originalName'] = originalName;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toWorkOrderJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['createdBy'] = createdBy;
|
||||
///TODO need to keep same variable for document type in backend for all modules, currently it is different for different modules
|
||||
if (documentType != null) {
|
||||
data['attachmentTypeId'] = documentType?.id;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toLoanJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['loanId'] = moduleReferenceId;
|
||||
data['loanAttachmentTypeId'] = attachmentTypeId;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
data['attachmentDescription'] = attachmentDescription;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toLoanDetailJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['loanId'] = moduleReferenceId;
|
||||
data['loanAttachmentTypeId'] = attachmentTypeId;
|
||||
data['attachmentDescription'] = attachmentDescription;
|
||||
data['createdBy'] = createdBy;
|
||||
data['createdDate'] = createdDate;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
|
||||
data['modifiedBy'] = modifiedBy;
|
||||
data['modifiedDate'] = modifiedDate;
|
||||
return data;
|
||||
}
|
||||
//TODO need to check where to use this need to verify with backend team.
|
||||
Map<String, dynamic> toPpmJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['visitId'] = moduleReferenceId;
|
||||
data['attachmentName'] = name;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
data['attachmentURL'] = attachmentURL;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toGasRefillJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['gasRefillId'] = moduleReferenceId;
|
||||
data['attachmentName'] = name;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toIncidentJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['incidentId'] = moduleReferenceId;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
data['attachmentDescription'] = attachmentDescription;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toAssetTransferJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDemoJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['demoRequestId'] = moduleReferenceId;
|
||||
data['originalName'] = originalName;
|
||||
if (documentType != null) {
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toInternalAuditJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['originalName'] = originalName;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toPreventiveVisitJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toAssetJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['attachmentName'] = name;
|
||||
data['attachmentURL'] = attachmentURL;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
data['originalName'] = originalName;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toTrafJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['trafId'] = moduleReferenceId;
|
||||
data['attachmentName'] = name;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
return data;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toSupplierJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['supplierId'] = supplierId;
|
||||
data['documentTypeId'] = documentType?.id;
|
||||
data['attachmentName'] = name;
|
||||
data['attachmentURL'] = attachmentURL;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,40 +1,42 @@
|
||||
class PpmAttachments {
|
||||
PpmAttachments({
|
||||
this.id,
|
||||
this.visitId,
|
||||
this.attachmentName,
|
||||
this.attachmentURL,
|
||||
});
|
||||
//TODO need to delete this
|
||||
|
||||
PpmAttachments.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
visitId = json['visitId'];
|
||||
attachmentName = json['attachmentName'] ?? json['attachmentURL']; // Handle potential null and prioritize'attachmentName'
|
||||
}
|
||||
|
||||
num? id; // Now nullable
|
||||
num? visitId; // Now nullable
|
||||
String? attachmentName; // Now nullable
|
||||
String? attachmentURL; // Now nullable
|
||||
|
||||
PpmAttachments copyWith({
|
||||
num? id,
|
||||
num? visitId,
|
||||
String? attachmentName,
|
||||
String? attachmentURL,
|
||||
}) =>
|
||||
PpmAttachments(
|
||||
id: id ?? this.id,
|
||||
visitId: visitId ?? this.visitId,
|
||||
attachmentName: attachmentName ?? this.attachmentName,attachmentURL: attachmentURL ?? this.attachmentURL,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['visitId'] = visitId;
|
||||
map['attachmentName'] = attachmentName;
|
||||
map['attachmentURL'] = attachmentURL;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
// class PpmAttachments {
|
||||
// PpmAttachments({
|
||||
// this.id,
|
||||
// this.visitId,
|
||||
// this.attachmentName,
|
||||
// this.attachmentURL,
|
||||
// });
|
||||
//
|
||||
// PpmAttachments.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// visitId = json['visitId'];
|
||||
// attachmentName = json['attachmentName'] ?? json['attachmentURL']; // Handle potential null and prioritize'attachmentName'
|
||||
// }
|
||||
//
|
||||
// num? id; // Now nullable
|
||||
// num? visitId; // Now nullable
|
||||
// String? attachmentName; // Now nullable
|
||||
// String? attachmentURL; // Now nullable
|
||||
//
|
||||
// PpmAttachments copyWith({
|
||||
// num? id,
|
||||
// num? visitId,
|
||||
// String? attachmentName,
|
||||
// String? attachmentURL,
|
||||
// }) =>
|
||||
// PpmAttachments(
|
||||
// id: id ?? this.id,
|
||||
// visitId: visitId ?? this.visitId,
|
||||
// attachmentName: attachmentName ?? this.attachmentName,attachmentURL: attachmentURL ?? this.attachmentURL,
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['visitId'] = visitId;
|
||||
// map['attachmentName'] = attachmentName;
|
||||
// map['attachmentURL'] = attachmentURL;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
@ -1,31 +1,33 @@
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
//TODO : need to remove this class
|
||||
|
||||
class DemoAttachments {
|
||||
int? id;
|
||||
num? demoRequestId;
|
||||
num? documentTypeId;
|
||||
Lookup? documentType;
|
||||
String? attachmentName;
|
||||
String? originalName;
|
||||
|
||||
DemoAttachments({this.id, this.documentTypeId, this.documentType, this.attachmentName, this.demoRequestId, this.originalName});
|
||||
|
||||
DemoAttachments.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
documentTypeId = json['documentTypeId'];
|
||||
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
|
||||
demoRequestId = json['demoRequestId'];
|
||||
attachmentName = json['attachmentName'];
|
||||
originalName = json['originalName'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['documentTypeId'] = documentTypeId;
|
||||
map['attachmentName'] = attachmentName;
|
||||
map['demoRequestId'] = demoRequestId;
|
||||
map['originalName'] = originalName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// class DemoAttachments {
|
||||
// int? id;
|
||||
// num? demoRequestId;
|
||||
// Lookup? documentType;
|
||||
// String? attachmentName;
|
||||
// String? originalName;
|
||||
//
|
||||
// DemoAttachments({this.id, this.documentType, this.attachmentName, this.demoRequestId, this.originalName});
|
||||
//
|
||||
// DemoAttachments.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
|
||||
// demoRequestId = json['demoRequestId'];
|
||||
// attachmentName = json['attachmentName'];
|
||||
// originalName = json['originalName'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// if(documentType!=null){
|
||||
// map['documentTypeId'] = documentType?.id;
|
||||
// }
|
||||
// map['attachmentName'] = attachmentName;
|
||||
// map['demoRequestId'] = demoRequestId;
|
||||
// map['originalName'] = originalName;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,24 +1,26 @@
|
||||
class IncidentAttachments {
|
||||
num? id;
|
||||
num? incidentId;
|
||||
String? attachmentName;
|
||||
String? attachmentDescription;
|
||||
//TODO : need to delete this
|
||||
|
||||
IncidentAttachments({this.id, this.attachmentName, this.incidentId, this.attachmentDescription});
|
||||
|
||||
IncidentAttachments.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
incidentId = json['incidentId'];
|
||||
attachmentName = json['attachmentName'];
|
||||
attachmentDescription = json['attachmentDescription'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['attachmentName'] = attachmentName;
|
||||
map['incidentId'] = incidentId;
|
||||
map['attachmentDescription'] = attachmentDescription;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
// class IncidentAttachments {
|
||||
// num? id;
|
||||
// num? incidentId;
|
||||
// String? attachmentName;
|
||||
// String? attachmentDescription;
|
||||
//
|
||||
// IncidentAttachments({this.id, this.attachmentName, this.incidentId, this.attachmentDescription});
|
||||
//
|
||||
// IncidentAttachments.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// incidentId = json['incidentId'];
|
||||
// attachmentName = json['attachmentName'];
|
||||
// attachmentDescription = json['attachmentDescription'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['attachmentName'] = attachmentName;
|
||||
// map['incidentId'] = incidentId;
|
||||
// map['attachmentDescription'] = attachmentDescription;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,26 +1,32 @@
|
||||
import 'dart:developer';
|
||||
|
||||
class InternalAuditAttachments {
|
||||
InternalAuditAttachments({this.id, this.originalName, this.name, this.createdBy});
|
||||
|
||||
int? id;
|
||||
String? name;
|
||||
String? originalName;
|
||||
String? createdBy;
|
||||
|
||||
InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
|
||||
originalName = json['originalName'];
|
||||
createdBy = json['createdBy'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['originalName'] = originalName;
|
||||
// data['createdBy'] = createdBy;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
//TODO : need to remove this class.
|
||||
// import 'dart:developer';
|
||||
//
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// class InternalAuditAttachments {
|
||||
// InternalAuditAttachments({this.id, this.originalName, this.name, this.createdBy,this.documentType});
|
||||
//
|
||||
// int? id;
|
||||
// String? name;
|
||||
// String? originalName;
|
||||
// String? createdBy;
|
||||
// Lookup ? documentType;
|
||||
//
|
||||
// InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
|
||||
// originalName = json['originalName'];
|
||||
// createdBy = json['createdBy'];
|
||||
// documentType =json['documentType'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = <String, dynamic>{};
|
||||
// data['id'] = id;
|
||||
// data['name'] = name;
|
||||
// data['originalName'] = originalName;
|
||||
// data['documentTypeId'] = documentType?.id;
|
||||
// // data['createdBy'] = createdBy;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,39 +1,40 @@
|
||||
class LoanAttachmentModel {
|
||||
int? loanId;
|
||||
String? attachmentName;
|
||||
int? loanAttachmentTypeId;
|
||||
String? attachmentDescription;
|
||||
int? id;
|
||||
String? createdBy;
|
||||
String? createdDate;
|
||||
String? modifiedBy;
|
||||
String? modifiedDate;
|
||||
|
||||
LoanAttachmentModel({this.loanId, this.attachmentName, this.loanAttachmentTypeId, this.attachmentDescription, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate});
|
||||
|
||||
LoanAttachmentModel.fromJson(Map<String, dynamic> json) {
|
||||
loanId = json['loanId'];
|
||||
attachmentName = json['attachmentName'];
|
||||
loanAttachmentTypeId = json['loanAttachmentTypeId'];
|
||||
attachmentDescription = json['attachmentDescription'];
|
||||
id = json['id'];
|
||||
createdBy = json['createdBy'];
|
||||
createdDate = json['createdDate'];
|
||||
modifiedBy = json['modifiedBy'];
|
||||
modifiedDate = json['modifiedDate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['loanId'] = this.loanId;
|
||||
data['attachmentName'] = this.attachmentName;
|
||||
data['loanAttachmentTypeId'] = this.loanAttachmentTypeId;
|
||||
data['attachmentDescription'] = this.attachmentDescription;
|
||||
data['id'] = this.id;
|
||||
data['createdBy'] = this.createdBy;
|
||||
data['createdDate'] = this.createdDate;
|
||||
data['modifiedBy'] = this.modifiedBy;
|
||||
data['modifiedDate'] = this.modifiedDate;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
//TODO need to delete this .
|
||||
// class LoanAttachmentModel {
|
||||
// int? loanId;
|
||||
// String? attachmentName;
|
||||
// int? loanAttachmentTypeId;
|
||||
// String? attachmentDescription;
|
||||
// int? id;
|
||||
// String? createdBy;
|
||||
// String? createdDate;
|
||||
// String? modifiedBy;
|
||||
// String? modifiedDate;
|
||||
//
|
||||
// LoanAttachmentModel({this.loanId, this.attachmentName, this.loanAttachmentTypeId, this.attachmentDescription, this.id, this.createdBy, this.createdDate, this.modifiedBy, this.modifiedDate});
|
||||
//
|
||||
// LoanAttachmentModel.fromJson(Map<String, dynamic> json) {
|
||||
// loanId = json['loanId'];
|
||||
// attachmentName = json['attachmentName'];
|
||||
// loanAttachmentTypeId = json['loanAttachmentTypeId'];
|
||||
// attachmentDescription = json['attachmentDescription'];
|
||||
// id = json['id'];
|
||||
// createdBy = json['createdBy'];
|
||||
// createdDate = json['createdDate'];
|
||||
// modifiedBy = json['modifiedBy'];
|
||||
// modifiedDate = json['modifiedDate'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['loanId'] = this.loanId;
|
||||
// data['attachmentName'] = this.attachmentName;
|
||||
// data['loanAttachmentTypeId'] = this.loanAttachmentTypeId;
|
||||
// data['attachmentDescription'] = this.attachmentDescription;
|
||||
// data['id'] = this.id;
|
||||
// data['createdBy'] = this.createdBy;
|
||||
// data['createdDate'] = this.createdDate;
|
||||
// data['modifiedBy'] = this.modifiedBy;
|
||||
// data['modifiedDate'] = this.modifiedDate;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -0,0 +1,346 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.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/device/asset_by_id_model.dart';
|
||||
import 'package:test_sa/models/generic_attachment_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
|
||||
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
||||
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
class AssetDetailsView extends StatefulWidget {
|
||||
final AssetByIdModel assetModel;
|
||||
final VoidCallback onUpload;
|
||||
|
||||
const AssetDetailsView({
|
||||
Key? key,
|
||||
required this.assetModel,
|
||||
required this.onUpload,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AssetDetailsView> createState() => _AssetDetailsViewState();
|
||||
}
|
||||
|
||||
class _AssetDetailsViewState extends State<AssetDetailsView> with SingleTickerProviderStateMixin {
|
||||
late AnimationController _animationController;
|
||||
List<GenericAttachmentModel> attachments = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 1400),
|
||||
vsync: this,
|
||||
);
|
||||
attachments = widget.assetModel.assetAttachments?.whereType<GenericAttachmentModel>().toList() ?? [];
|
||||
_animationController.forward(from: 0.0);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Image animation - fade in with scale
|
||||
final imageAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.4, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final imageScaleAnimation = Tween<double>(begin: 0.92, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.4, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
// Status label animation
|
||||
final statusAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.15, 0.5, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final statusSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.2),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.15, 0.5, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
// Header animation
|
||||
final headerAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.25, 0.6, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final headerSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.2),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.25, 0.6, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
// Details row animation
|
||||
final detailsAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.35, 0.75, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final detailsSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.15),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.35, 0.75, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
// Dates section animation
|
||||
final datesAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.50, 0.9, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final datesSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.15),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.50, 0.9, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
// Description animation (if exists)
|
||||
final descAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.65, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final descSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.65, 1.0, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
final attachmentAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.80, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
final attachmentSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.80, 1.0, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Animated image
|
||||
FadeTransition(
|
||||
opacity: imageAnimation,
|
||||
child: ScaleTransition(
|
||||
scale: imageScaleAnimation,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 159 / 94,
|
||||
child: Container(
|
||||
width: 95,
|
||||
height: 95,
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.neutral30,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(widget.assetModel.assetPhoto != null ? URLs.getFileUrl(widget.assetModel.assetPhoto!)! : "https://www.lasteelcraft.com/images/no-image-available.png"),
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
6.height,
|
||||
// Animated content column
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Status label with animation
|
||||
if (widget.assetModel.commissioningStatus != null)
|
||||
FadeTransition(
|
||||
opacity: statusAnimation,
|
||||
child: SlideTransition(
|
||||
position: statusSlideAnimation,
|
||||
child: StatusLabel(
|
||||
label: widget.assetModel.commissioningStatus!.name,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, widget.assetModel.commissioningStatus!.name!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.assetModel.commissioningStatus!.name!),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.assetModel.commissioningStatus != null) 8.height,
|
||||
|
||||
// Header with animation
|
||||
FadeTransition(
|
||||
opacity: headerAnimation,
|
||||
child: SlideTransition(
|
||||
position: headerSlideAnimation,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 2,
|
||||
children: [
|
||||
InfoHeader16Widget(widget.assetModel.modelDefinition?.assetName?.cleanupWhitespace.capitalizeFirstOfEach ?? "-"),
|
||||
if (context.userProvider.isEngineer && !(widget.assetModel.hasTrainingImageData ?? true))
|
||||
const InfoTextLabelWidget(label: '*Upload Images for this asset', color: AppColor.red30),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
8.height,
|
||||
// Details row with animation
|
||||
FadeTransition(
|
||||
opacity: detailsAnimation,
|
||||
child: SlideTransition(
|
||||
position: detailsSlideAnimation,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InfoTextWidget(label: context.translation.assetNo, value: widget.assetModel.multiAssets!.first.assetNumber, showEmptyValue: true, copyValue: true),
|
||||
InfoTextWidget(label: context.translation.modelName, value: widget.assetModel.modelDefinition!.modelName, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.supplier, value: widget.assetModel.supplier?.suppliername, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.manufacture, value: widget.assetModel.modelDefinition!.manufacturerName, showEmptyValue: true),
|
||||
],
|
||||
).expanded,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InfoTextWidget(label: context.translation.snNo, value: widget.assetModel.multiAssets!.first.assetSerialNo, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.site, value: widget.assetModel.site?.custName?.cleanupWhitespace.capitalizeFirstOfEach, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.building, value: widget.assetModel.building?.name?.cleanupWhitespace.capitalizeFirstOfEach, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.floor, value: widget.assetModel.floor?.name?.cleanupWhitespace.capitalizeFirstOfEach, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.md, value: widget.assetModel.department?.departmentName?.cleanupWhitespace.capitalizeFirstOfEach, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.room, value: widget.assetModel.room?.name?.cleanupWhitespace.capitalizeFirstOfEach, showEmptyValue: true),
|
||||
],
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Divider with animation
|
||||
FadeTransition(
|
||||
opacity: datesAnimation,
|
||||
child: const Divider().defaultStyle(context),
|
||||
),
|
||||
// Dates section with animation
|
||||
FadeTransition(
|
||||
opacity: datesAnimation,
|
||||
child: SlideTransition(
|
||||
position: datesSlideAnimation,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InfoTextWidget(label: context.translation.installationDate, value: widget.assetModel.installationDate?.toAssetDetailsFormat, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.nextPmDate, value: widget.assetModel.nextPMDate?.toAssetDetailsFormat, showEmptyValue: true),
|
||||
InfoTextWidget(label: context.translation.lastPmDate, value: widget.assetModel.lastPMDate?.toAssetDetailsFormat, showEmptyValue: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Description with animation (if exists)
|
||||
if ((widget.assetModel.modelDefinition?.assetDescription ?? "").isNotEmpty) ...[
|
||||
FadeTransition(
|
||||
opacity: descAnimation,
|
||||
child: const Divider().defaultStyle(context),
|
||||
),
|
||||
FadeTransition(
|
||||
opacity: descAnimation,
|
||||
child: SlideTransition(
|
||||
position: descSlideAnimation,
|
||||
child: InfoTextWidget(label: widget.assetModel.modelDefinition!.assetDescription!, showEmptyValue: true, isMsg: true),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
if (attachments.isNotEmpty) ...[
|
||||
FadeTransition(
|
||||
opacity: attachmentAnimation,
|
||||
child: const Divider().defaultStyle(context),
|
||||
),
|
||||
FadeTransition(
|
||||
opacity: attachmentAnimation,
|
||||
child: SlideTransition(
|
||||
position: attachmentSlideAnimation,
|
||||
child: FilesList(images: attachments.map((toElement) => URLs.getFileUrl(toElement.name!) ?? '').toList()),
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context),
|
||||
).expanded,
|
||||
if (context.userProvider.isEngineer && !(widget.assetModel.hasTrainingImageData ?? true))
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: "Upload Images",
|
||||
onPressed: widget.onUpload,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||
|
||||
class AssetDocumentHistoryView extends StatelessWidget {
|
||||
const AssetDocumentHistoryView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<String> dummyDocuments = [
|
||||
'https://picsum.photos/200/300?random=1',
|
||||
'https://picsum.photos/200/300?random=2',
|
||||
'https://picsum.photos/200/300?random=3',
|
||||
'https://picsum.photos/200/300?random=4',
|
||||
'https://picsum.photos/200/300?random=5',
|
||||
];
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||
child: FilesList(
|
||||
showAsListView: true,
|
||||
// itemGap: 12.toScreenHeight,
|
||||
showDownloadButton: true,
|
||||
images: dummyDocuments,
|
||||
).toShadowContainer(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue