From 44654e1e380f013eb0a500c74d4b17f755eb0e4f Mon Sep 17 00:00:00 2001 From: nextwo <1234> Date: Tue, 11 Jul 2023 14:53:14 +0300 Subject: [PATCH] some edits --- .../providers/api/hospitals_provider.dart | 6 +- .../service_report_last_calls_provider.dart | 2 +- lib/models/device/device.dart | 30 ++-- lib/models/engineer.dart | 4 +- lib/models/fault_description.dart | 33 +++-- lib/models/subtitle.dart | 1 - .../request_device_transfer.dart | 4 +- lib/views/pages/login.dart | 3 +- .../search_sub_workorder_page.dart | 6 +- .../pages/sub_workorder/workorder_update.dart | 4 +- lib/views/pages/user/land_page.dart | 16 +-- .../requests/report/edit_service_report.dart | 134 +++++++++--------- .../report/future_service_report.dart | 3 +- .../pages/user/requests/request_details.dart | 2 +- .../pages/user/visits/visit_details.dart | 26 ++-- .../widgets/date_and_time/time_picker.dart | 2 +- .../equipment/single_device_picker.dart | 4 +- .../status/report/fault_desc_menu.dart | 2 - 18 files changed, 140 insertions(+), 142 deletions(-) diff --git a/lib/controllers/providers/api/hospitals_provider.dart b/lib/controllers/providers/api/hospitals_provider.dart index eb9e3ae9..a52a750e 100644 --- a/lib/controllers/providers/api/hospitals_provider.dart +++ b/lib/controllers/providers/api/hospitals_provider.dart @@ -115,13 +115,13 @@ class HospitalsProvider extends ChangeNotifier { } } - Future> getHospitalsListByVal({String searchVal=""}) async { + Future> getHospitalsListByVal({String searchVal = ""}) async { Response response; try { - if(searchVal.isNotEmpty) { + if (searchVal.isNotEmpty) { searchVal = "?searchText=$searchVal"; } - response = await ApiManager.instance.get(URLs.getHospitalsAutoComplete+searchVal); + response = await ApiManager.instance.get(URLs.getHospitalsAutoComplete + searchVal); // response = await get( // Uri.parse(host + URLs.getHospitals // + ( title == null || title.isEmpty ? "" : "?name=$title" )), diff --git a/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart b/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart index 3e4741b9..7551ad57 100644 --- a/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart +++ b/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart @@ -57,7 +57,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier { try { // todo request new api from backend to make filter work 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( // Uri.parse( diff --git a/lib/models/device/device.dart b/lib/models/device/device.dart index 72f9d120..113e928e 100644 --- a/lib/models/device/device.dart +++ b/lib/models/device/device.dart @@ -34,21 +34,21 @@ class Device { factory Device.fromJson(Map parsedJson) { return Device( - id: parsedJson["id"], - serialNumber: parsedJson["assetSerialNo"], - number: parsedJson["assetNumber"], - modelDefinition: ModelDefinition.fromJson(parsedJson["modelDefinition"]), - hospital: Hospital.fromJson(parsedJson["site"]), - destBuildingName: parsedJson["destBuildingName"], - destDepartmentName: parsedJson["destDepartmentName"], - destRoom: parsedJson["destRoom"], - destFloor: parsedJson["destFloor"], - destSiteName:parsedJson['destSiteName'] - // parsedJson["modelDefinition"] == null ? "" : - // parsedJson["modelDefinition"]["manufacturerName"], - // model: parsedJson["modelDefinition"] == null ? "" : - // parsedJson["modelDefinition"]["modelName"], - ); + id: parsedJson["id"], + serialNumber: parsedJson["assetSerialNo"], + number: parsedJson["assetNumber"], + modelDefinition: ModelDefinition.fromJson(parsedJson["modelDefinition"]), + hospital: Hospital.fromJson(parsedJson["site"]), + destBuildingName: parsedJson["destBuildingName"], + destDepartmentName: parsedJson["destDepartmentName"], + destRoom: parsedJson["destRoom"], + destFloor: parsedJson["destFloor"], + destSiteName: parsedJson['destSiteName'] + // parsedJson["modelDefinition"] == null ? "" : + // parsedJson["modelDefinition"]["manufacturerName"], + // model: parsedJson["modelDefinition"] == null ? "" : + // parsedJson["modelDefinition"]["modelName"], + ); } factory Device.fromDevice(Device device) { diff --git a/lib/models/engineer.dart b/lib/models/engineer.dart index ffedca72..e53b0af5 100644 --- a/lib/models/engineer.dart +++ b/lib/models/engineer.dart @@ -8,9 +8,9 @@ class Engineer { }); factory Engineer.fromJson(Map parsedJson) { - if(parsedJson==null) return Engineer(); + if (parsedJson == null) return Engineer(); return Engineer( - id: parsedJson["userId"] ?? parsedJson["id"], + id: parsedJson["userId"] ?? parsedJson["id"], name: parsedJson["userName"] ?? parsedJson["name"], ); } diff --git a/lib/models/fault_description.dart b/lib/models/fault_description.dart index ecc99f7f..4858e55f 100644 --- a/lib/models/fault_description.dart +++ b/lib/models/fault_description.dart @@ -1,9 +1,10 @@ class FaultDescription { FaultDescription({ - this.id, - this.defectName, - this.workPerformed, - this.estimatedTime,}); + this.id, + this.defectName, + this.workPerformed, + this.estimatedTime, + }); FaultDescription.fromJson(dynamic json) { id = json['id']; @@ -15,15 +16,18 @@ class FaultDescription { String defectName; String workPerformed; String estimatedTime; -FaultDescription copyWith({ num id, - String defectName, - String workPerformed, - String estimatedTime, -}) => FaultDescription( id: id ?? this.id, - defectName: defectName ?? this.defectName, - workPerformed: workPerformed ?? this.workPerformed, - estimatedTime: estimatedTime ?? this.estimatedTime, -); + FaultDescription copyWith({ + num id, + String defectName, + String workPerformed, + String estimatedTime, + }) => + FaultDescription( + id: id ?? this.id, + defectName: defectName ?? this.defectName, + workPerformed: workPerformed ?? this.workPerformed, + estimatedTime: estimatedTime ?? this.estimatedTime, + ); Map toJson() { final map = {}; map['id'] = id; @@ -32,5 +36,4 @@ FaultDescription copyWith({ num id, map['estimatedTime'] = estimatedTime; return map; } - -} \ No newline at end of file +} diff --git a/lib/models/subtitle.dart b/lib/models/subtitle.dart index 8a2689ad..09f6a4de 100644 --- a/lib/models/subtitle.dart +++ b/lib/models/subtitle.dart @@ -237,7 +237,6 @@ class Subtitle { String room; String actions; - void setIssues(List issues) { issues.clear(); issues.add(reason1); diff --git a/lib/views/pages/device_transfer/request_device_transfer.dart b/lib/views/pages/device_transfer/request_device_transfer.dart index 3d0cb755..5ec58012 100644 --- a/lib/views/pages/device_transfer/request_device_transfer.dart +++ b/lib/views/pages/device_transfer/request_device_transfer.dart @@ -245,7 +245,7 @@ class _RequestDeviceTransferState extends State { departments: _deviceTransferProvider?.floor?.departments, onSelect: (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(() {}); }, ), @@ -261,7 +261,7 @@ class _RequestDeviceTransferState extends State { validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", textInputType: TextInputType.number, onSaved: (value) { - _deviceTransferProvider.room=value; + _deviceTransferProvider.room = value; }, ), 12.height, diff --git a/lib/views/pages/login.dart b/lib/views/pages/login.dart index e77b67da..a6fba23d 100644 --- a/lib/views/pages/login.dart +++ b/lib/views/pages/login.dart @@ -115,14 +115,13 @@ class _LoginState extends State { host: _settingProvider.host, ); if (status >= 200 && status < 300) { - if(_userProvider.user.isAuthenticated ?? false) { + if (_userProvider.user.isAuthenticated ?? false) { _settingProvider.setUser(_userProvider.user); Navigator.of(context).pushNamed(LandPage.id); } else { Fluttertoast.showToast(msg: _userProvider.user.message); } - // if (_userProvider.user.isActive) // else diff --git a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart index 73d4618f..32fcec04 100644 --- a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart @@ -135,12 +135,10 @@ class _SearchSubWorkOrderPageState extends State { ), const SizedBox(height: 16), HospitalAutoCompleteField( - initialValue:_site, + initialValue: _site, onSearch: (value) { _site = value.name; - setState(() { - - }); + setState(() {}); }, ), const SizedBox(height: 16), diff --git a/lib/views/pages/sub_workorder/workorder_update.dart b/lib/views/pages/sub_workorder/workorder_update.dart index 9d9c5d6b..3970aeaa 100644 --- a/lib/views/pages/sub_workorder/workorder_update.dart +++ b/lib/views/pages/sub_workorder/workorder_update.dart @@ -55,7 +55,9 @@ class _WorkOrderUpdateState extends State { ], ), ), - WorkOrderDetails(item: widget.item,) + WorkOrderDetails( + item: widget.item, + ) ], ), ), diff --git a/lib/views/pages/user/land_page.dart b/lib/views/pages/user/land_page.dart index e6e9d608..3aa625e1 100644 --- a/lib/views/pages/user/land_page.dart +++ b/lib/views/pages/user/land_page.dart @@ -212,14 +212,14 @@ class _LandPageState extends State { Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); }, ), - if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) - LandPageItem( - text: "Search Work Order", - svgPath: "assets/images/sub_workorder_icon.svg", - onPressed: () { - Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); - }, - ), + if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) + LandPageItem( + text: "Search Work Order", + svgPath: "assets/images/sub_workorder_icon.svg", + onPressed: () { + Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); + }, + ), ], ), ], diff --git a/lib/views/pages/user/requests/report/edit_service_report.dart b/lib/views/pages/user/requests/report/edit_service_report.dart index b0cc2bc4..7cd53f7a 100644 --- a/lib/views/pages/user/requests/report/edit_service_report.dart +++ b/lib/views/pages/user/requests/report/edit_service_report.dart @@ -104,7 +104,7 @@ class _EditServiceReportState extends State with TickerProvid getRequestForWorkOrder(); } _serviceReport.assetType = _assetTypeProvider.statuses?.firstWhere( - (element) => element.value == _callRequestForWorkOrder?.assetType, + (element) => element.value == _callRequestForWorkOrder?.assetType, orElse: () => null, ); _subtitle = AppLocalization.of(context).subtitle; @@ -158,15 +158,15 @@ class _EditServiceReportState extends State with TickerProvid widget.request.deviceSerialNumber == null ? const SizedBox() : ASubTitle( - "${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}", - font: 14, - ), + "${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}", + font: 14, + ), Text( "${_subtitle.customer}: ${widget.request.hospitalName}", style: Theme.of(context).textTheme.subtitle1.copyWith( - fontWeight: FontWeight.bold, - fontSize: 12, - ), + fontWeight: FontWeight.bold, + fontSize: 12, + ), textScaleFactor: AppStyle.getScaleFactor(context), ) ], @@ -226,9 +226,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle(_subtitle.visitDate), _validate && _serviceReport.visitDate == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), Row( children: [ @@ -262,9 +262,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle(_subtitle.deviceSN), _validate && _serviceReport.device?.id == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), AutoCompleteDeviceField( hospitalId: widget.request.hospitalId, @@ -281,9 +281,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle(_subtitle.AssetType), _validate && _serviceReport.assetType == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), const SizedBox( height: 4, @@ -296,7 +296,7 @@ class _EditServiceReportState extends State with TickerProvid _assetTypeProvider.reset(); await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); _serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere( - (element) => element.value == _callRequestForWorkOrder.assetType, + (element) => element.value == _callRequestForWorkOrder.assetType, orElse: () => null, ); }, @@ -327,9 +327,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle("Equipment Status"), _validate && _serviceReport.equipmentStatus == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), const SizedBox( height: 4, @@ -367,9 +367,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle(_subtitle.callLastSituation), _validate && _serviceReport.callLastSituation == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), const SizedBox(height: 4), ServiceReportLastCallsMenu( @@ -504,54 +504,54 @@ class _EditServiceReportState extends State with TickerProvid _serviceReport.callLastSituation?.value != 12 ? const SizedBox.shrink() : Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.invoiceNumber), - const SizedBox( - height: 8, - ), - ATextFormField( - initialValue: _serviceReport?.invoiceNumber, - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle1, - validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, - textInputType: TextInputType.number, - onSaved: (value) { - _serviceReport.invoiceNumber = value; - }, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.invoiceNumber), + const SizedBox( + height: 8, + ), + ATextFormField( + initialValue: _serviceReport?.invoiceNumber, + textAlign: TextAlign.center, + 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( - height: 4, + width: 8, ), - 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; - }, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.invoiceCode), + const SizedBox( + height: 4, + ), + 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,), // Row( @@ -958,9 +958,9 @@ class _EditServiceReportState extends State with TickerProvid ASubTitle(_subtitle.partNumber), _validate && _serviceReport.parts == null ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) + _subtitle.requiredWord, + color: Colors.red, + ) : const SizedBox.shrink(), const SizedBox( height: 4, diff --git a/lib/views/pages/user/requests/report/future_service_report.dart b/lib/views/pages/user/requests/report/future_service_report.dart index c391b669..cb39a6e3 100644 --- a/lib/views/pages/user/requests/report/future_service_report.dart +++ b/lib/views/pages/user/requests/report/future_service_report.dart @@ -31,8 +31,7 @@ class _FutureServiceReportState extends State { _userProvider = Provider.of(context); _settingProvider = Provider.of(context); 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( body: FutureBuilder( future: ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle), diff --git a/lib/views/pages/user/requests/request_details.dart b/lib/views/pages/user/requests/request_details.dart index cfe8ec93..18b4700f 100644 --- a/lib/views/pages/user/requests/request_details.dart +++ b/lib/views/pages/user/requests/request_details.dart @@ -345,7 +345,7 @@ class RequestDetailsPage extends StatelessWidget { title: _subtitle.visitDate, info: workOrders[index].visitDate, ), - RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name??""), + RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name ?? ""), RequestInfoRow( title: _subtitle.assetSN, info: workOrders[index].callRequest.asset.assetSerialNo, diff --git a/lib/views/pages/user/visits/visit_details.dart b/lib/views/pages/user/visits/visit_details.dart index a787be18..73cb60d4 100644 --- a/lib/views/pages/user/visits/visit_details.dart +++ b/lib/views/pages/user/visits/visit_details.dart @@ -47,19 +47,19 @@ class VisitDetailsPage extends StatelessWidget { ), ), if (_userProvider?.user?.type == UsersTypes.engineer) - AIconButton( - iconData: Icons.edit, - color: AColors.white, - buttonSize: 42, - backgroundColor: AColors.green, - onPressed: () async { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => EditPentry( - visit: visit, - pentry: visit.pentry, - ))); - }, - ), + AIconButton( + iconData: Icons.edit, + color: AColors.white, + buttonSize: 42, + backgroundColor: AColors.green, + onPressed: () async { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => EditPentry( + visit: visit, + pentry: visit.pentry, + ))); + }, + ), SizedBox(width: 42) ], ), diff --git a/lib/views/widgets/date_and_time/time_picker.dart b/lib/views/widgets/date_and_time/time_picker.dart index 036766e4..63648225 100644 --- a/lib/views/widgets/date_and_time/time_picker.dart +++ b/lib/views/widgets/date_and_time/time_picker.dart @@ -20,7 +20,7 @@ class ADateTimePicker extends StatelessWidget { ), ), 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), ), onPressed: () async { diff --git a/lib/views/widgets/equipment/single_device_picker.dart b/lib/views/widgets/equipment/single_device_picker.dart index 2fdecf87..722d2f21 100644 --- a/lib/views/widgets/equipment/single_device_picker.dart +++ b/lib/views/widgets/equipment/single_device_picker.dart @@ -106,7 +106,8 @@ class _SingleDevicePickerState extends State { ), const SizedBox( height: 8, - ),ATextFormField( + ), + ATextFormField( hintText: _subtitle.searchBySn, controller: snController, style: Theme.of(context).textTheme.subtitle1, @@ -120,7 +121,6 @@ class _SingleDevicePickerState extends State { _searchableList.addAll(_devicesProvider.devices); }, ), - ], ), ), diff --git a/lib/views/widgets/status/report/fault_desc_menu.dart b/lib/views/widgets/status/report/fault_desc_menu.dart index 5229aff5..a2b670de 100644 --- a/lib/views/widgets/status/report/fault_desc_menu.dart +++ b/lib/views/widgets/status/report/fault_desc_menu.dart @@ -44,10 +44,8 @@ class _SingleStatusMenuState extends State { @override void initState() { - if (widget.initialStatus != null) { final result = widget.statuses?.where((element) { - return element.id == widget.initialStatus.id; }); if (result.isNotEmpty) _selectedStatus = result.first;