cleanup code
This commit is contained in:
@@ -258,7 +258,7 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
|
||||
Future<void> createReceiving(
|
||||
User user, Package package, List<File?> files) async {
|
||||
User? user, Package package, List<File?>? files) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class PackageModel extends BaseModel {
|
||||
throw Exception("Exceed number of file upload");
|
||||
}
|
||||
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
List<String> urls = await uploadFiles(path, files);
|
||||
package.photoUrls = urls;
|
||||
@@ -284,26 +284,26 @@ class PackageModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateReceiving(User user, Package package, List<File?> files,
|
||||
Future<void> updateReceiving(User? user, Package package, List<File?> files,
|
||||
List<String?> deletedUrls) async {
|
||||
if (user != null) {
|
||||
package.fcsID = user.fcsID;
|
||||
}
|
||||
if (deletedUrls != null) {
|
||||
if (deletedUrls.isNotEmpty) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
if (files.isNotEmpty) {
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
uploadedURL = await uploadFiles(path, files);
|
||||
uploadedURL.forEach((url) {
|
||||
@@ -329,20 +329,20 @@ class PackageModel extends BaseModel {
|
||||
|
||||
Future<void> updateProcessing(
|
||||
Package package, List<File?> files, List<String?> deletedUrls) async {
|
||||
if (deletedUrls != null) {
|
||||
if (deletedUrls.isNotEmpty) {
|
||||
for (String? url in deletedUrls) {
|
||||
package.photoUrls.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> uploadedURL = [];
|
||||
if (files != null) {
|
||||
if (files.isNotEmpty) {
|
||||
var count =
|
||||
(package.photoUrls.length) + files.length - (deletedUrls.length);
|
||||
|
||||
if (count > uploadPhotoLimit)
|
||||
throw Exception("Exceed number of file upload");
|
||||
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
|
||||
package.photoUrls = package.photoUrls;
|
||||
String path = Path.join(pkg_files_path);
|
||||
uploadedURL = await uploadFiles(path, files);
|
||||
uploadedURL.forEach((url) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/market/market_editor.dart';
|
||||
import 'package:fcs/pages/market/model/market_model.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
@@ -226,8 +225,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
|
||||
try {
|
||||
_package!.desc = _descCtl.text;
|
||||
_package!.remark = _remarkCtl.text;
|
||||
@@ -252,8 +250,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
|
||||
try {
|
||||
// await packageModel.deletePackage(_package);
|
||||
Navigator.pop<bool>(context, true);
|
||||
|
||||
@@ -3,9 +3,7 @@ import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
@@ -187,7 +185,7 @@ class _PackageNewState extends State<PackageNew> {
|
||||
}
|
||||
|
||||
_create() async {
|
||||
if (user == null || packages == null || packages.length == 0) {
|
||||
if (user == null || packages.length == 0) {
|
||||
showMsgDialog(context, "Error", "Invalid user!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,12 @@ import 'package:fcs/pages/market/market_editor.dart';
|
||||
import 'package:fcs/pages/market/model/market_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
const MANAGE_MARKET = "Manage Market";
|
||||
|
||||
Reference in New Issue
Block a user