some edits

pull/2/head
nextwo 3 years ago
parent 3737c3b41c
commit 44654e1e38

@ -115,13 +115,13 @@ class HospitalsProvider extends ChangeNotifier {
} }
} }
Future<List<Hospital>> getHospitalsListByVal({String searchVal=""}) async { Future<List<Hospital>> getHospitalsListByVal({String searchVal = ""}) async {
Response response; Response response;
try { try {
if(searchVal.isNotEmpty) { if (searchVal.isNotEmpty) {
searchVal = "?searchText=$searchVal"; searchVal = "?searchText=$searchVal";
} }
response = await ApiManager.instance.get(URLs.getHospitalsAutoComplete+searchVal); response = await ApiManager.instance.get(URLs.getHospitalsAutoComplete + searchVal);
// response = await get( // response = await get(
// Uri.parse(host + URLs.getHospitals // Uri.parse(host + URLs.getHospitals
// + ( title == null || title.isEmpty ? "" : "?name=$title" )), // + ( title == null || title.isEmpty ? "" : "?name=$title" )),

@ -57,7 +57,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier {
try { try {
// todo request new api from backend to make filter work // todo request new api from backend to make filter work
response = await ApiManager.instance.get( response = await ApiManager.instance.get(
"${URLs.getServiceReportLastCalls}?parentWOId=${woId??id}&isAdd=true&id=${id ?? 0}&typeTransaction=$typeName", "${URLs.getServiceReportLastCalls}?parentWOId=${woId ?? id}&isAdd=true&id=${id ?? 0}&typeTransaction=$typeName",
); );
// response = await get( // response = await get(
// Uri.parse( // Uri.parse(

@ -34,21 +34,21 @@ class Device {
factory Device.fromJson(Map<String, dynamic> parsedJson) { factory Device.fromJson(Map<String, dynamic> parsedJson) {
return Device( return Device(
id: parsedJson["id"], id: parsedJson["id"],
serialNumber: parsedJson["assetSerialNo"], serialNumber: parsedJson["assetSerialNo"],
number: parsedJson["assetNumber"], number: parsedJson["assetNumber"],
modelDefinition: ModelDefinition.fromJson(parsedJson["modelDefinition"]), modelDefinition: ModelDefinition.fromJson(parsedJson["modelDefinition"]),
hospital: Hospital.fromJson(parsedJson["site"]), hospital: Hospital.fromJson(parsedJson["site"]),
destBuildingName: parsedJson["destBuildingName"], destBuildingName: parsedJson["destBuildingName"],
destDepartmentName: parsedJson["destDepartmentName"], destDepartmentName: parsedJson["destDepartmentName"],
destRoom: parsedJson["destRoom"], destRoom: parsedJson["destRoom"],
destFloor: parsedJson["destFloor"], destFloor: parsedJson["destFloor"],
destSiteName:parsedJson['destSiteName'] destSiteName: parsedJson['destSiteName']
// parsedJson["modelDefinition"] == null ? "" : // parsedJson["modelDefinition"] == null ? "" :
// parsedJson["modelDefinition"]["manufacturerName"], // parsedJson["modelDefinition"]["manufacturerName"],
// model: parsedJson["modelDefinition"] == null ? "" : // model: parsedJson["modelDefinition"] == null ? "" :
// parsedJson["modelDefinition"]["modelName"], // parsedJson["modelDefinition"]["modelName"],
); );
} }
factory Device.fromDevice(Device device) { factory Device.fromDevice(Device device) {

@ -8,9 +8,9 @@ class Engineer {
}); });
factory Engineer.fromJson(Map<String, dynamic> parsedJson) { factory Engineer.fromJson(Map<String, dynamic> parsedJson) {
if(parsedJson==null) return Engineer(); if (parsedJson == null) return Engineer();
return Engineer( return Engineer(
id: parsedJson["userId"] ?? parsedJson["id"], id: parsedJson["userId"] ?? parsedJson["id"],
name: parsedJson["userName"] ?? parsedJson["name"], name: parsedJson["userName"] ?? parsedJson["name"],
); );
} }

@ -1,9 +1,10 @@
class FaultDescription { class FaultDescription {
FaultDescription({ FaultDescription({
this.id, this.id,
this.defectName, this.defectName,
this.workPerformed, this.workPerformed,
this.estimatedTime,}); this.estimatedTime,
});
FaultDescription.fromJson(dynamic json) { FaultDescription.fromJson(dynamic json) {
id = json['id']; id = json['id'];
@ -15,15 +16,18 @@ class FaultDescription {
String defectName; String defectName;
String workPerformed; String workPerformed;
String estimatedTime; String estimatedTime;
FaultDescription copyWith({ num id, FaultDescription copyWith({
String defectName, num id,
String workPerformed, String defectName,
String estimatedTime, String workPerformed,
}) => FaultDescription( id: id ?? this.id, String estimatedTime,
defectName: defectName ?? this.defectName, }) =>
workPerformed: workPerformed ?? this.workPerformed, FaultDescription(
estimatedTime: estimatedTime ?? this.estimatedTime, id: id ?? this.id,
); defectName: defectName ?? this.defectName,
workPerformed: workPerformed ?? this.workPerformed,
estimatedTime: estimatedTime ?? this.estimatedTime,
);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
@ -32,5 +36,4 @@ FaultDescription copyWith({ num id,
map['estimatedTime'] = estimatedTime; map['estimatedTime'] = estimatedTime;
return map; return map;
} }
} }

@ -237,7 +237,6 @@ class Subtitle {
String room; String room;
String actions; String actions;
void setIssues(List<String> issues) { void setIssues(List<String> issues) {
issues.clear(); issues.clear();
issues.add(reason1); issues.add(reason1);

@ -245,7 +245,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
departments: _deviceTransferProvider?.floor?.departments, departments: _deviceTransferProvider?.floor?.departments,
onSelect: (status) { onSelect: (status) {
_deviceTransferProvider.department = status; _deviceTransferProvider.department = status;
_formModel.receiver.department = Department(id: status.id, name: status.name) ; _formModel.receiver.department = Department(id: status.id, name: status.name);
setState(() {}); setState(() {});
}, },
), ),
@ -261,7 +261,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number, textInputType: TextInputType.number,
onSaved: (value) { onSaved: (value) {
_deviceTransferProvider.room=value; _deviceTransferProvider.room = value;
}, },
), ),
12.height, 12.height,

@ -115,14 +115,13 @@ class _LoginState extends State<Login> {
host: _settingProvider.host, host: _settingProvider.host,
); );
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
if(_userProvider.user.isAuthenticated ?? false) { if (_userProvider.user.isAuthenticated ?? false) {
_settingProvider.setUser(_userProvider.user); _settingProvider.setUser(_userProvider.user);
Navigator.of(context).pushNamed(LandPage.id); Navigator.of(context).pushNamed(LandPage.id);
} else { } else {
Fluttertoast.showToast(msg: _userProvider.user.message); Fluttertoast.showToast(msg: _userProvider.user.message);
} }
// if (_userProvider.user.isActive) // if (_userProvider.user.isActive)
// else // else

@ -135,12 +135,10 @@ class _SearchSubWorkOrderPageState extends State<SearchSubWorkOrderPage> {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
HospitalAutoCompleteField( HospitalAutoCompleteField(
initialValue:_site, initialValue: _site,
onSearch: (value) { onSearch: (value) {
_site = value.name; _site = value.name;
setState(() { setState(() {});
});
}, },
), ),
const SizedBox(height: 16), const SizedBox(height: 16),

@ -55,7 +55,9 @@ class _WorkOrderUpdateState extends State<WorkOrderUpdate> {
], ],
), ),
), ),
WorkOrderDetails(item: widget.item,) WorkOrderDetails(
item: widget.item,
)
], ],
), ),
), ),

@ -212,14 +212,14 @@ class _LandPageState extends State<LandPage> {
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
}, },
), ),
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
LandPageItem( LandPageItem(
text: "Search Work Order", text: "Search Work Order",
svgPath: "assets/images/sub_workorder_icon.svg", svgPath: "assets/images/sub_workorder_icon.svg",
onPressed: () { onPressed: () {
Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
}, },
), ),
], ],
), ),
], ],

@ -104,7 +104,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
getRequestForWorkOrder(); getRequestForWorkOrder();
} }
_serviceReport.assetType = _assetTypeProvider.statuses?.firstWhere( _serviceReport.assetType = _assetTypeProvider.statuses?.firstWhere(
(element) => element.value == _callRequestForWorkOrder?.assetType, (element) => element.value == _callRequestForWorkOrder?.assetType,
orElse: () => null, orElse: () => null,
); );
_subtitle = AppLocalization.of(context).subtitle; _subtitle = AppLocalization.of(context).subtitle;
@ -158,15 +158,15 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
widget.request.deviceSerialNumber == null widget.request.deviceSerialNumber == null
? const SizedBox() ? const SizedBox()
: ASubTitle( : ASubTitle(
"${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}", "${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",
font: 14, font: 14,
), ),
Text( Text(
"${_subtitle.customer}: ${widget.request.hospitalName}", "${_subtitle.customer}: ${widget.request.hospitalName}",
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 12,
), ),
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
) )
], ],
@ -226,9 +226,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle(_subtitle.visitDate), ASubTitle(_subtitle.visitDate),
_validate && _serviceReport.visitDate == null _validate && _serviceReport.visitDate == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
Row( Row(
children: [ children: [
@ -262,9 +262,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle(_subtitle.deviceSN), ASubTitle(_subtitle.deviceSN),
_validate && _serviceReport.device?.id == null _validate && _serviceReport.device?.id == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
AutoCompleteDeviceField( AutoCompleteDeviceField(
hospitalId: widget.request.hospitalId, hospitalId: widget.request.hospitalId,
@ -281,9 +281,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle(_subtitle.AssetType), ASubTitle(_subtitle.AssetType),
_validate && _serviceReport.assetType == null _validate && _serviceReport.assetType == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
const SizedBox( const SizedBox(
height: 4, height: 4,
@ -296,7 +296,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_assetTypeProvider.reset(); _assetTypeProvider.reset();
await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host);
_serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere( _serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere(
(element) => element.value == _callRequestForWorkOrder.assetType, (element) => element.value == _callRequestForWorkOrder.assetType,
orElse: () => null, orElse: () => null,
); );
}, },
@ -327,9 +327,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle("Equipment Status"), ASubTitle("Equipment Status"),
_validate && _serviceReport.equipmentStatus == null _validate && _serviceReport.equipmentStatus == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
const SizedBox( const SizedBox(
height: 4, height: 4,
@ -367,9 +367,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle(_subtitle.callLastSituation), ASubTitle(_subtitle.callLastSituation),
_validate && _serviceReport.callLastSituation == null _validate && _serviceReport.callLastSituation == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
const SizedBox(height: 4), const SizedBox(height: 4),
ServiceReportLastCallsMenu( ServiceReportLastCallsMenu(
@ -504,54 +504,54 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_serviceReport.callLastSituation?.value != 12 _serviceReport.callLastSituation?.value != 12
? const SizedBox.shrink() ? const SizedBox.shrink()
: Row( : Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
ASubTitle(_subtitle.invoiceNumber), Expanded(
const SizedBox( child: Column(
height: 8, crossAxisAlignment: CrossAxisAlignment.start,
), children: [
ATextFormField( ASubTitle(_subtitle.invoiceNumber),
initialValue: _serviceReport?.invoiceNumber, const SizedBox(
textAlign: TextAlign.center, height: 8,
style: Theme.of(context).textTheme.subtitle1, ),
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, ATextFormField(
textInputType: TextInputType.number, initialValue: _serviceReport?.invoiceNumber,
onSaved: (value) { textAlign: TextAlign.center,
_serviceReport.invoiceNumber = value; style: Theme.of(context).textTheme.subtitle1,
}, validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value) {
_serviceReport.invoiceNumber = value;
},
),
],
),
), ),
],
),
),
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox( const SizedBox(
height: 4, width: 8,
), ),
ATextFormField( Expanded(
initialValue: _serviceReport?.invoiceCode, child: Column(
textAlign: TextAlign.center, crossAxisAlignment: CrossAxisAlignment.start,
style: Theme.of(context).textTheme.subtitle1, children: [
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, ASubTitle(_subtitle.invoiceCode),
textInputType: TextInputType.text, const SizedBox(
onSaved: (value) { height: 4,
_serviceReport.invoiceCode = value; ),
}, ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.text,
onSaved: (value) {
_serviceReport.invoiceCode = value;
},
),
],
),
), ),
], ],
), ),
),
],
),
// const SizedBox(height: 8,), // const SizedBox(height: 8,),
// Row( // Row(
@ -958,9 +958,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ASubTitle(_subtitle.partNumber), ASubTitle(_subtitle.partNumber),
_validate && _serviceReport.parts == null _validate && _serviceReport.parts == null
? ASubTitle( ? ASubTitle(
_subtitle.requiredWord, _subtitle.requiredWord,
color: Colors.red, color: Colors.red,
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
const SizedBox( const SizedBox(
height: 4, height: 4,

@ -31,8 +31,7 @@ class _FutureServiceReportState extends State<FutureServiceReport> {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle) ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle);
;
return Scaffold( return Scaffold(
body: FutureBuilder<ServiceReport>( body: FutureBuilder<ServiceReport>(
future: ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle), future: ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle),

@ -345,7 +345,7 @@ class RequestDetailsPage extends StatelessWidget {
title: _subtitle.visitDate, title: _subtitle.visitDate,
info: workOrders[index].visitDate, info: workOrders[index].visitDate,
), ),
RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name??""), RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name ?? ""),
RequestInfoRow( RequestInfoRow(
title: _subtitle.assetSN, title: _subtitle.assetSN,
info: workOrders[index].callRequest.asset.assetSerialNo, info: workOrders[index].callRequest.asset.assetSerialNo,

@ -47,19 +47,19 @@ class VisitDetailsPage extends StatelessWidget {
), ),
), ),
if (_userProvider?.user?.type == UsersTypes.engineer) if (_userProvider?.user?.type == UsersTypes.engineer)
AIconButton( AIconButton(
iconData: Icons.edit, iconData: Icons.edit,
color: AColors.white, color: AColors.white,
buttonSize: 42, buttonSize: 42,
backgroundColor: AColors.green, backgroundColor: AColors.green,
onPressed: () async { onPressed: () async {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (_) => EditPentry( builder: (_) => EditPentry(
visit: visit, visit: visit,
pentry: visit.pentry, pentry: visit.pentry,
))); )));
}, },
), ),
SizedBox(width: 42) SizedBox(width: 42)
], ],
), ),

@ -20,7 +20,7 @@ class ADateTimePicker extends StatelessWidget {
), ),
), ),
child: Text( child: Text(
date == null ? "Pick Time" : date.toString().substring(0,date.toString().lastIndexOf(":")), date == null ? "Pick Time" : date.toString().substring(0, date.toString().lastIndexOf(":")),
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
), ),
onPressed: () async { onPressed: () async {

@ -106,7 +106,8 @@ class _SingleDevicePickerState extends State<SingleDevicePicker> {
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,
),ATextFormField( ),
ATextFormField(
hintText: _subtitle.searchBySn, hintText: _subtitle.searchBySn,
controller: snController, controller: snController,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
@ -120,7 +121,6 @@ class _SingleDevicePickerState extends State<SingleDevicePicker> {
_searchableList.addAll(_devicesProvider.devices); _searchableList.addAll(_devicesProvider.devices);
}, },
), ),
], ],
), ),
), ),

@ -44,10 +44,8 @@ class _SingleStatusMenuState extends State<FaultDescriptionMenu> {
@override @override
void initState() { void initState() {
if (widget.initialStatus != null) { if (widget.initialStatus != null) {
final result = widget.statuses?.where((element) { final result = widget.statuses?.where((element) {
return element.id == widget.initialStatus.id; return element.id == widget.initialStatus.id;
}); });
if (result.isNotEmpty) _selectedStatus = result.first; if (result.isNotEmpty) _selectedStatus = result.first;

Loading…
Cancel
Save