bug fixes

main_production_attahment_type
WaseemAbbasi22 1 month ago
parent dd644732c9
commit 448a85522a

@ -68,6 +68,7 @@ import 'package:test_sa/modules/applicationDemo/providers/application_demo_reque
import 'package:test_sa/modules/applicationDemo/screens/application_demo_request_form_screen.dart';
import 'package:test_sa/modules/tm_module/gas_refill/create_gas_refill_request.dart';
import 'package:test_sa/modules/tm_module/gas_refill/update_gas_refill_request.dart';
import 'package:test_sa/modules/traf_module/create_traf_request_page.dart';
import 'package:test_sa/new_views/app_style/app_themes.dart';
import 'package:test_sa/new_views/pages/help_center_page.dart';
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
@ -145,6 +146,7 @@ import 'modules/tm_module/device_transfer/device_filter_screen.dart';
import 'modules/tm_module/device_transfer/device_search_screen.dart';
import 'modules/tm_module/tasks/create_task_view.dart';
import 'modules/tm_module/gas_refill/gas_refill_request_form.dart';
import 'modules/traf_module/traf_request_provider.dart';
import 'providers/lookups/classification_lookup_provider.dart';
import 'providers/lookups/customer_lookup_provider.dart';
import 'providers/lookups/department_lookup_provider.dart';
@ -387,6 +389,7 @@ class MyApp extends StatelessWidget {
// UTILITY PROVIDERS (1)
ChangeNotifierProvider(create: (_) => OracleCodeProvider(), lazy: true),
ChangeNotifierProvider(create: (_) => TrafRequestProvider(), lazy: true),
],
child: GestureDetector(
onTap: () {
@ -425,6 +428,7 @@ class MyApp extends StatelessWidget {
DeviceSearchScreen.id: (_) => const DeviceSearchScreen(),
DeviceFilterScreen.id: (_) => const DeviceFilterScreen(),
CreateIncidentRequestPage.id: (_) => CreateIncidentRequestPage(),
CreateTRAFRequestPage.id: (_) => CreateTRAFRequestPage(),
SettingsPage.id: (_) => const SettingsPage(),
ProfilePage.id: (_) => const ProfilePage(),
ReportBugPage.id: (_) => const ReportBugPage(),

@ -163,10 +163,19 @@ class GenericAttachmentModel {
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
originalName = json['originalName'];
}
GenericAttachmentModel.fromAssetInventoryJson(Map<String, dynamic> json) {
id = json['id'];
name = json['attachmentName'];
attachmentURL = json['attachmentURL'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
originalName = json['originalName'];
}
GenericAttachmentModel.fromTrafJson(Map<String, dynamic> json) {
id = json['id'];
moduleReferenceId= json['trafId'];
name = json['attachmentName'];
attachmentDescription = json['attachmentDescription'];
moduleReferenceId = json['trafId'];
documentType = json['attachmentType'] != null ? Lookup.fromJson(json['attachmentType']) : null;
}
@ -287,10 +296,19 @@ class GenericAttachmentModel {
data['originalName'] = originalName;
return data;
}
Map<String, dynamic> toAssetDeliveryJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['attachmentTypeId'] = documentType?.id;
data['originalName'] = originalName;
data['createdBy'] = createdBy;
return data;
}
Map<String, dynamic> toInventoryJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attachmentName'] = name;
data['Name'] = name;
data['attachmentURL'] = attachmentURL;
data['attachmentTypeId'] = documentType?.id;
data['originalName'] = originalName;
@ -302,7 +320,7 @@ class GenericAttachmentModel {
data['id'] = id;
data['trafId'] = moduleReferenceId;
data['attachmentName'] = name;
data['documentTypeId'] = documentType?.id;
data['attachmentTypeId'] = documentType?.id;
return data;
}

@ -34,6 +34,7 @@ class HelperFunction {
builder: (context) => AssetDeliveryAttachmentView(
tableItemId: deliveryTableItemId,
attachmentType: result!.value,
documentType: Lookup(id: result.id, value: result.value, name: result.name),
viewOnly: viewOnly,
attachmentList: list,
)));

@ -11,6 +11,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/request_attachment_type_enum.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/asset_delivery_module/provider/asset_delivery_provider.dart';
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
@ -26,6 +27,7 @@ import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
class AssetDeliveryAttachmentView extends StatefulWidget {
final int? tableItemId;
final int? attachmentType;
final Lookup? documentType;
bool viewOnly = false;
final List<GenericAttachmentModel> attachmentList;
@ -34,6 +36,7 @@ class AssetDeliveryAttachmentView extends StatefulWidget {
required this.attachmentList,
this.viewOnly = false,
this.attachmentType,
this.documentType,
this.tableItemId,
});
@ -76,73 +79,74 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
Navigator.pop(context);
},
),
body:Column(
body: Column(
children: [
Flexible(
fit: FlexFit.loose, // ✅ expands only as much as needed
child: Column(
children: [
Flexible(
fit: FlexFit.loose, // ✅ expands only as much as needed
child: Column(
children: [
widget.attachmentType == 5 && !widget.viewOnly
? AttachmentPicker(
label: context.translation.attachments,
showTypeDropdown: false,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
buttonColor: AppColor.primary10,
onlyImages: false,
showAsListView: true,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
onChange: (attachment) {},
).toShadowContainer(
context,
borderRadius: 20,
padding: 12,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
)
: Column(
children: [
InfoHeader16Widget("Attachments".addTranslation),
FilesList( showAsListView: true,
types: _attachments.map((doc) {
final attachmentType = doc.documentType?.name ?? '';
return attachmentType.isNotEmpty ? attachmentType : 'Asset Guide';
}).toList(),
images: _attachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '',).toList() ?? []).toShadowContainer(
context,
borderRadius: 20,
padding: 12,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
],
),
],
),
),
if (widget.attachmentType == 5 && !widget.viewOnly)
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Save'.addTranslation,
maxWidth: true,
onPressed: _onSavePressed,
),
),
widget.attachmentType == 5 && !widget.viewOnly
? AttachmentPicker(
label: context.translation.attachments,
showTypeDropdown: false,
attachment: _attachments,
moduleId: RequestAttachmentTypeEnum.assetDelivery.id,
buttonColor: AppColor.primary10,
documentType: widget.documentType,
onlyImages: false,
showAsListView: true,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
onChange: (attachment) {},
).toShadowContainer(
context,
borderRadius: 20,
padding: 12,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
)
: FilesList(
showAsListView: true,
types: _attachments.map((doc) {
final attachmentType = doc.documentType?.name ?? '';
return attachmentType.isNotEmpty ? attachmentType : 'Asset Guide';
}).toList(),
images: _attachments
.map(
(e) => URLs.getFileUrl(e.name ?? '') ?? '',
)
.toList() ??
[])
.toShadowContainer(
context,
borderRadius: 20,
padding: 12,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
],
),
),
if (widget.attachmentType == 5 && !widget.viewOnly)
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(
buttonColor: AppColor.primary10,
label: 'Save'.addTranslation,
maxWidth: true,
onPressed: _onSavePressed,
),
),
],
),
);
}
Future<void> _onSavePressed() async {
final List<GenericAttachmentModel> attachmentPayload = _attachments.map((item) {
final List<Map<String, dynamic>> attachmentPayload = _attachments.map((item) {
final String name = CMRequestUtils.isLocalUrl(item.name ?? '') ? '${item.name?.split("/").last}|${base64Encode(File(item.name!).readAsBytesSync())}' : item.name ?? '';
return GenericAttachmentModel(
id: item.id ?? 0,
name: name,
documentType: item.documentType,
);
documentType: widget.documentType,
).toAssetDeliveryJson();
}).toList();
showDialog(

@ -200,7 +200,7 @@ class AssetInventoryModel {
if (json['assetInventoryDetailAssetAttachments'] != null) {
assetInventoryDetailAssetAttachments = [];
json['assetInventoryDetailAssetAttachments'].forEach((v) {
assetInventoryDetailAssetAttachments.add(GenericAttachmentModel.fromAssetJson(v));
assetInventoryDetailAssetAttachments.add(GenericAttachmentModel.fromAssetInventoryJson(v));
});
}

@ -11,6 +11,7 @@ import 'package:test_sa/modules/asset_inventory_module/models/asset_inventory_mo
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
///TODO We are not showing attachment here we need to check this with backend team and flow .
class AssetDetailCardView extends StatelessWidget {
AssetInventoryModel assetInventoryModel;
VoidCallback onDeletePress;

@ -296,12 +296,7 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
classificationWidget(label: _scannedAssetModel?.status),
],
12.height,
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,

@ -54,7 +54,7 @@ class DemoRequestItemView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StatusLabel(
label: requestDetails!.status!,
label: requestDetails?.status??'',
textColor: AppColor.demoRequestStatusTextColor(context, requestDetails?.statusValue ?? 0),
backgroundColor: AppColor.demoRequestStatus(context, requestDetails?.statusValue ?? 0),
),

@ -26,6 +26,7 @@ import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/new_views/common_widgets/working_time_tile.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/total_working_time_detail_bottomsheet.dart';

@ -86,19 +86,19 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
StatusLabel(
label: model!.status!.name,
id: model!.status!.value,
label: model?.status?.name,
id: model?.status?.value,
radius: 4,
textColor: AppColor.getRequestStatusTextColorByName(
context,
model!.status!.name,
model?.status?.name,
),
backgroundColor: AppColor.getRequestStatusColorByName(
context,
model!.status!.name,
model?.status?.name,
),
),
InfoDateWidget(model!.createdDate?.toString() ?? ""),
InfoDateWidget(model?.createdDate?.toString() ?? ""),
],
),
8.height,
@ -117,6 +117,7 @@ class _SystemInternalAuditDetailPageState extends State<SystemInternalAuditDetai
if (allAttachments.isNotEmpty) ...[
const Divider().defaultStyle(context),
InfoHeader16Widget("Attachments".addTranslation),
8.height,
FilesList(
showAsListView: true,
types: allAttachments

@ -150,14 +150,16 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
if (_attachments.isNotEmpty) ...[
4.height,
InfoHeader16Widget("Attachments".addTranslation),
4.height,
FilesList(
showAsListView: true,
types: _attachments
.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList(),
images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList() ?? []),
showAsListView: true,
types: data.attachments
?.whereType<GenericAttachmentModel>()
.where((e) => e.documentType != null && e.documentType!.name!.isNotEmpty)
.map((toElement) => toElement.documentType!.name!)
.toList() ??
[],
images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList()),
],
],
).toShadowContainer(context);

@ -106,6 +106,7 @@ class _CreateRequestTypeBottomSheetState extends State<CreateRequestTypeBottomSh
icon: requestList[index].icon,
label: requestList[index].title,
onTap: () {
log('route name is ${requestList[index].routeName}');
Navigator.pushReplacementNamed(context, requestList[index].routeName);
},
),

@ -1,3 +1,4 @@
import 'dart:developer';
import 'dart:io';
import 'package:ellipsized_text/ellipsized_text.dart';
import 'package:flutter/gestures.dart';

@ -98,9 +98,11 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
vsync: this,
);
_animationController.forward();
// if (widget.documentType != null) {
// documentLookup = widget.documentType;
// }
WidgetsBinding.instance.addPostFrameCallback((_) {
Provider.of<AttachmentTypeLookupProviderLatest>(context, listen: false).reset();
log('i am going to reset the value');
});
}
@ -136,6 +138,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
file: image,
showAsListView: widget.showAsListView,
enabled: widget.enabled,
// documentType: widget.documentType != null ? widget.documentType?.name : widget.attachment[index].documentType?.name,
documentType: widget.attachment[index].documentType?.name,
onRemoveTap: (image) {
if (!widget.enabled) {
@ -186,7 +189,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
);
if (result != null) {
for (var path in result.paths) {
widget.attachment.add(GenericAttachmentModel(id: 0, name: File(path!).path, documentType: documentLookup));
widget.attachment.add(GenericAttachmentModel(id: 0, name: File(path!).path, documentType: widget.documentType ?? documentLookup));
}
if (widget.onChange != null) {
widget.onChange!(widget.attachment);
@ -229,8 +232,7 @@ 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 = !widget.showTypeDropdown?true:documentLookup != null;
bool isEnabled = !widget.showTypeDropdown ? true : documentLookup != null;
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
@ -305,7 +307,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
8.height,
InfoHeader16Widget(widget.pickerTitle),
8.height,
if(widget.showTypeDropdown)...[
if (widget.showTypeDropdown) ...[
SingleItemDropDownMenu<Lookup, AttachmentTypeLookupProviderLatest>(
context: context,
height: 56.toScreenHeight,
@ -325,7 +327,6 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
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,
@ -381,7 +382,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
pickedFiles.forEach((pickedFile) {
File fileImage = File(pickedFile.path);
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentType: documentLookup));
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentType: widget.documentType ?? documentLookup));
});
if (widget.onChange != null) {
widget.onChange!(widget.attachment);
@ -408,7 +409,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> with SingleTickerPr
}
}
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentType: documentLookup));
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentType: widget.documentType ?? documentLookup));
if (widget.onChange != null) {
widget.onChange!(widget.attachment);
}

Loading…
Cancel
Save