|
|
|
|
@ -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,6 +537,17 @@ 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());
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|