|
|
|
|
@ -12,6 +12,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/building.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/department.dart';
|
|
|
|
|
@ -54,7 +55,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
final TextEditingController _requestedQuantityController = TextEditingController();
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
List<File> _files = [];
|
|
|
|
|
List<GenericAttachmentModel> attachments = [];
|
|
|
|
|
bool installationType = true;
|
|
|
|
|
String comments = '';
|
|
|
|
|
List<File> _userAttachments = [];
|
|
|
|
|
@ -78,6 +79,12 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
_readOnlyAttachments = _taskProvider?.taskRequestModel?.taskJobAttachments?.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? [];
|
|
|
|
|
|
|
|
|
|
_taskProvider?.updateTaskModel(taskModel);
|
|
|
|
|
if (taskModel != null) {
|
|
|
|
|
attachments.addAll(taskModel.taskJobAttachments!.map((e) => GenericAttachmentModel(id:e.id,name:e.name ?? '')).toList());
|
|
|
|
|
// if (taskModel.taskType?.isInstallation == true) {
|
|
|
|
|
// await _taskProvider!.getSiteData(siteId: taskModel.asset?.siteId);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -101,76 +108,78 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
? const ALoading()
|
|
|
|
|
: taskProvider.taskRequestModel != null
|
|
|
|
|
? Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_timerWidget(context, true, taskProvider),
|
|
|
|
|
8.height,
|
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)],
|
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[
|
|
|
|
|
recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!),
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_timerWidget(context, true, taskProvider),
|
|
|
|
|
8.height,
|
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)],
|
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[
|
|
|
|
|
recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!),
|
|
|
|
|
],
|
|
|
|
|
// if (previousComments.isNotEmpty) ...[
|
|
|
|
|
// 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50),
|
|
|
|
|
// 8.height,
|
|
|
|
|
buildPreviousComments(taskProvider: taskProvider),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ],
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: context.translation.technicalComment,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: TextStyle(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
comments = value;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
),
|
|
|
|
|
20.height,
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
label: context.translation.attachFiles,
|
|
|
|
|
attachment: attachments,
|
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
// if (previousComments.isNotEmpty) ...[
|
|
|
|
|
// 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50),
|
|
|
|
|
// 8.height,
|
|
|
|
|
buildPreviousComments(taskProvider: taskProvider),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ],
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: context.translation.technicalComment,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
comments = value;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
),
|
|
|
|
|
20.height,
|
|
|
|
|
MultiFilesPicker(
|
|
|
|
|
label: context.translation.attachFiles,
|
|
|
|
|
files: _userAttachments,
|
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
16.height,
|
|
|
|
|
const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
|
children: [
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.save,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 0),
|
|
|
|
|
).expanded,
|
|
|
|
|
12.width,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.complete,
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 1),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
16.height,
|
|
|
|
|
const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
|
children: [
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.save,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 0),
|
|
|
|
|
).expanded,
|
|
|
|
|
12.width,
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.complete,
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 1),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: NoDataFound(message: context.translation.noDataFound).center,
|
|
|
|
|
@ -189,12 +198,9 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
if (validate(model: taskModel)) {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
List<TaskJobAttachment> attachment = [];
|
|
|
|
|
if (_readOnlyAttachments.isNotEmpty) {
|
|
|
|
|
attachment.addAll(_readOnlyAttachments);
|
|
|
|
|
}
|
|
|
|
|
for (var file in _userAttachments) {
|
|
|
|
|
String fileName = ServiceRequestUtils.isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(File(file.path).readAsBytesSync())}") : file.path;
|
|
|
|
|
attachment.add(TaskJobAttachment(id: 0, name: fileName));
|
|
|
|
|
for (var item in attachments) {
|
|
|
|
|
String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??'';
|
|
|
|
|
attachment.add(TaskJobAttachment(id: item.id, name: fileName));
|
|
|
|
|
}
|
|
|
|
|
taskModel?.taskJobAttachments = attachment;
|
|
|
|
|
if (taskModel?.taskTimePicker != null) {
|
|
|
|
|
@ -268,7 +274,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.installationDate,
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
date: DateTime.tryParse(taskModel.installationDate ?? ""),
|
|
|
|
|
formatDateWithTime: false,
|
|
|
|
|
onDatePicker: (selectedDate) {
|
|
|
|
|
@ -294,7 +300,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.serialNo,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
initialValue: taskModel.serialNo ?? '',
|
|
|
|
|
@ -310,7 +316,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
initialValue: taskModel.site,
|
|
|
|
|
loading: _taskProvider?.isSiteLoading,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
enabled: false,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
@ -328,7 +334,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
SingleItemDropDownMenu<Building, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: 'Installation Building',
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
loading: _taskProvider?.isSiteLoading,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
@ -349,7 +355,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
SingleItemDropDownMenu<Floor, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
loading: _taskProvider?.isSiteLoading,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
title: 'Installation Floor',
|
|
|
|
|
@ -369,7 +375,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: 'Installation Department',
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
loading: _taskProvider?.isSiteLoading,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
@ -429,7 +435,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: context.translation.completedActions,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
enabled: false,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: taskModel.actionNeeded,
|
|
|
|
|
@ -444,7 +450,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: context.translation.impactStatus,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: taskModel.impactStatus,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
@ -468,7 +474,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: context.translation.completedActions,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
enabled: false,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: taskModel.actionNeeded,
|
|
|
|
|
@ -483,7 +489,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: context.translation.impactStatus,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
backgroundColor: AppColor.neutral90,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: taskModel.impactStatus,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
@ -515,7 +521,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
enabled: isTimerEnable,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColor.neutral90,
|
|
|
|
|
color: AppColor.fieldBgColor(context),
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
),
|
|
|
|
|
pickerTimer: taskProvider.taskRequestModel?.taskTimePicker,
|
|
|
|
|
@ -534,11 +540,11 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'Total Working Time:'.bodyText2(context).custom(color: AppColor.neutral50),
|
|
|
|
|
'Total Working Time:'.bodyText2(context).custom(color: AppColor.textColor(context)),
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round()),
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50, fontWeight: FontWeight.w600),
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.textColor(context), fontWeight: FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -655,7 +661,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.assistantEmployee.heading6(context).custom(color: AppColor.black10),
|
|
|
|
|
context.translation.assistantEmployee.heading6(context).custom(color: AppColor.textColor(context)),
|
|
|
|
|
Icon(isExpanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -670,7 +676,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
children: [
|
|
|
|
|
ServiceReportAssistantEmployeeMenu(
|
|
|
|
|
title: context.translation.select,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
initialValue: (taskModel?.assistantEmployees?.isNotEmpty ?? false) ? taskModel?.assistantEmployees?.first : null,
|
|
|
|
|
onSelect: (employee) {
|
|
|
|
|
if (employee == null) {
|
|
|
|
|
@ -688,7 +694,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.startTime,
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
date: taskModel?.modelAssistantEmployees?.startDate,
|
|
|
|
|
// from: taskModel?.d,
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
@ -728,7 +734,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.endTime,
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
date: taskModel?.modelAssistantEmployees?.endDate,
|
|
|
|
|
enable: taskModel?.modelAssistantEmployees?.startDate != null,
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
@ -782,12 +788,12 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.workingHours,
|
|
|
|
|
backgroundColor: AppColor.neutral80,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
controller: _workingHoursController,
|
|
|
|
|
suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
|
|
|
|
|
initialValue: taskModel?.modelAssistantEmployees?.workingHours != null ? taskModel!.modelAssistantEmployees!.workingHours?.toStringAsFixed(2) : '',
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
enable: false,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
@ -796,9 +802,9 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: taskModel?.modelAssistantEmployees?.comment,
|
|
|
|
|
labelText: context.translation.comment,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
|