Implemented new set article mechanism for unscannable articles
This commit is contained in:
@ -23,6 +23,10 @@ class _ArticleListItem extends State<ArticleListItem> {
|
||||
Color? color;
|
||||
Color? textColor;
|
||||
|
||||
if (!widget.article.scannable) {
|
||||
amount = widget.article.amount;
|
||||
}
|
||||
|
||||
if (amount == 0) {
|
||||
color = Colors.redAccent;
|
||||
textColor = Theme.of(context).colorScheme.onSecondary;
|
||||
@ -56,7 +60,8 @@ class _ArticleListItem extends State<ArticleListItem> {
|
||||
),
|
||||
);
|
||||
|
||||
if (widget.article.unscanned()) {
|
||||
if ((widget.article.unscanned() && widget.article.scannable) ||
|
||||
!widget.article.scannable && widget.article.amount == 0) {
|
||||
actionButton = IconButton.outlined(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(Colors.blueAccent),
|
||||
|
||||
@ -20,33 +20,86 @@ class ResetArticleAmountDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ResetArticleAmountDialogState extends State<ResetArticleAmountDialog> {
|
||||
int _selectedAmount = 1;
|
||||
|
||||
void _reset() {
|
||||
context.read<TourBloc>().add(
|
||||
ResetScanAmountEvent(
|
||||
articleId: widget.article.internalId.toString(),
|
||||
deliveryId: widget.deliveryId,
|
||||
),
|
||||
);
|
||||
String deliveryId = widget.deliveryId;
|
||||
String articleId = widget.article.internalId.toString();
|
||||
|
||||
if (widget.article.scannable) {
|
||||
context.read<TourBloc>().add(
|
||||
ResetScanAmountEvent(
|
||||
articleId: widget.article.internalId.toString(),
|
||||
deliveryId: widget.deliveryId,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
debugPrint("ID: $articleId");
|
||||
debugPrint("AMOUNT :$_selectedAmount");
|
||||
|
||||
context.read<TourBloc>().add(
|
||||
SetArticleAmountEvent(
|
||||
deliveryId: deliveryId,
|
||||
articleId: articleId,
|
||||
amount: _selectedAmount,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
Widget _amountSelection() {
|
||||
final list = List.generate(3, (index) => index + 1);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Anzahl:", style: Theme.of(context).textTheme.labelLarge),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children:
|
||||
list
|
||||
.map(
|
||||
(index) => ChoiceChip(
|
||||
label: Text("$index"),
|
||||
selected: _selectedAmount == index,
|
||||
onSelected: (bool selected) {
|
||||
setState(() {
|
||||
_selectedAmount = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Anzahl Artikel zurücksetzen?"),
|
||||
content: SizedBox(
|
||||
height: 120,
|
||||
height: MediaQuery.of(context).size.height * 0.25,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text("Wollen Sie die entfernten Artikel wieder hinzufügen?"),
|
||||
!widget.article.scannable ? _amountSelection() : Container(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
FilledButton(
|
||||
onPressed: _reset,
|
||||
child: const Text("Zurücksetzen"),
|
||||
child:
|
||||
widget.article.scannable
|
||||
? const Text("Zurücksetzen")
|
||||
: const Text("Hinzufügen"),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
|
||||
@ -7,7 +7,11 @@ import 'package:hl_lieferservice/feature/delivery/bloc/tour_event.dart';
|
||||
import '../../../../../model/article.dart';
|
||||
|
||||
class ArticleUnscanDialog extends StatefulWidget {
|
||||
const ArticleUnscanDialog({super.key, required this.article, required this.deliveryId});
|
||||
const ArticleUnscanDialog({
|
||||
super.key,
|
||||
required this.article,
|
||||
required this.deliveryId,
|
||||
});
|
||||
|
||||
final String deliveryId;
|
||||
final Article article;
|
||||
@ -23,14 +27,32 @@ class _ArticleUnscanDialogState extends State<ArticleUnscanDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
void _unscan() {
|
||||
context.read<TourBloc>().add(
|
||||
UnscanArticleEvent(
|
||||
deliveryId: widget.deliveryId,
|
||||
articleId: widget.article.internalId.toString(),
|
||||
newAmount: int.parse(unscanAmountController.text),
|
||||
reason: unscanNoteController.text,
|
||||
),
|
||||
);
|
||||
int amountToBeDeleted = int.parse(unscanAmountController.text);
|
||||
String deliveryId = widget.deliveryId;
|
||||
String articleId = widget.article.internalId.toString();
|
||||
String reason = unscanNoteController.text;
|
||||
|
||||
if (widget.article.scannable) {
|
||||
context.read<TourBloc>().add(
|
||||
UnscanArticleEvent(
|
||||
deliveryId: deliveryId,
|
||||
articleId: articleId,
|
||||
newAmount: amountToBeDeleted,
|
||||
reason: reason,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// If the article is not scannable we need to adjust the quantity of the article
|
||||
// directly.
|
||||
context.read<TourBloc>().add(
|
||||
SetArticleAmountEvent(
|
||||
deliveryId: deliveryId,
|
||||
articleId: articleId,
|
||||
amount: widget.article.amount - amountToBeDeleted,
|
||||
reason: reason
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
@ -136,6 +136,9 @@ class _DeliveryDetailState extends State<DeliveryDetail> {
|
||||
driverSignature: driver,
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
Widget _stepsNavigation(Delivery delivery) {
|
||||
|
||||
@ -117,8 +117,6 @@ class _SignatureViewState extends State<SignatureView> {
|
||||
builder: (context, state) {
|
||||
final current = state;
|
||||
|
||||
debugPrint("STATE: $current");
|
||||
|
||||
if (current is NoteLoaded) {
|
||||
if (current.notes.isEmpty) {
|
||||
return const SizedBox(
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:hl_lieferservice/dto/discount_remove_response.dart';
|
||||
import 'package:hl_lieferservice/dto/discount_update_response.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/repository/note_repository.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/service/notes_service.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/service/delivery_info_service.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/service/tour_service.dart';
|
||||
import 'package:hl_lieferservice/model/delivery.dart';
|
||||
|
||||
class DeliveryRepository {
|
||||
|
||||
Reference in New Issue
Block a user