Merge remote-tracking branch 'origin/demo_branch' into demo_branch

# Conflicts:
#	lib/views/pages/user/gas_refill/gas_refill_form.dart
design_3.0_task_module_new
Sikander Saleem 7 months ago
commit f50ede8321

@ -28,7 +28,6 @@ class GasRefillProvider extends ChangeNotifier {
building = null; building = null;
floor = null; floor = null;
department = null; department = null;
gasRefillAttachments.clear();
} }
// state code of current request to defied error message // state code of current request to defied error message
@ -46,14 +45,6 @@ class GasRefillProvider extends ChangeNotifier {
// done _loading = true // done _loading = true
// failed _loading = false // failed _loading = false
bool isLoading = false; bool isLoading = false;
List<File> _gasRefillAttachments = [];
List<File> get gasRefillAttachments => _gasRefillAttachments;
set gasRefillAttachments(List<File> value) {
_gasRefillAttachments = value;
notifyListeners();
}

@ -267,7 +267,10 @@ class GasRefillModel {
employeeId = model.employeeId; employeeId = model.employeeId;
name = model.name; name = model.name;
techComment = model.techComment; techComment = model.techComment;
gasRefillAttachments = model.gasRefillAttachments;
createdDate = model.createdDate; createdDate = model.createdDate;
workingHours = model.workingHours;
gasRefillTimers=model.gasRefillTimers;
} }
GasRefillModel copyWith({ GasRefillModel copyWith({

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
@ -45,6 +46,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
Lookup? _requestedQuantity; Lookup? _requestedQuantity;
final TextEditingController _commentController = TextEditingController(); final TextEditingController _commentController = TextEditingController();
GasRefillProvider? _gasRefillProvider; GasRefillProvider? _gasRefillProvider;
List<File> _files = [];
static List<Lookup> gasQuantity = [ static List<Lookup> gasQuantity = [
Lookup(name: "1", id: 1, value: 1), Lookup(name: "1", id: 1, value: 1),
@ -61,13 +63,11 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
_gasModel =GasRefillModel(); _gasModel =GasRefillModel();
_currentDetails = GasRefillDetails(); _currentDetails = GasRefillDetails();
_gasModel = GasRefillModel(gasRefillDetails: []); _gasModel = GasRefillModel(gasRefillDetails: []);
_gasRefillProvider!.gasRefillAttachments.clear();
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
_gasRefillProvider!.gasRefillAttachments.clear();
} }
@override @override
@ -220,7 +220,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
8.height, 8.height,
MultiFilesPicker( MultiFilesPicker(
label: context.translation.attachFiles, label: context.translation.attachFiles,
files: _gasRefillProvider!.gasRefillAttachments, files:_files,
buttonColor: AppColor.black10, buttonColor: AppColor.black10,
onlyImages: false, onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
@ -243,7 +243,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
_gasModel.gasRefillDetails=[]; _gasModel.gasRefillDetails=[];
_gasModel.gasRefillDetails?.add(_currentDetails); _gasModel.gasRefillDetails?.add(_currentDetails);
_gasModel.gasRefillAttachments = []; _gasModel.gasRefillAttachments = [];
for (var item in _gasRefillProvider!.gasRefillAttachments) { for (var item in _files) {
_gasModel.gasRefillAttachments?.add(GasRefillAttachments( _gasModel.gasRefillAttachments?.add(GasRefillAttachments(
id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path));
} }

@ -687,6 +687,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
if (employee == null) { if (employee == null) {
widget.formModel?.assistantEmployees = []; widget.formModel?.assistantEmployees = [];
} else { } else {
selectedEmployee = employee;
widget.formModel?.assistantEmployees = [employee.copyWith(id: 0)]; widget.formModel?.assistantEmployees = [employee.copyWith(id: 0)];
widget.formModel?.modelAssistantEmployees?.employeeId = employee.user?.id; widget.formModel?.modelAssistantEmployees?.employeeId = employee.user?.id;
} }

@ -62,6 +62,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
bool _firstTime = true; bool _firstTime = true;
Lookup? _deliveredQuantity; Lookup? _deliveredQuantity;
List<File> _attachments = [];
static List<Lookup> deliveredQuantity = [ static List<Lookup> deliveredQuantity = [
Lookup(name: "1", id: 1, value: 1), Lookup(name: "1", id: 1, value: 1),
@ -79,9 +80,8 @@ class _GasRefillFormState extends State<GasRefillForm> {
if (widget.gasRefillModel != null) { if (widget.gasRefillModel != null) {
_formModel.fromGasRefillModel(widget.gasRefillModel!); _formModel.fromGasRefillModel(widget.gasRefillModel!);
// totalWorkingHours = totalWorkingHours =
// _formModel?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0; _formModel.gasRefillTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDate!).difference(DateTime.parse(item.startDate!)).inSeconds) ?? 0;
_commentController.text = _formModel.techComment ?? ""; _commentController.text = _formModel.techComment ?? "";
try { try {
_deliveredQuantity = deliveredQuantity.singleWhere((element) => element.value == _formModel.gasRefillDetails![0].deliverdQty); _deliveredQuantity = deliveredQuantity.singleWhere((element) => element.value == _formModel.gasRefillDetails![0].deliverdQty);
@ -89,8 +89,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
} catch (ex) {} } catch (ex) {}
} }
if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) { if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) {
_gasRefillProvider?.gasRefillAttachments = []; _attachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList());
_gasRefillProvider?.gasRefillAttachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList());
} }
} }
@ -130,9 +129,9 @@ class _GasRefillFormState extends State<GasRefillForm> {
); );
}); });
_formModel.gasRefillAttachments = []; _formModel.gasRefillAttachments = [];
for (var item in _gasRefillProvider!.gasRefillAttachments) { for (var item in _attachments) {
_formModel.gasRefillAttachments?.add(GasRefillAttachments( _formModel.gasRefillAttachments
id: 0, gasRefillId: _formModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path)); ?.add(GasRefillAttachments(id: 0,gasRefillId: _formModel.id??0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path));
} }
await _gasRefillProvider?.updateGasRefill(status: status, model: _formModel).whenComplete(() { await _gasRefillProvider?.updateGasRefill(status: status, model: _formModel).whenComplete(() {
if (status == 1) { if (status == 1) {
@ -287,7 +286,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
16.height, 16.height,
MultiFilesPicker( MultiFilesPicker(
label: context.translation.attachFiles, label: context.translation.attachFiles,
files: _gasRefillProvider!.gasRefillAttachments, files: _attachments,
buttonColor: AppColor.black10, buttonColor: AppColor.black10,
onlyImages: false, onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),

Loading…
Cancel
Save