ppm timer & receiver name fixed.

main_design2.0
Sikander Saleem 8 months ago
parent e2750094d9
commit caa1f975ab

@ -387,8 +387,8 @@ class Ppm {
String visitStatusName, String visitStatusName,
String warrantyEndDate, String warrantyEndDate,
TimerModel tbsTimer, TimerModel tbsTimer,
}) => }) {
Ppm( Ppm ppm = Ppm(
id: id ?? this.id, id: id ?? this.id,
ppmScheduleId: ppmScheduleId ?? this.ppmScheduleId, ppmScheduleId: ppmScheduleId ?? this.ppmScheduleId,
assetId: assetId ?? this.assetId, assetId: assetId ?? this.assetId,
@ -468,7 +468,11 @@ class Ppm {
visitNo: visitNo ?? this.visitNo, visitNo: visitNo ?? this.visitNo,
visitStatusName: visitStatusName ?? this.visitStatusName, visitStatusName: visitStatusName ?? this.visitStatusName,
warrantyEndDate: warrantyEndDate ?? this.warrantyEndDate, warrantyEndDate: warrantyEndDate ?? this.warrantyEndDate,
)..tbsTimer = tbsTimer ?? this.tbsTimer; );
ppm.tbsTimer = tbsTimer ?? this.tbsTimer;
return ppm;
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};

@ -261,9 +261,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
context.translation.transferDetails.heading5(context), context.translation.transferDetails.heading5(context),
8.height, 8.height,
'${context.translation.assetName}: ${_formModel.assetName.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), '${context.translation.assetName}: ${_formModel.assetName.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context),
'${context.translation.requesterName}: ${_formModel?.receiverEndUserName?.cleanupWhitespace?.capitalizeFirstOfEach??""}'.bodyText(context),
///TBDZ
'${context.translation.requesterName}: '.bodyText(context),
], ],
).toShadowContainer(context); ).toShadowContainer(context);
} }

@ -19,22 +19,43 @@ import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/app_filled_button.dart'; import '../../../../new_views/common_widgets/app_filled_button.dart';
import '../../../widgets/requests/request_status.dart'; import '../../../widgets/requests/request_status.dart';
class PpmDetailsPage extends StatelessWidget { class PpmDetailsPage extends StatefulWidget {
static const String id = "/visit-details"; static const String id = "/visit-details";
final RequestsDetails request; final RequestsDetails request;
const PpmDetailsPage({Key key, this.request}) : super(key: key); PpmDetailsPage({Key key, this.request}) : super(key: key);
@override
_PpmDetailsPageState createState() {
return _PpmDetailsPageState();
}
}
class _PpmDetailsPageState extends State<PpmDetailsPage> {
UserProvider userProvider;
PpmProvider ppmProvider;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
UserProvider userProvider = Provider.of<UserProvider>(context); userProvider ??= Provider.of<UserProvider>(context, listen: false);
PpmProvider ppmProvider = Provider.of<PpmProvider>(context); ppmProvider ??= Provider.of<PpmProvider>(context, listen: false);
return Scaffold( return Scaffold(
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance), appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
body: SafeArea( body: SafeArea(
child: FutureBuilder( child: FutureBuilder(
future: ppmProvider.getPpmById(request.id), future: ppmProvider.getPpmById(widget.request.id),
builder: (context, snap) { builder: (context, snap) {
if (snap.connectionState == ConnectionState.waiting) { if (snap.connectionState == ConnectionState.waiting) {
return const ALoading(); return const ALoading();
@ -48,13 +69,13 @@ class PpmDetailsPage extends StatelessWidget {
children: [ children: [
Row( Row(
children: [ children: [
if (request.priority != null) if (widget.request.priority != null)
StatusLabel( StatusLabel(
label: request.priority, label: widget.request.priority,
textColor: AppColor.getRequestStatusTextColorByName(context, request.priority), textColor: AppColor.getRequestStatusTextColorByName(context, widget.request.priority),
backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority), backgroundColor: AppColor.getRequestStatusColorByName(context, widget.request.priority),
), ),
if (request.priority != null) 8.width, if (widget.request.priority != null) 8.width,
StatusLabel( StatusLabel(
label: ppm.visitStatusName, label: ppm.visitStatusName,
id: ppm.deviceStatusId, id: ppm.deviceStatusId,
@ -82,8 +103,9 @@ class PpmDetailsPage extends StatelessWidget {
).expanded, ).expanded,
if (userProvider.user.type == UsersTypes.engineer && (ppm.visitStatusId != 270 && ppm.visitStatusId != 269)) if (userProvider.user.type == UsersTypes.engineer && (ppm.visitStatusId != 270 && ppm.visitStatusId != 269))
AppFilledButton( AppFilledButton(
onPressed: () { onPressed: () async {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPpm(ppm: ppm, details: request))); await Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPpm(ppm: ppm, details: widget.request)));
setState(() {});
}, },
label: context.translation.updateRequest, label: context.translation.updateRequest,
).paddingAll(16) ).paddingAll(16)

@ -60,8 +60,8 @@ class _EditPpmState extends State<EditPpm> with SingleTickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context,listen: false);
_regularVisitsProvider = Provider.of<PpmProvider>(context); _regularVisitsProvider = Provider.of<PpmProvider>(context,listen: false);
return Scaffold( return Scaffold(
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance), appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
key: _scaffoldKey, key: _scaffoldKey,

@ -28,24 +28,10 @@ class PentryTBSForm extends StatefulWidget {
} }
class _PentryTBSFormState extends State<PentryTBSForm> { class _PentryTBSFormState extends State<PentryTBSForm> {
Ppm _model;
@override
void initState() {
_model = widget.model;
super.initState();
}
@override
void dispose() {
print("disposeddddddd");
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_model?.files ??= []; widget.model?.files ??= [];
_model?.files = (_model.files ?? []).where((element) => element.attachmentName != null && element.attachmentName.isNotEmpty).toList(); widget.model?.files = (widget.model.files ?? []).where((element) => element.attachmentName != null && element.attachmentName.isNotEmpty).toList();
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
@ -54,7 +40,7 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>( SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
context: context, context: context,
initialValue: _model.visitStatusId == null ? null : Lookup(name: _model.visitStatusName ?? "", id: _model.visitStatusId), initialValue: widget.model.visitStatusId == null ? null : Lookup(name: widget.model.visitStatusName ?? "", id: widget.model.visitStatusId),
title: context.translation.ppmVisit, title: context.translation.ppmVisit,
onSelect: (value) { onSelect: (value) {
if (value?.value == 4) { if (value?.value == 4) {
@ -64,93 +50,96 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
} }
if (value != null) { if (value != null) {
_model.visitStatusName = value.name; widget.model.visitStatusName = value.name;
_model.visitStatusId = value.id; widget.model.visitStatusId = value.id;
} }
}, },
), ),
8.height, 8.height,
AppTimer( AppTimer(
label: context.translation.timer, label: context.translation.timer,
timer: _model.tbsTimer, timer: widget.model.tbsTimer,
enabled: _model.tbsTimer.endAt == null, enabled: widget.model.tbsTimer.endAt == null,
timerProgress: (isRunning) {
print("timerProgress:$isRunning");
},
onChange: (timer) async { onChange: (timer) async {
_model.tbsTimer = timer; widget.model.tbsTimer = timer;
return true; return true;
}, },
), ),
8.height, 8.height,
SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>( SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
context: context, context: context,
initialValue: _model.deviceStatusId == null ? null : Lookup(name: _model.deviceStatusName ?? "", id: _model.deviceStatusId), initialValue: widget.model.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId),
title: context.translation.deviceStatus, title: context.translation.deviceStatus,
onSelect: (value) { onSelect: (value) {
if (value != null) { if (value != null) {
_model.deviceStatusId = value.id; widget.model.deviceStatusId = value.id;
_model.deviceStatusName = value.name; widget.model.deviceStatusName = value.name;
} }
}, },
), ),
8.height, 8.height,
ADatePicker( ADatePicker(
label: context.translation.actualVisitDate, label: context.translation.actualVisitDate,
date: DateTime.tryParse(_model.actualDate ?? ""), date: DateTime.tryParse(widget.model.actualDate ?? ""),
from: DateTime.now().subtract(const Duration(days: 30)), from: DateTime.now().subtract(const Duration(days: 30)),
onDatePicker: (date) { onDatePicker: (date) {
if (date == null) return; if (date == null) return;
_model.actualDate = date?.toIso8601String(); widget.model.actualDate = date?.toIso8601String();
setState(() {}); setState(() {});
}, },
), ),
8.height, 8.height,
ADatePicker( ADatePicker(
label: context.translation.expectedVisitDate, label: context.translation.expectedVisitDate,
date: DateTime.tryParse(_model.expectedDate ?? ""), date: DateTime.tryParse(widget.model.expectedDate ?? ""),
from: DateTime.now().subtract(const Duration(days: 30)), from: DateTime.now().subtract(const Duration(days: 30)),
enable: false, enable: false,
onDatePicker: (date) { onDatePicker: (date) {
if (date == null) return; if (date == null) return;
_model.expectedDate = date?.toIso8601String(); widget.model.expectedDate = date?.toIso8601String();
setState(() {}); setState(() {});
}, },
), ),
8.height, 8.height,
AppTextFormField( AppTextFormField(
labelText: context.translation.travelingHours, labelText: context.translation.travelingHours,
initialValue: (_model.travelingHours ?? "").toString(), initialValue: (widget.model.travelingHours ?? "").toString(),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.number, textInputType: TextInputType.number,
onChange: (value) { onChange: (value) {
_model.travelingHours = value; widget.model.travelingHours = value;
}, },
), ),
8.height, 8.height,
MultiFilesPicker( MultiFilesPicker(
label: context.translation.attachImage, label: context.translation.attachImage,
files: _model.files.map((e) => File(e.attachmentName)).toList(), files: widget.model.files.map((e) => File(e.attachmentName)).toList(),
onChange: (files) { onChange: (files) {
_model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList(); widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
}, },
), ),
8.height, 8.height,
ESignature( ESignature(
title: context.translation.nurseSignature, title: context.translation.nurseSignature,
oldSignature: _model.nurseSignature, oldSignature: widget.model.nurseSignature,
newSignature: _model.localNurseSignature, newSignature: widget.model.localNurseSignature,
onChange: (signature) { onChange: (signature) {
_model.localNurseSignature = signature; widget.model.localNurseSignature = signature;
_model.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; widget.model.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
}, },
), ),
8.height, 8.height,
ESignature( ESignature(
title: context.translation.engSign, title: context.translation.engSign,
oldSignature: _model.engSignature, oldSignature: widget.model.engSignature,
newSignature: _model.localEngineerSignature, newSignature: widget.model.localEngineerSignature,
onChange: (signature) { onChange: (signature) {
_model.localEngineerSignature = signature; widget.model.localEngineerSignature = signature;
_model.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; widget.model.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
}, },
), ),
8.height, 8.height,

Loading…
Cancel
Save