bug fixes

main_production_attahment_type
WaseemAbbasi22 1 month ago
parent 56322d8db3
commit dd644732c9

@ -117,7 +117,7 @@ class GenericAttachmentModel {
id = json['id'];
name = json['attachmentName'];
moduleReferenceId = json['gasRefillId'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
documentType = json['documentType'] != null ? Lookup.fromJson(json['documentType']) : null;
}
GenericAttachmentModel.fromIncidentJson(Map<String, dynamic> json) {
@ -199,8 +199,8 @@ class GenericAttachmentModel {
data['id'] = id;
data['attachmentName'] = name;
data['loanId'] = moduleReferenceId;
data['loanAttachmentTypeId'] = attachmentTypeId;
data['documentTypeId'] = documentType?.id;
data['loanAttachmentTypeId'] = documentType?.id;
// data['documentTypeId'] = documentType?.id;
data['attachmentDescription'] = attachmentDescription;
return data;
}
@ -221,16 +221,6 @@ class GenericAttachmentModel {
return data;
}
//TODO need to check where to use this need to verify with backend team.
Map<String, dynamic> toPpmJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['visitId'] = moduleReferenceId;
data['attachmentName'] = name;
data['documentTypeId'] = documentType?.id;
data['attachmentURL'] = attachmentURL;
return data;
}
Map<String, dynamic> toGasRefillJson() {
final Map<String, dynamic> data = <String, dynamic>{};
@ -246,7 +236,7 @@ class GenericAttachmentModel {
data['id'] = id;
data['attachmentName'] = name;
data['incidentId'] = moduleReferenceId;
data['documentTypeId'] = documentType?.id;
data['attachmentTypeId'] = documentType?.id;
data['attachmentDescription'] = attachmentDescription;
return data;
}
@ -255,7 +245,7 @@ class GenericAttachmentModel {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['documentTypeId'] = documentType?.id;
data['attachmentTypeId'] = documentType?.id;
return data;
}
@ -276,7 +266,7 @@ class GenericAttachmentModel {
data['id'] = id;
data['name'] = name;
data['originalName'] = originalName;
data['documentTypeId'] = documentType?.id;
data['attachmentTypeId'] = documentType?.id;
return data;
}
@ -284,7 +274,7 @@ class GenericAttachmentModel {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['documentTypeId'] = documentType?.id;
data['attachmentTypeId'] = documentType?.id;
return data;
}
@ -297,6 +287,15 @@ class GenericAttachmentModel {
data['originalName'] = originalName;
return data;
}
Map<String, dynamic> toInventoryJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['attachmentURL'] = attachmentURL;
data['attachmentTypeId'] = documentType?.id;
data['originalName'] = originalName;
return data;
}
Map<String, dynamic> toTrafJson() {
final Map<String, dynamic> data = <String, dynamic>{};

@ -76,9 +76,7 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
Navigator.pop(context);
},
),
body: widget.attachmentList.isEmpty
? const NoDataFound().center
: Column(
body:Column(
children: [
Flexible(
fit: FlexFit.loose, // ✅ expands only as much as needed
@ -87,6 +85,7 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
widget.attachmentType == 5 && !widget.viewOnly
? AttachmentPicker(
label: context.translation.attachments,
showTypeDropdown: false,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
buttonColor: AppColor.primary10,

@ -242,9 +242,7 @@ class AssetInventoryModel {
'newSupplierName': newSupplierName,
'photo': photo,
'remarks': remarks,
'assetInventoryDetailAssetAttachments': assetInventoryDetailAssetAttachments != null
? assetInventoryDetailAssetAttachments!.map((v) => v?.toAssetJson() ?? {}).toList()
: [],
'assetInventoryDetailAssetAttachments': assetInventoryDetailAssetAttachments.map((v) => v.toInventoryJson() ?? {}).toList(),
};
}

@ -43,11 +43,9 @@ class SessionModel {
statusName = json['statusName'];
startDate = json['startDate'];
endDate = json['endDate'];
if (json['assetInventorySites'] != null) {
assetInventorySites = (json['assetInventorySites'] as List).map((e) => Site.fromJson(e)).toList();
}
if (json['assetInventoryAssignedEmployee'] != null) {
assetInventoryAssignedEmployee = (json['assetInventoryAssignedEmployee'] as List).map((e) => AssetInventoryAssignedEmployee.fromJson(e)).toList();
}

@ -24,6 +24,7 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/equipment/asset_picker.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker_item.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../new_views/common_widgets/app_filled_button.dart';
import '../../../new_views/common_widgets/default_app_bar.dart';
@ -295,11 +296,12 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
classificationWidget(label: _scannedAssetModel?.status),
],
12.height,
Text(
'Attachments'.addTranslation,
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.white936),
),
InfoHeader16Widget('Attachments'.addTranslation),
// Text(
// 'Attachments'.addTranslation,
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.white936),
// ),
8.height,
AttachmentPicker(
moduleId: RequestAttachmentTypeEnum.assetInventory.id,
label: context.translation.attachFiles,
@ -409,7 +411,7 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
// try {
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_scannedAssetModel?.assetInventoryDetailAssetAttachments.add(GenericAttachmentModel(id: item.id, name: fileName,documentType: item.documentType));
_scannedAssetModel?.assetInventoryDetailAssetAttachments.add(GenericAttachmentModel(id: item.id, name: fileName, documentType: item.documentType));
}
// // } catch (error) {
// // print(error);

@ -629,7 +629,7 @@ class _CreateLoanRequestPageState extends State<CreateLoanRequestPage> with Tick
_loanFormModel.loanAttachment = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
_loanFormModel.loanAttachment?.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: 0));
_loanFormModel.loanAttachment?.add(GenericAttachmentModel(id: 0, name: fileName, moduleReferenceId: 0,documentType: item.documentType));
}
Utils.showLoading(context);
LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);

@ -1,3 +1,4 @@
import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
@ -99,10 +100,15 @@ class _WoInfoFormState extends State<WoInfoForm> {
@override
Widget build(BuildContext context) {
// double totalWorkingHours =
// widget.planPreventiveVisit.preventiveVisitTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
return Consumer<PpmProvider>(builder: (context, ppmProvider, child) {
ppmProvider.ppmPlanAttachments.forEach((e){
log('attachemnt type ${e.documentType}');
});
return ListView(
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
children: [

@ -45,6 +45,7 @@ class AttachmentPicker extends StatefulWidget {
final String pickerTitle;
final String label;
final bool error;
final bool showTypeDropdown;
final int moduleId;
final List<GenericAttachmentModel> attachment;
final bool enabled, onlyImages;
@ -75,6 +76,7 @@ class AttachmentPicker extends StatefulWidget {
// this.showAsListView = false,
this.pickMultiple = false,
this.checkQuality = false,
this.showTypeDropdown = true,
this.child,
this.buttonColor})
: super(key: key);
@ -227,7 +229,8 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
return StatefulBuilder(
builder: (BuildContext context, StateSetter setModalState) {
Widget listCard({required String icon, required String label, required VoidCallback onTap}) {
bool isEnabled = documentLookup != null;
bool isEnabled = !widget.showTypeDropdown?true:documentLookup != null;
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
@ -302,24 +305,27 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
8.height,
InfoHeader16Widget(widget.pickerTitle),
8.height,
SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProviderLatest>(
context: context,
height: 56.toScreenHeight,
requestById: widget.moduleId,
title: "Document Type",
initialValue: documentLookup,
showShadow: false,
backgroundColor: AppColor.fieldBgColor(context),
showAsBottomSheet: true,
onSelect: (value) {
documentLookup = value;
setModalState(() {});
},
),
if (documentLookup == null) ...[
4.height,
const InfoTextLabelWidget(label: 'Please Select Document Type before picking file', color: AppColor.red30),
if(widget.showTypeDropdown)...[
SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProviderLatest>(
context: context,
height: 56.toScreenHeight,
requestById: widget.moduleId,
title: "Document Type",
initialValue: documentLookup,
showShadow: false,
backgroundColor: AppColor.fieldBgColor(context),
showAsBottomSheet: true,
onSelect: (value) {
documentLookup = value;
setModalState(() {});
},
),
if (documentLookup == null) ...[
4.height,
const InfoTextLabelWidget(label: 'Please Select Document Type before picking file', color: AppColor.red30),
],
],
GridView.builder(
padding: const EdgeInsets.only(top: 16, bottom: 0),
shrinkWrap: true,

Loading…
Cancel
Save