|
|
|
|
@ -28,8 +28,6 @@ import '../../../../models/new_models/department.dart';
|
|
|
|
|
import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
|
|
|
|
|
//TODO need to refactor this screen also add loaders when done ...
|
|
|
|
|
|
|
|
|
|
class UpdateParentAssetView extends StatefulWidget {
|
|
|
|
|
final TechnicalInspectionAssetModel assetModel;
|
|
|
|
|
final int? lineId;
|
|
|
|
|
@ -438,7 +436,6 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
|
|
|
|
|
|
|
|
|
|
assetDeliveryProvider.parentFormModel.tableItemId = widget.tableItemId;
|
|
|
|
|
assetDeliveryProvider.parentFormModel.costCenterId = widget.costCenterItemId;
|
|
|
|
|
log('model data ${assetDeliveryProvider.parentFormModel.toJson()}');
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
await assetDeliveryProvider.saveTechnicalInspectionAssetData(model: assetDeliveryProvider.parentFormModel).then((status) async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
@ -453,7 +450,7 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
|
|
|
|
|
final result = await Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => InspectionChecklistBottomSheet(
|
|
|
|
|
builder: (context) => InspectionCheckListView(
|
|
|
|
|
initialValues: checkList,
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
|
|
@ -462,18 +459,6 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
buildInspectionPayload(checkList);
|
|
|
|
|
if (checkList.isNotEmpty) {
|
|
|
|
|
final isPass = checkList.every((e) => e.status == 'PASS');
|
|
|
|
|
log('Final Status: ${isPass ? 'PASS' : 'FAIL'}');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// call this as bottomsheet.
|
|
|
|
|
// final result = await showModalBottomSheet<List<Map<String, dynamic>>>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// isScrollControlled: true,
|
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
|
// builder: (_) => const InspectionChecklistBottomSheet(),
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool _isPass(List<InspectionChecklistItem> list, String title) {
|
|
|
|
|
@ -528,446 +513,9 @@ class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
checkList.forEach((item) {
|
|
|
|
|
log('items ${item.toJson()}');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String _statusFromBool(bool? value) {
|
|
|
|
|
return value == true ? 'PASS' : 'FAIL';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// import 'dart:developer';
|
|
|
|
|
// import 'package:flutter/material.dart';
|
|
|
|
|
// import 'package:provider/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/new_models/building.dart';
|
|
|
|
|
// import 'package:test_sa/models/new_models/floor.dart';
|
|
|
|
|
// import 'package:test_sa/models/new_models/site.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/models/technical_inspection_asset_model.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/search_asset_view.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/status_checklist_view.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/technical_inpection_asset_card_view.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/pages/technical_inpection/update_child_asset_view.dart';
|
|
|
|
|
// import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
|
|
|
|
|
// import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
// import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
// import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
// import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
|
|
|
|
|
// import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
// import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
|
// import '../../../../models/new_models/department.dart';
|
|
|
|
|
// import '../../../../new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
// import '../../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
//
|
|
|
|
|
// //TODO need to refactor this screen when done ...
|
|
|
|
|
//
|
|
|
|
|
// class UpdateParentAssetView extends StatefulWidget {
|
|
|
|
|
// final TechnicalInspectionParentAssetModel assetModel;
|
|
|
|
|
// final int? lineId;
|
|
|
|
|
//
|
|
|
|
|
// UpdateParentAssetView({
|
|
|
|
|
// Key? key,
|
|
|
|
|
// required this.assetModel,
|
|
|
|
|
// this.lineId,
|
|
|
|
|
// }) : super(key: key);
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// State<UpdateParentAssetView> createState() => _UpdateParentAssetViewState();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// class _UpdateParentAssetViewState extends State<UpdateParentAssetView> {
|
|
|
|
|
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
// List<InspectionChecklistItem> checkList = [];
|
|
|
|
|
// late SiteProvider siteProvider;
|
|
|
|
|
// late AssetDeliveryProvider assetDeliveryProvider;
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// void initState() {
|
|
|
|
|
// siteProvider = Provider.of<SiteProvider>(context, listen: false);
|
|
|
|
|
// assetDeliveryProvider = Provider.of<AssetDeliveryProvider>(context, listen: false);
|
|
|
|
|
// // WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
// populateForm();
|
|
|
|
|
// // });
|
|
|
|
|
// super.initState();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// void populateForm() async {
|
|
|
|
|
// // _model = widget.assetModel;
|
|
|
|
|
// assetDeliveryProvider.setModel(widget.assetModel);
|
|
|
|
|
// applyInspectionFlagsToChecklist(model: widget.assetModel,checklist: checkList);
|
|
|
|
|
// if (widget.assetModel.site != null) {
|
|
|
|
|
// await assetDeliveryProvider.getSiteData(siteId: widget.assetModel.site?.id, model: _model);
|
|
|
|
|
// }
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// void dispose() {
|
|
|
|
|
// super.dispose();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
|
// return Scaffold(
|
|
|
|
|
// key: _scaffoldKey,
|
|
|
|
|
// appBar: DefaultAppBar(
|
|
|
|
|
// title: 'Parent Details'.addTranslation,
|
|
|
|
|
// titleStyle: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
// ),
|
|
|
|
|
// body: Form(
|
|
|
|
|
// key: _formKey,
|
|
|
|
|
// child: Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// SingleChildScrollView(
|
|
|
|
|
// padding: const EdgeInsets.all(16),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// inspectionDetailsForm(lineId: widget.lineId),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// childList(context),
|
|
|
|
|
// ],
|
|
|
|
|
// ).toShadowContainer(context, borderRadius: 20, padding: 12))
|
|
|
|
|
// .expanded,
|
|
|
|
|
// FooterActionButton.footerContainer(context: context, child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Save'.addTranslation, maxWidth: true, onPressed: _saveTap)),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Widget childList(BuildContext context) {
|
|
|
|
|
// final assetDeliveryTableList = ['abc', 'def', 'ghi', 'fhg', 'hjhh'];
|
|
|
|
|
// return Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// Row(
|
|
|
|
|
// children: [
|
|
|
|
|
// Text(
|
|
|
|
|
// "Test List",
|
|
|
|
|
// style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
|
|
|
|
|
// ),
|
|
|
|
|
// 8.width,
|
|
|
|
|
// 'web_link_icon'.toSvgAsset().onPress(() {
|
|
|
|
|
// openInspectionChecklist(context);
|
|
|
|
|
// }),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ListView.separated(
|
|
|
|
|
// itemCount: assetDeliveryTableList.length,
|
|
|
|
|
// separatorBuilder: (_, __) => 8.height,
|
|
|
|
|
// padding: EdgeInsets.zero,
|
|
|
|
|
// shrinkWrap: true,
|
|
|
|
|
// physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
// itemBuilder: (listContext, itemIndex) {
|
|
|
|
|
// return TechnicalInspectionAssetCard(
|
|
|
|
|
// assetModel: TechnicalInspectionParentAssetModel(),
|
|
|
|
|
// ischild: true,
|
|
|
|
|
// editPress: () {
|
|
|
|
|
// Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateChildAssetView()));
|
|
|
|
|
// },
|
|
|
|
|
// isViewOnly: false,
|
|
|
|
|
// );
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Widget inspectionDetailsForm({int? lineId}) {
|
|
|
|
|
// return Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// //Replace with simple container...
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: 'Asset Number'.addTranslation,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// initialValue: _model.assetNumber,
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
// textInputType: TextInputType.number,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// enable: false,
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
// ).onPress(() async {
|
|
|
|
|
// var data = await Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
// builder: (context) => TechnicalInspectionSearchAssetView(
|
|
|
|
|
// lineId: lineId,
|
|
|
|
|
// )));
|
|
|
|
|
// if (data != null) {
|
|
|
|
|
// TechnicalInspectionParentAssetModel? assetModel = await assetDeliveryProvider.getAssetDetails(assetId: data?.id);
|
|
|
|
|
//
|
|
|
|
|
// if (assetModel != null) {
|
|
|
|
|
// _model =TechnicalInspectionParentAssetModel();
|
|
|
|
|
// setState(() {
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _model = assetModel;
|
|
|
|
|
// });
|
|
|
|
|
// if (assetModel.site != null) {
|
|
|
|
|
// await assetDeliveryProvider.getSiteData(siteId: assetModel.site?.id, model: _model);
|
|
|
|
|
// }
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: 'Serial Number'.addTranslation,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// initialValue: _model.serialNo ?? '',
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
// textInputType: TextInputType.number,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
// _model.serialNo = value;
|
|
|
|
|
// },
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: 'System ID'.addTranslation,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// initialValue: _model.systemId ?? '',
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
// _model.systemId = value;
|
|
|
|
|
// },
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: 'Site',
|
|
|
|
|
// initialValue: _model.site,
|
|
|
|
|
// loading: assetDeliveryProvider.isSiteLoading,
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// // enabled: false,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value == null) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// _model.site = value;
|
|
|
|
|
// _model.building = null;
|
|
|
|
|
// _model.floor = null;
|
|
|
|
|
// _model.department = null;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Building, NullableLoadingProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: 'Building',
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// loading: assetDeliveryProvider.isSiteLoading,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// initialValue: _model.building,
|
|
|
|
|
// enabled: _model.site?.buildings?.isNotEmpty ?? false,
|
|
|
|
|
// staticData: _model.site?.buildings ?? [],
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value == null) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// _model.building = value;
|
|
|
|
|
// _model.floor = null;
|
|
|
|
|
// _model.department = null;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Floor, NullableLoadingProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// loading: assetDeliveryProvider.isSiteLoading,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// title: 'Floor',
|
|
|
|
|
// initialValue: _model.floor,
|
|
|
|
|
// enabled: _model.building?.floors?.isNotEmpty ?? false,
|
|
|
|
|
// staticData: _model.building?.floors ?? [],
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value == null) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// _model.floor = value;
|
|
|
|
|
// _model.department = null;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Department, NullableLoadingProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: 'Department',
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// loading: assetDeliveryProvider.isSiteLoading,
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// initialValue: _model.department,
|
|
|
|
|
// enabled: _model.floor?.departments?.isNotEmpty ?? false,
|
|
|
|
|
// staticData: _model.floor?.departments ?? [],
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value == null) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// _model.department = value;
|
|
|
|
|
// _model.room = null;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
//
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: 'Installation Date'.addTranslation,
|
|
|
|
|
// hideShadow: true,
|
|
|
|
|
// height: 56.toScreenHeight,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// date: _model.installationDate,
|
|
|
|
|
// // from: widget.pickerFromDate,
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// builder: (BuildContext context, Widget? child) {
|
|
|
|
|
// final ThemeData currentTheme = Theme.of(context);
|
|
|
|
|
// return Theme(
|
|
|
|
|
// data: currentTheme.copyWith(
|
|
|
|
|
// timePickerTheme: TimePickerThemeData(
|
|
|
|
|
// dialHandColor: AppColor.primary10,
|
|
|
|
|
// dialBackgroundColor: Colors.grey.withOpacity(0.1),
|
|
|
|
|
// hourMinuteColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.grey.withOpacity(0.1)),
|
|
|
|
|
// dayPeriodColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.transparent),
|
|
|
|
|
// dayPeriodTextColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? Colors.white : AppColor.primary10),
|
|
|
|
|
// dayPeriodBorderSide: BorderSide(color: Colors.grey.withOpacity(0.2)),
|
|
|
|
|
// entryModeIconColor: AppColor.primary10,
|
|
|
|
|
// ),
|
|
|
|
|
// textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: AppColor.primary10)),
|
|
|
|
|
// ),
|
|
|
|
|
// child: child!,
|
|
|
|
|
// );
|
|
|
|
|
// },
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// _model.installationDate = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ///Need to check which details show here...
|
|
|
|
|
//
|
|
|
|
|
// void _saveTap() async {
|
|
|
|
|
// _formKey.currentState!.save();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Future<void> openInspectionChecklist(BuildContext context) async {
|
|
|
|
|
// final result = await Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
// builder: (context) => InspectionChecklistBottomSheet(
|
|
|
|
|
// initialValues: checkList,
|
|
|
|
|
// )));
|
|
|
|
|
//
|
|
|
|
|
// log('result i got is $result');
|
|
|
|
|
// if(result!=null){
|
|
|
|
|
// checkList = result;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// if (checkList.isNotEmpty) {
|
|
|
|
|
// final isPass = checkList.every((e) => e.status == 'PASS');
|
|
|
|
|
// log('Final Status: ${isPass ? 'PASS' : 'FAIL'}');
|
|
|
|
|
// }
|
|
|
|
|
// final payload = buildInspectionPayload(checkList);
|
|
|
|
|
//
|
|
|
|
|
// log('API Payload: $payload');
|
|
|
|
|
// // call this as bottomsheet.
|
|
|
|
|
// // final result = await showModalBottomSheet<List<Map<String, dynamic>>>(
|
|
|
|
|
// // context: context,
|
|
|
|
|
// // isScrollControlled: true,
|
|
|
|
|
// // backgroundColor: Colors.transparent,
|
|
|
|
|
// // builder: (_) => const InspectionChecklistBottomSheet(),
|
|
|
|
|
// // );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// bool _isPass(List<InspectionChecklistItem> list, String title) {
|
|
|
|
|
// return list
|
|
|
|
|
// .firstWhere(
|
|
|
|
|
// (e) => e.title == title,
|
|
|
|
|
// orElse: () => InspectionChecklistItem(status: 'FAIL'),
|
|
|
|
|
// )
|
|
|
|
|
// .status ==
|
|
|
|
|
// 'PASS';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Map<String, bool> buildInspectionPayload(List<InspectionChecklistItem> checklist) {
|
|
|
|
|
// return {
|
|
|
|
|
// 'flagphysicalInspection': _isPass(checklist, 'Physical Inspection As Per Manufacturer Instructions'),
|
|
|
|
|
// 'flagFunctionPerformance': _isPass(checklist, 'Functional Performance As Per Results Of Manufacturer Recommended Check List'),
|
|
|
|
|
// 'flagGroundingResistance': _isPass(checklist, 'Grounding Resistance: Ω'),
|
|
|
|
|
// 'flagChassiss': _isPass(checklist, 'Chassis Leakage Current: µA'),
|
|
|
|
|
// 'flagLeadsLeakage': _isPass(checklist, 'Leads Leakage Current: µA'),
|
|
|
|
|
// 'flagAlert': _isPass(checklist, 'This Device Is Not Subject To Any Alert Or Recall Until The Date Of Preparation Of This Inspection Form'),
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// void applyInspectionFlagsToChecklist({
|
|
|
|
|
// required List<InspectionChecklistItem> checklist,
|
|
|
|
|
// required TechnicalInspectionParentAssetModel model,
|
|
|
|
|
// }) {
|
|
|
|
|
// for (final item in checklist) {
|
|
|
|
|
// switch (item.title) {
|
|
|
|
|
// case 'Physical Inspection As Per Manufacturer Instructions':
|
|
|
|
|
// item.status = _statusFromBool(model.flagphysicalInspection);
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'Functional Performance As Per Results Of Manufacturer Recommended Check List':
|
|
|
|
|
// item.status = _statusFromBool(model.flagFunctionPerformance);
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'Grounding Resistance: Ω':
|
|
|
|
|
// item.status = _statusFromBool(model.flagGroundingResistance);
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'Chassis Leakage Current: µA':
|
|
|
|
|
// item.status = _statusFromBool(model.flagChassiss);
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'Leads Leakage Current: µA':
|
|
|
|
|
// item.status = _statusFromBool(model.flagLeadsLeakage);
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'This Device Is Not Subject To Any Alert Or Recall Until The Date Of Preparation Of This Inspection Form':
|
|
|
|
|
// item.status = _statusFromBool(model.flagAlert);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// String _statusFromBool(bool? value) {
|
|
|
|
|
// return value == true ? 'PASS' : 'FAIL';
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|