|
|
|
|
@ -1,19 +1,14 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
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/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/search_work_order.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/spare_parts.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
@ -23,8 +18,7 @@ import 'package:test_sa/service_request_latest/request_detail_provider.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/forms/spare_part/spare_part_request.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/update_service_report.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/work_order_details_page.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/files_list.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
@ -52,99 +46,107 @@ class ActivitiesListView extends StatelessWidget {
|
|
|
|
|
itemCount: activities.length,
|
|
|
|
|
separatorBuilder: (czt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Row(
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: activities[index].activityStatus?.name,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, activities[index].activityStatus?.name),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, activities[index].activityStatus?.name),
|
|
|
|
|
),
|
|
|
|
|
"drag_icon".toSvgAsset(height: 12, width: 23, color: AppColor.neutral160),
|
|
|
|
|
if (userProvider.user!.type == UsersTypes.engineer &&
|
|
|
|
|
requestDetailProvider.currentWorkOrder?.data?.status?.value != 5 &&
|
|
|
|
|
requestDetailProvider.currentWorkOrder?.data?.status?.value != 3)
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"edit_icon".toSvgAsset(height: 21, width: 21).onPress(() {
|
|
|
|
|
print('attachments in activity model is ${activities[index].activitySparePart?.acitiySparePartAttachments}');
|
|
|
|
|
requestDetailProvider.sparePartHelperModel=SparePartHelperModel(
|
|
|
|
|
id: activities[index].id,
|
|
|
|
|
workOrderId: requestDetailProvider.currentWorkOrder?.data?.requestId,
|
|
|
|
|
sparePartAttachments:activities[index].activitySparePart?.acitiySparePartAttachments??[],
|
|
|
|
|
sparePart:SparePart(
|
|
|
|
|
id: activities[index].activitySparePart?.partCatalogItem?.id,
|
|
|
|
|
partName: activities[index].activitySparePart?.partCatalogItem?.partName,
|
|
|
|
|
partNo: activities[index].activitySparePart?.partCatalogItem?.partNumber),
|
|
|
|
|
quantity: activities[index].activitySparePart?.quantity,
|
|
|
|
|
activityStatusId: activities[index].activityStatus?.id,
|
|
|
|
|
//TODO commets are missing in api response..
|
|
|
|
|
// comment: activities[index].activitySparePart?.description,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
requestDetailProvider.updateSparePartHelperModel(requestDetailProvider.sparePartHelperModel);
|
|
|
|
|
print('model in activity page is ${requestDetailProvider.sparePartHelperModel?.toJson()}');
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => const SparePartRequest (),
|
|
|
|
|
));
|
|
|
|
|
}),
|
|
|
|
|
24.width,
|
|
|
|
|
"delete_icon".toSvgAsset(height: 21, width: 21).onPress(()async {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
int status = await requestDetailProvider.deleteActivitySparePart(id: activities[index].id!, workOrderId: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
await requestDetailProvider.getWorkOrderById(id: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
6.height,
|
|
|
|
|
//activity type...
|
|
|
|
|
Text(
|
|
|
|
|
'${activities[index].activityType?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
3.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.partName}: ${activities[index].activitySparePart?.partCatalogItem?.partName}',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: activities[index].activityStatus?.name,
|
|
|
|
|
textColor: AppColor.getHistoryLogStatusTextColorByName(activities[index].activityStatus!.name!),
|
|
|
|
|
backgroundColor: AppColor.getHistoryLogStatusColorByName(activities[index].activityStatus!.name!),
|
|
|
|
|
),
|
|
|
|
|
2.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.partNo}: ${activities[index].activitySparePart?.partCatalogItem?.partNumber}',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
2.height,
|
|
|
|
|
//TODO description text not in api.
|
|
|
|
|
// Text(
|
|
|
|
|
// '${context.translation.date}: ${activities[index].currentSituation?.date}',
|
|
|
|
|
// style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
// ),
|
|
|
|
|
2.height,
|
|
|
|
|
"drag_icon".toSvgAsset(height: 12, width: 23, color: AppColor.neutral160),
|
|
|
|
|
if (userProvider.user!.type == UsersTypes.engineer &&
|
|
|
|
|
requestDetailProvider.currentWorkOrder?.data?.status?.value != 5 &&
|
|
|
|
|
requestDetailProvider.currentWorkOrder?.data?.status?.value != 3)
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
"edit_icon".toSvgAsset(height: 21, width: 21).onPress(() {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel = SparePartHelperModel(
|
|
|
|
|
id: activities[index].id,
|
|
|
|
|
workOrderId: requestDetailProvider.currentWorkOrder?.data?.requestId,
|
|
|
|
|
comment: activities[index].activitySparePart?.comment,
|
|
|
|
|
sparePartAttachments: activities[index].activitySparePart?.acitiySparePartAttachments ?? [],
|
|
|
|
|
sparePart: SparePart(
|
|
|
|
|
id: activities[index].activitySparePart?.partCatalogItem?.id,
|
|
|
|
|
partName: activities[index].activitySparePart?.partCatalogItem?.partName,
|
|
|
|
|
partNo: activities[index].activitySparePart?.partCatalogItem?.partNumber),
|
|
|
|
|
quantity: activities[index].activitySparePart?.quantity,
|
|
|
|
|
activityStatusId: activities[index].activityStatus?.id,
|
|
|
|
|
//TODO commets are missing in api response..
|
|
|
|
|
// comment: activities[index].activitySparePart?.description,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
requestDetailProvider.updateSparePartHelperModel(requestDetailProvider.sparePartHelperModel);
|
|
|
|
|
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => const SparePartRequest(),
|
|
|
|
|
));
|
|
|
|
|
}),
|
|
|
|
|
24.width,
|
|
|
|
|
"delete_icon".toSvgAsset(height: 21, width: 21).onPress(() async {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
int status =
|
|
|
|
|
await requestDetailProvider.deleteActivitySparePart(id: activities[index].id!, workOrderId: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
await requestDetailProvider.getWorkOrderById(id: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
//TODO write onview detail method..
|
|
|
|
|
// Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// MaterialPageRoute(builder: (context) => WorkOrderDetailsPage(workOrder: activities[index], serviceRequest: ServiceRequest())),
|
|
|
|
|
// );
|
|
|
|
|
}).expanded,
|
|
|
|
|
),
|
|
|
|
|
6.height,
|
|
|
|
|
//activity type...
|
|
|
|
|
Text(
|
|
|
|
|
'${activities[index].activityType?.cleanupWhitespace.capitalizeFirstOfEach}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
3.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.partName}: ${activities[index].activitySparePart?.partCatalogItem?.partName}',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
2.height,
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.partNo}: ${activities[index].activitySparePart?.partCatalogItem?.partNumber}',
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
2.height,
|
|
|
|
|
//TODO description text not in api.
|
|
|
|
|
// Text(
|
|
|
|
|
// '${context.translation.date}: ${activities[index].currentSituation?.date}',
|
|
|
|
|
// style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
// ),
|
|
|
|
|
if (activities[index].activitySparePart?.comment?.isNotEmpty ?? false) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
2.height,
|
|
|
|
|
Text(
|
|
|
|
|
activities[index].activitySparePart?.comment ?? "",
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
if (activities[index].activitySparePart?.acitiySparePartAttachments?.isNotEmpty ?? false) ...[
|
|
|
|
|
2.height,
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
FilesList(images: activities[index].activitySparePart!.acitiySparePartAttachments!.map((toElement) => URLs.getFileUrl(toElement.name!)!).toList()),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
).toShadowContainer(context, padding: 12).onPress(() {
|
|
|
|
|
//TODO write onview detail method..
|
|
|
|
|
// Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// MaterialPageRoute(builder: (context) => WorkOrderDetailsPage(workOrder: activities[index], serviceRequest: ServiceRequest())),
|
|
|
|
|
// );
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
).expanded,
|
|
|
|
|
if (userProvider.user!.type == UsersTypes.engineer &&
|
|
|
|
|
|