Compare commits

...

2 Commits

@ -3,13 +3,13 @@ class URLs {
static const String appReleaseBuildNumber = "40";
static const host1 = "https://atomsm.hmg.com"; // production url
// static const host1 = "https://atomsm.hmg.com"; // production url
// static const host1 = "https://atomsmdev.hmg.com"; // local DEV url
// static const host1 = "https://atomsmuat.hmg.com"; // local UAT url
static const host1 = "https://atomsmuat.hmg.com"; // local UAT url
// static final String _baseUrl = "$_host/mobile"; // host local UAT
static final String _baseUrl = "$_host/mobile"; // host local UAT
// static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis
static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM
// static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM
// static final String _baseUrl = "$_host/v4/mobile"; // v4 for Demo module
// static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation
// static final String _baseUrl = "$_host/v6/mobile"; // for asset delivery module

@ -1,3 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
@ -7,13 +10,13 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/helper/utils.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/traf_department.dart';
import 'package:test_sa/models/new_models/users_based_on_search_model.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';
import 'package:test_sa/modules/traf_module/asset_auto_complete_field.dart';
import 'package:test_sa/modules/traf_module/traf_request_detail_page.dart';
import 'package:test_sa/modules/traf_module/update_traf_request_page.dart';
import 'package:test_sa/modules/traf_module/users_auto_complete_field.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -21,11 +24,11 @@ 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/multiple_item_drop_down_menu.dart';
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/providers/lookups/department_lookup_provider.dart';
import 'package:test_sa/providers/lookups/request_type_lookup_provider.dart';
import 'package:test_sa/providers/lookups/yes_no_lookup_provider.dart';
import 'package:test_sa/views/widgets/equipment/asset_picker.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'traf_request_model.dart';
import 'traf_request_provider.dart';
@ -58,6 +61,7 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
List<TrafDepartment> departments = [];
List<UsersBasedOnSearchModel> userBasedOnSearch = [];
List<GenericAttachmentModel> attachments = [];
FocusNode otherServicesEffectsNode = FocusNode();
FocusNode useInCombinationNode = FocusNode();
@ -443,9 +447,21 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
trafRequest?.usedWithCombination = value;
},
),
]
],
12.height,
AttachmentPicker(
label: context.translation.attachFiles,
attachment: attachments,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
onChange: (attachment) {
attachments = attachment;
},
),
],
).toShadowContainer(context, padding: 12, borderRadius: 20),
16.height,
Row(
children: [
@ -521,8 +537,19 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
return;
}
// Process attachments similar to CreateCMRequest
trafRequest?.attachments = [];
for (var item in attachments) {
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '')
? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}")
: item.name ?? '';
trafRequest?.attachments!.add(
Attachments(id: 0, trafId: 0, attachmentName: fileName),
);
}
Utils.showLoading(context);
bool isSuccess = await Provider.of<TrafRequestProvider>(context, listen: false).addTraf(trafRequest!.toJson());
bool isSuccess = await Provider.of<TrafRequestProvider>(context, listen: false).addTraf(trafRequest!.toJsonNew());
Utils.hideLoading(context);
if (isSuccess) {
Navigator.pop(context);

@ -1,8 +1,12 @@
import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:provider/provider.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';
@ -12,9 +16,11 @@ import 'package:test_sa/modules/traf_module/update_traf_request_page.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/widgets/images/files_list.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
import '../../controllers/api_routes/urls.dart';
import 'asset_analytics_model.dart';
import 'traf_request_model.dart';
@ -32,10 +38,14 @@ class TrafRequestDetailPage extends StatefulWidget {
}
class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
List<File> _attachments = [];
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
Provider.of<TrafRequestProvider>(context, listen: false).getTRAFById(widget.trafId);
});
}
@override
@ -53,6 +63,9 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
builder: (_, isLoading, __) {
if (isLoading) return const ALoading();
TrafRequestProvider trafProvider = Provider.of<TrafRequestProvider>(context, listen: false);
if (trafProvider.trafRequestDataModel?.attachments != null) {
_attachments = trafProvider.trafRequestDataModel!.attachments!.map((e) => File(URLs.getFileUrl(e.attachmentName ?? '') ?? '')).toList();
}
return trafProvider.trafRequestDataModel == null
? const NoDataFound().center
: Column(
@ -118,6 +131,10 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
8.height,
'TRAF No: ${data.reqCode ?? '-'}'.bodyText(context),
'Request type: ${data.requestTypeName ?? '-'}'.bodyText(context),
if (data.requestTypeValue == 1) ...[
4.height,
'Requested Quantity: ${data.qty ?? '-'}'.bodyText(context),
],
4.height,
'How would the requested technology solve the current situation and/or serve the purpose?: ${data.purposeAnswer ?? '-'}'.bodyText(context),
4.height,
@ -148,6 +165,15 @@ class _TrafRequestDetailPageState extends State<TrafRequestDetailPage> {
4.height,
'Equipment going to be used with combination of other equipments:\n${data.usedWithCombination ?? '-'}'.bodyText(context),
],
if (_attachments.isNotEmpty) ...[
4.height,
Text(
"Attachments".addTranslation,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
),
// 8.height,
FilesList(images: _attachments.map((e) => URLs.getFileUrl(e.path ?? '') ?? '').toList() ?? []),
],
],
).toShadowContainer(context, borderRadius: 20, padding: 12);
}

@ -88,10 +88,12 @@ class TrafRequestDataModel {
String? isEffectedName;
String? effectedServices;
int? isCombinationId;
int?requestTypeValue;
String? isCombinationName;
String? usedWithCombination;
String? comment;
List<Attachments>? attachments;
bool? isFromMobile;
int? isBudgetId;
String? isBudgetName;
String? firstLineManagerId;
@ -186,9 +188,11 @@ class TrafRequestDataModel {
this.isEffectedName,
this.effectedServices,
this.isCombinationId,
this.requestTypeValue,
this.isCombinationName,
this.usedWithCombination,
this.comment,
this.isFromMobile = true,
this.attachments,
this.isBudgetId,
this.isBudgetName,
@ -299,9 +303,11 @@ class TrafRequestDataModel {
isEffectedName = json['isEffectedName'];
effectedServices = json['effectedServices'];
isCombinationId = json['isCombinationId'];
requestTypeValue = json['requestTypeValue'];
isCombinationName = json['isCombinationName'];
usedWithCombination = json['usedWithCombination'];
comment = json['comment'];
isFromMobile = json['isFromMobile'];
if (json['attachments'] != null) {
attachments = <Attachments>[];
json['attachments'].forEach((v) {
@ -415,9 +421,11 @@ class TrafRequestDataModel {
data['isEffectedName'] = this.isEffectedName;
data['effectedServices'] = this.effectedServices;
data['isCombinationId'] = this.isCombinationId;
data['requestTypeValue'] = this.requestTypeValue;
data['isCombinationName'] = this.isCombinationName;
data['usedWithCombination'] = this.usedWithCombination;
data['comment'] = this.comment;
data['isFromMobile'] = this.isFromMobile;
if (this.attachments != null) {
data['attachments'] = this.attachments!.map((v) => v.toJson()).toList();
} else {
@ -474,6 +482,67 @@ class TrafRequestDataModel {
data['modifiedDate'] = this.modifiedDate;
return data;
}
Map<String, dynamic> toJsonNew() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['reqNo'] = reqNo;
data['reqCode'] = reqCode;
data['employeeId'] = employeeId;
data['positionId'] = positionId;
data['departments'] =
departments?.map((v) => v.toJson()).toList() ?? [];
if (this.trafDepartments != null) {
data['trafDepartments'] = this.trafDepartments!.map((v) => v.toJson()).toList();
}
data['siteId'] = siteId;
data['siteName'] = siteName;
data['requesterExtensionNumber'] = requesterExtensionNumber;
data['requesterExtensionName'] = requesterExtensionName;
data['requesterExtensionPositionId'] = requesterExtensionPositionId;
data['requestTypeId'] = requestTypeId;
data['assetNDId'] = assetNDId;
data['assetId'] = assetId;
data['qty'] = qty;
data['purposeAnswer'] = purposeAnswer;
data['currentPractise'] = currentPractise;
data['censusQ1'] = censusQ1;
data['censusQ2'] = censusQ2;
data['censusQ3'] = censusQ3;
data['censusQ4'] = censusQ4;
data['isFromMobile'] = isFromMobile;
data['trafContacts'] =
trafContacts?.map((v) => v.toJson()).toList() ?? [];
data['usingSolelyOrSharedId'] = usingSolelyOrSharedId;
data['isEffectedId'] = isEffectedId;
data['effectedServices'] = effectedServices;
data['isCombinationId'] = isCombinationId;
data['usedWithCombination'] = usedWithCombination;
data['comment'] = comment;
data['isBudgetId'] = isBudgetId;
data['attachments'] =
attachments?.map((v) => v.toJson()).toList() ?? [];
return data;
}
}
class TrafContacts {

@ -593,14 +593,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.2.0"
flutter_vibrate:
dependency: "direct main"
description:
name: flutter_vibrate
sha256: "6eea0e94dd7dc8c7872e994a1139d55a8640e32fd5898ff59ee8bd53b8dea3b3"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
flutter_web_plugins:
dependency: transitive
description: flutter
@ -718,6 +710,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
haptic_feedback:
dependency: "direct main"
description:
name: haptic_feedback
sha256: dcc2494994c41428823f8f2082fd17a4e89e372bd142e07681420cbfaf99dcad
url: "https://pub.dev"
source: hosted
version: "0.6.4+3"
hooks:
dependency: transitive
description:
@ -1002,10 +1002,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
url: "https://pub.dev"
source: hosted
version: "0.12.18"
version: "0.12.19"
material_color_utilities:
dependency: transitive
description:
@ -1074,10 +1074,10 @@ packages:
dependency: "direct main"
description:
name: nfc_manager
sha256: "24c78b0e5702da53e7f8794d073624c0bee7cd99924f257cbd11f5d1c5866879"
sha256: "1b8d3788ed71bb34f59878a445e433891eb2268353289515c1542b2780151fe6"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
version: "4.2.1"
objective_c:
dependency: transitive
description:
@ -1719,10 +1719,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
url: "https://pub.dev"
source: hosted
version: "0.7.9"
version: "0.7.10"
timezone:
dependency: transitive
description:
@ -1940,5 +1940,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.11.0 <4.0.0"
flutter: ">=3.38.5"
dart: ">=3.11.4 <4.0.0"
flutter: ">=3.38.4"

Loading…
Cancel
Save