asset transfer room model & comment added

main_design2.0
Sikander Saleem 2 years ago
parent 162ebd38be
commit 2932796068

@ -1,6 +1,7 @@
import 'package:test_sa/models/device/supplier.dart';
import 'package:test_sa/models/device/technical_guidance_book.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/room_model.dart';
import '../new_models/building.dart';
import '../new_models/department.dart';
@ -80,7 +81,7 @@ class Asset {
building = json['building'] != null ? Building.fromJson(json['building']) : null;
floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
department = json['department'] != null ? Department.fromJson(json['department']) : null;
room = json['room'];
room = json['room'] != null ? Rooms.fromJson(json['room']) : null;
testsDay = json['testsDay'];
purchasingPrice = json['purchasingPrice'];
nbv = json['nbv'];
@ -136,7 +137,8 @@ class Asset {
Building building;
Floor floor;
Department department;
String room;
Rooms room;
// String room;
num testsDay;
num purchasingPrice;
String nbv;
@ -187,7 +189,7 @@ class Asset {
Building building,
Floor floor,
Department department,
String room,
Rooms room,
num testsDay,
num purchasingPrice,
String nbv,
@ -313,7 +315,10 @@ class Asset {
if (department != null) {
map['department'] = department.toJson();
}
map['room'] = room;
// map['room'] = room;
if (room != null) {
map['room'] = room.toJson();
}
map['testsDay'] = testsDay;
map['purchasingPrice'] = purchasingPrice;
map['nbv'] = nbv;

@ -25,6 +25,7 @@ class AssetTransfer {
this.senderAssignedEmployeeId,
this.senderMachineStatusId,
this.senderComment,
this.comment,
this.senderStartDate,
this.senderEndDate,
this.senderWorkingHours,
@ -88,6 +89,7 @@ class AssetTransfer {
senderAssignedEmployeeId = json['senderAssignedEmployeeId'];
senderMachineStatusId = json['senderMachineStatusId'];
senderComment = json['senderComment'];
comment = json['comment'];
senderStartDate = json['senderStartDate'];
senderEndDate = json['senderEndDate'];
senderWorkingHours = json['senderWorkingHours'];
@ -170,7 +172,7 @@ class AssetTransfer {
num destBuildingId;
num destFloorId;
num destDepartmentId;
String destRoom;
num destRoom;
num senderSiteId;
num senderBuildingId;
num senderFloorId;
@ -179,6 +181,7 @@ class AssetTransfer {
String senderAssignedEmployeeId;
num senderMachineStatusId;
String senderComment;
String comment;
String senderStartDate;
String senderEndDate;
String senderWorkingHours;
@ -234,6 +237,7 @@ class AssetTransfer {
String senderAssignedEmployeeId,
num senderMachineStatusId,
String senderComment,
String comment,
String senderStartDate,
String senderEndDate,
String senderWorkingHours,
@ -297,6 +301,7 @@ class AssetTransfer {
senderAssignedEmployeeId: senderAssignedEmployeeId ?? this.senderAssignedEmployeeId,
senderMachineStatusId: senderMachineStatusId ?? this.senderMachineStatusId,
senderComment: senderComment ?? this.senderComment,
comment: comment ?? this.comment,
senderStartDate: senderStartDate ?? this.senderStartDate,
senderEndDate: senderEndDate ?? this.senderEndDate,
senderWorkingHours: senderWorkingHours ?? this.senderWorkingHours,
@ -360,6 +365,7 @@ class AssetTransfer {
map['senderAssignedEmployeeId'] = senderAssignedEmployeeId;
map['senderMachineStatusId'] = senderMachineStatusId;
map['senderComment'] = senderComment;
map['comment'] = comment;
map['senderStartDate'] = senderStartDate;
map['senderEndDate'] = senderEndDate;
map['senderWorkingHours'] = senderWorkingHours;
@ -427,6 +433,7 @@ class AssetTransfer {
map['senderAssignedEmployeeId'] = senderAssignedEmployeeId;
map['senderMachineStatusId'] = senderMachineStatusId;
map['senderComment'] = senderComment;
map['comment'] = comment;
map['senderStartDate'] = senderStartDate;
map['senderEndDate'] = senderEndDate;
map['senderWorkingHours'] = senderWorkingHours;
@ -468,6 +475,7 @@ class AssetTransfer {
senderAssignedEmployeeId = assetTransfer.senderAssignedEmployeeId;
senderMachineStatusId = assetTransfer.senderMachineStatusId;
senderComment = assetTransfer.senderComment;
comment = assetTransfer.comment;
senderStartDate = assetTransfer.senderStartDate;
senderEndDate = assetTransfer.senderEndDate;
senderWorkingHours = assetTransfer.senderWorkingHours;

@ -1,3 +1,5 @@
import 'package:test_sa/models/new_models/room_model.dart';
import '../base.dart';
class Department extends Base {
@ -5,7 +7,9 @@ class Department extends Base {
this.id,
this.departmentName,
this.departmentCode,
this.departmentId,
this.ntCode,
this.rooms,
}) : super(identifier: id.toString(), name: departmentName);
Department.fromJson(dynamic json) {
@ -14,25 +18,31 @@ class Department extends Base {
departmentName = json['departmentName'] ?? json['name'];
name = departmentName;
departmentCode = json['departmentCode'];
departmentId = json['departmentId'];
ntCode = json['ntCode'];
rooms = <Rooms>[];
if (json['rooms'] != null) {
json['rooms'].forEach((v) {
rooms.add(Rooms.fromJson(v));
});
}
}
num id;
String departmentName;
String departmentCode;
String departmentId;
String ntCode;
Department copyWith({
num id,
String departmentName,
String departmentCode,
String ntCode,
}) =>
Department(
List<Rooms> rooms;
Department copyWith({num id, String departmentName, String departmentCode, String ntCode, List<Rooms> rooms}) => Department(
id: id ?? this.id,
departmentName: departmentName ?? this.departmentName,
departmentCode: departmentCode ?? this.departmentCode,
departmentId: departmentId ?? this.departmentId,
ntCode: ntCode ?? this.ntCode,
rooms: rooms ?? this.rooms,
);
Map<String, dynamic> toJson() {
@ -40,7 +50,11 @@ class Department extends Base {
map['id'] = id;
map['departmentName'] = departmentName;
map['departmentCode'] = departmentCode;
map['departmentId'] = departmentId;
map['ntCode'] = ntCode;
if (rooms != null) {
map['rooms'] = rooms.map((v) => v.toJson()).toList();
}
return map;
}
}

@ -0,0 +1,26 @@
import 'package:test_sa/models/base.dart';
class Rooms extends Base {
int id;
int departmentId;
int clientRoomId;
String roomName;
Rooms({this.id, this.departmentId, this.clientRoomId, this.roomName});
Rooms.fromJson(Map<String, dynamic> json) {
id = json['id'];
departmentId = json['departmentId'];
clientRoomId = json['clientRoomId'];
roomName = json['roomName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['departmentId'] = this.departmentId;
data['clientRoomId'] = this.clientRoomId;
data['roomName'] = this.roomName;
return data;
}
}

@ -78,6 +78,12 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
_buildTextWidget('${context.translation.assetNumber} : ${_model?.assetNumber ?? ""}'),
_buildTextWidget('${context.translation.model} : ${_model?.modelName ?? ""}'),
_buildTextWidget('${context.translation.sn} : ${_model?.assetSerialNo ?? ""}'),
if ((_model?.comment ?? "").isNotEmpty) ...[
8.height,
const Divider().defaultStyle(context),
8.height,
_buildTextWidget(_model?.comment),
]
],
),
8.height,
@ -195,7 +201,6 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
if ((_userProvider.user?.type == UsersTypes.engineer))
if (isCurrentEngineerEligibleForEdit && !isCurrentRequestCompletedOrClosed)
// if (isSender
// ? (!(_model?.senderMachineStatusName?.toLowerCase()?.contains("close") ?? false) && !(_model?.senderMachineStatusName?.toLowerCase()?.contains("complete") ?? false))
// : (!(_model?.receiverMachineStatusName?.toLowerCase()?.contains("close") ?? false) && !(_model?.receiverMachineStatusName?.toLowerCase()?.contains("complete") ?? false)))

@ -12,6 +12,7 @@ import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/device/asset_transfer.dart';
import 'package:test_sa/models/new_models/department.dart';
import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/room_model.dart';
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import '../../../models/new_models/building.dart';
@ -55,6 +56,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
_transferModel.destBuildingId = _assetDestination.building?.id;
_transferModel.destFloorId = _assetDestination.floor?.id;
_transferModel.destDepartmentId = _assetDestination.department?.id;
_transferModel.destRoom = _assetDestination.room?.clientRoomId;
if (!_formKey.currentState.validate() || !(await _transferModel.validate(context))) {
return;
}
@ -159,23 +161,24 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
},
),
8.height,
// SingleItemDropDownMenu<Department, NullableLoadingProvider>(
// context: context,
// title: context.translation.room,
// initialValue: _assetDestination?.department,
// enabled: _assetDestination?.floor?.departments?.isNotEmpty ?? false,
// staticData: _assetDestination?.floor?.departments ?? [],
// onSelect: (value) {
// _assetDestination?.department = value;
// },
// ),
8.height,
AppTextFormField(
labelText: context.translation.room,
onSaved: (text) {
_transferModel.destRoom = text;
SingleItemDropDownMenu<Rooms, NullableLoadingProvider>(
context: context,
title: context.translation.room,
initialValue: _assetDestination?.room,
enabled: _assetDestination?.department?.rooms?.isNotEmpty ?? false,
staticData: _assetDestination?.department?.rooms ?? [],
onSelect: (value) {
_assetDestination?.room = value;
_transferModel.destRoom = value.clientRoomId;
},
),
8.height,
// AppTextFormField(
// labelText: context.translation.room,
// onSaved: (text) {
// _transferModel.destRoom = text;
// },
// ),
16.height,
context.translation.comments.heading5(context),
8.height,
@ -183,7 +186,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
controller: _commentsController,
labelText: context.translation.comments,
onSaved: (text) {
_transferModel.senderComment = text;
_transferModel.comment = text;
},
),
100.height,

Loading…
Cancel
Save