Change service last calls API

merge-requests/30/head
zaid_daoud 2 years ago
parent 5945756e60
commit 5f7bc0cf6e

@ -53,7 +53,7 @@ class URLs {
static get getServiceReportReasons => "$_baseUrl/Lookups/GetLookup?lookupEnum=522"; // get
static get getServiceReportTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=501"; // get
static get getServiceReportStatus => "$_baseUrl/Lookups/GetLookup?lookupEnum=521"; // get
static get getServiceReportLastCalls => "$_baseUrl/Lookups/GetLookup?lookupEnum=520"; // get
static get getServiceReportLastCalls => "$_baseUrl/WorkOrder/GetLookupCallLastSituationBasedOnCase"; // get
static get getAssetTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=28"; // get
static get getPartNumber => "$_baseUrl/PartCatalog/GetPartAutoComplete"; // get
static get getServiceReportPriority => "$_baseUrl/Lookups/GetLookup?lookupEnum=602"; // get

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceReportLastCallsProvider extends ChangeNotifier{
class ServiceReportLastCallsProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_calls = null;
_loading = null;
_stateCode = null;
@ -33,7 +32,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -43,16 +42,22 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getCalls ({String host,User user,int serviceStatus}) async {
if(_loading == true)
return -2;
Future<int> getCalls({
String host,
User user,
int serviceStatus,
String woId,
int id,
String typeName,
}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
// todo request new api from backend to make filter work
response = await ApiManager.instance.get(
URLs.getServiceReportLastCalls,
"${URLs.getServiceReportLastCalls}?parentWOId=$woId&isAdd=true&id=${id ?? 0}&typeTransaction=$typeName",
);
// response = await get(
// Uri.parse(
@ -61,7 +66,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
// ),
// );
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -69,13 +74,11 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}
}

@ -278,6 +278,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
ServiceReportStatusMenu(
report: _serviceReport,
request: widget.request,
onSelect: (status) {
_serviceReport.status = status;
},

@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
@ -36,9 +35,10 @@ import 'package:test_sa/views/widgets/status/report/service_report_type.dart';
import 'package:test_sa/views/widgets/status/report/service_status.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class EditServiceReport extends StatefulWidget {
static final String id = "/edit-service-report";
final ServiceRequest request ;
final ServiceRequest request;
final ServiceReport report;
const EditServiceReport({Key key, this.request, this.report}) : super(key: key);
@ -46,9 +46,7 @@ class EditServiceReport extends StatefulWidget {
_EditServiceReportState createState() => _EditServiceReportState();
}
class _EditServiceReportState extends State<EditServiceReport> with TickerProviderStateMixin{
class _EditServiceReportState extends State<EditServiceReport> with TickerProviderStateMixin {
UserProvider _userProvider;
SettingProvider _settingProvider;
ServiceRequestsProvider _serviceRequestsProvider;
@ -76,6 +74,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_workPreformedController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);
@ -97,52 +96,54 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ListView(
children: [
//AppNameBar(),
const SizedBox(height: 16,),
const SizedBox(
height: 16,
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_subtitle.editServiceReport,
style: Theme.of(context).textTheme.headline5.copyWith(
color: AColors.cyan,
fontSize: 28,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
margin: const EdgeInsets.symmetric(horizontal: 16,vertical: 16),
decoration: BoxDecoration(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
const BoxShadow(
color: AColors.grey,
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
boxShadow: [
const BoxShadow(
color: AColors.grey,
offset: Offset(0,-1),
)
]
),
offset: Offset(0, -1),
)
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Wrap(
spacing: 10,
children: [
ASubTitle("${_subtitle.callId}: ${widget.request.requestCode}",font: 14,),
widget.request.deviceSerialNumber == null ? const SizedBox():
ASubTitle("${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",font: 14,),
ASubTitle(
"${_subtitle.callId}: ${widget.request.requestCode}",
font: 14,
),
widget.request.deviceSerialNumber == null
? const SizedBox()
: ASubTitle(
"${_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),
)
],
),
const Divider(),
@ -156,29 +157,39 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reportType),
_validate && _serviceReport.type == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.type == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportTypeMenu(
initialValue: _serviceReport.type,
onSelect: (status){
onSelect: (status) {
_serviceReport.type = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
// visit date
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.visitDate),
_validate && _serviceReport.visitDate == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.visitDate == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
Row(
children: [
Expanded(
@ -186,7 +197,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
date: _serviceReport.visitDate,
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
onDatePicker: (date){
onDatePicker: (date) {
_serviceReport.visitDate = date;
setState(() {});
},
@ -197,58 +208,84 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
],
),
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// device sn
Visibility(
visible: true,//widget.report.device == null,
visible: true, //widget.report.device == null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.deviceSN),
_validate && _serviceReport.device?.id == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.device?.id == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
AutoCompleteDeviceField(
hospitalId: widget.request.hospitalId,
initialValue: _serviceReport.device,
onPick: (id){
onPick: (id) {
_serviceReport.device.id = id;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
],
),
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.serviceType),
_validate && _serviceReport.assetType == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.assetType == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceAssetTypeMenu(
initialValue: _serviceReport.assetType,
onSelect: (status){
onSelect: (status) {
_serviceReport.assetType = status;
},
),
const SizedBox(height: 8,),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
const SizedBox(
height: 8,
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
const ASubTitle("Assign Employee"),
const SizedBox(height: 8,),
_validate && _serviceReport.engineer == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
const SizedBox(
height: 8,
),
_validate && _serviceReport.engineer == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
EngineersMenu(
initialValue: _serviceReport.engineer,
onSelect: (engineer){
onSelect: (engineer) {
_serviceReport.engineer = engineer;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Report status and Service Type
Row(
children: [
@ -258,37 +295,49 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reportStatus),
_validate && _serviceReport.status == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.status == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportStatusMenu(
report: _serviceReport,
onSelect: (status){
request: widget.request,
onSelect: (status) {
_serviceReport.status = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
Consumer<ServiceReportLastCallsProvider>(
builder: (_, provider, __) {
if(provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
if (provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.callLastSituation),
_validate && _serviceReport.callLastSituation == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.callLastSituation == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportLastCallsMenu(
report: _serviceReport,
onSelect: (status){
if(status?.value == 12
|| _serviceReport.callLastSituation?.value == 12){
onSelect: (status) {
if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) {
_serviceReport.callLastSituation = status;
setState(() {});
} else {
@ -303,56 +352,61 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// invoice number & code
_serviceReport.callLastSituation?.value != 12 ? const SizedBox.shrink():
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
_serviceReport.callLastSituation?.value != 12
? const SizedBox.shrink()
: Row(
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,),
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(
width: 8,
),
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(
@ -414,7 +468,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ),
// const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
// reasons
@ -423,17 +479,21 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reasons),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status){
onSelect: (status) {
_serviceReport.reason = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -442,8 +502,8 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
AMiniOneImagePicker(
//error: _validate && _serviceReport.image == null,
image: _image,
onPick: (image){
_image =image;
onPick: (image) {
_image = image;
_serviceReport.image = base64Encode(image.readAsBytesSync());
},
),
@ -452,7 +512,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Traveling Hours & Working Hours
Row(
children: [
@ -461,13 +523,15 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.workingHours),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
Expanded(
child: AppTimer(
timer: _serviceReport.timer,
onChange: (timer) async{
onChange: (timer) async {
_serviceReport.timer = timer;
return true;
},
@ -516,7 +580,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Operating Hours and Job Sheet Number
// Row(
// children: [
@ -564,29 +630,39 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ],
// ),
//const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Nurse Signature"),
ESignature(
oldSignature: _serviceReport.signatureNurse,
newSignature: _serviceReport.localNurseSignature,
onChange: (signature){
if(signature == null || signature.isEmpty) {return;}
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Engineer Signature"),
ESignature(
oldSignature: _serviceReport.signatureEngineer,
newSignature: _serviceReport.localNurseSignature,
onChange: (signature){
if(signature == null || signature.isEmpty) {return;}
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Part Number and Quantity
Row(
children: [
@ -596,12 +672,17 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.partNumber),
_validate && _serviceReport.parts == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.parts == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
AutoCompletePartsField(
onPick: (part){
onPick: (part) {
_serviceReport.parts.add(part);
setState(() {});
},
@ -609,34 +690,33 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
],
),
),
],
),
SizedBox(height: 8*AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
Row(
children: [
Expanded(flex:3,child: Text(_subtitle.number)),
Expanded(flex: 1,child: Text(_subtitle.quantity)),
Expanded(flex: 3, child: Text(_subtitle.number)),
Expanded(flex: 1, child: Text(_subtitle.quantity)),
],
),
Column(
children: List.generate(
_serviceReport.parts.length,
(index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part){
_serviceReport.parts.remove(part);
setState(() {});
},
);
}
),
children: List.generate(_serviceReport.parts.length, (index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part) {
_serviceReport.parts.remove(part);
setState(() {});
},
);
}),
),
const SizedBox(height: 16,),
const SizedBox(
height: 16,
),
],
),
),
@ -646,48 +726,40 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
text: _subtitle.update,
onPressed: () async {
_validate = true;
if(!_formKey.currentState.validate()){
if (!_formKey.currentState.validate()) {
setState(() {});
return;
}
if(!_serviceReport.validate()) {
if (!_serviceReport.validate()) {
setState(() {});
return;
}
_formKey.currentState.save();
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _serviceRequestsProvider.updateServiceReport(
user: _userProvider.user,
host: _settingProvider.host,
report: _serviceReport,
request: widget.request
);
_isLoading =false;
int status = await _serviceRequestsProvider.updateServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop();
Navigator.of(context).pop();
}else{
String errorMessage = HttpStatusManger.getStatusMessage(
status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
errorMessage
),
)
);
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
},
),
),
const SizedBox(height: 300,)
const SizedBox(
height: 300,
)
],
),
const ABackButton(),

@ -8,13 +8,16 @@ import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_report.dart';
import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
class ServiceReportStatusMenu extends StatefulWidget {
final Function(Lookup) onSelect;
final ServiceReport report;
final ServiceRequest request;
const ServiceReportStatusMenu({Key key, this.onSelect, this.report}) : super(key: key);
const ServiceReportStatusMenu({Key key, this.onSelect, this.report, this.request}) : super(key: key);
@override
State<ServiceReportStatusMenu> createState() => _ServiceReportStatusMenuState();
@ -28,7 +31,7 @@ class _ServiceReportStatusMenuState extends State<ServiceReportStatusMenu> {
UserProvider userProvider = Provider.of<UserProvider>(context);
ServiceReportStatusProvider menuProvider = Provider.of<ServiceReportStatusProvider>(context);
ServiceReportLastCallsProvider callsLastSituationsProvider = Provider.of<ServiceReportLastCallsProvider>(context);
if(firstTime){
if (firstTime) {
callsLastSituationsProvider.reset();
firstTime = false;
@ -36,37 +39,38 @@ class _ServiceReportStatusMenuState extends State<ServiceReportStatusMenu> {
return LoadingManager(
isLoading: menuProvider.isLoading == true || callsLastSituationsProvider.isLoading == true,
isFailedLoading: menuProvider.statuses == null || callsLastSituationsProvider.calls == null,
stateCode: menuProvider.stateCode == null || callsLastSituationsProvider.stateCode == null ? null:
max(menuProvider.stateCode ?? 0,callsLastSituationsProvider.stateCode ?? 0),
stateCode: menuProvider.stateCode == null || callsLastSituationsProvider.stateCode == null ? null : max(menuProvider.stateCode ?? 0, callsLastSituationsProvider.stateCode ?? 0),
onRefresh: () async {
await callsLastSituationsProvider.getCalls(
user: userProvider.user,
host: settingProvider.host,
serviceStatus: widget.report.status?.id
user: userProvider.user,
host: settingProvider.host,
serviceStatus: widget.report.status?.id,
typeName: widget.report.type?.name,
id: widget.report.id,
woId: widget.request.id,
);
if(menuProvider.stateCode == null){
if (menuProvider.stateCode == null) {
menuProvider.reset();
await menuProvider.getTypes(
user: userProvider.user,
host: settingProvider.host
);
await menuProvider.getTypes(user: userProvider.user, host: settingProvider.host);
setState(() {});
}
},
child: SingleStatusMenu(
statuses: menuProvider.statuses,
initialStatus: widget.report.status,
onSelect: (status){
onSelect: (status) {
widget.report.callLastSituation = null;
callsLastSituationsProvider.getCalls(
user: userProvider.user,
host: settingProvider.host,
serviceStatus: status.id
serviceStatus: status.id,
id: widget.report.id,
woId: widget.request.id,
typeName: widget.report.type.name,
);
widget.onSelect(status);
},
)
);
));
}
}

Loading…
Cancel
Save