New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add all scanned products to list #3401
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3401 +/- ##
===========================================
+ Coverage 10.32% 11.27% +0.94%
===========================================
Files 260 260
Lines 12595 12575 -20
===========================================
+ Hits 1301 1418 +117
+ Misses 11294 11157 -137
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK @M123-dev, but there is a couple of remarks that are rather important:
- you should
await
when you update withasync
- it would be great to code a distinct dialog method that lets the user select user lists (and create new ones)
Feel free to dismiss the other comments.
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
I did some refactoring @monsieurtanuki hopefully all your suggestions should be adressed with this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev!
I have the funny impression that you did refactor, but not in the direction I suggested - I had in mind an agnostic selectedLists selectUserLists(allLists, initiallySelectedLists)
dialog method.
That doesn't help my review, especially as these days I have limited time to dedicate to the project.
Feel free to ignore my comments and to merge anyway, as long as the code works as intended.
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
formKey, | ||
textEditingController, | ||
), | ||
onFieldSubmitted: (_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot see the added value of removing method _onNewListValueSubmitted
as it's called twice,
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev!
Again, I cannot say that there's something obviously wrong in your code, it's just that I imagined a different way to code it - and there are tons of ways to code it anyway.
Feel free to merge any time.
Sorry for my absence on this PR, had a lot of exams over the last few weeks 😄 Now everything should be done, the lists are preselected if all barcodes to add are included and the dialog is a little more abstract so that it can be reused more often. Feel free to have a look at the changes or just merge @monsieurtanuki 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev!
Obviously you don't like my concept of "method that returns the product lists selected by the user". Fair enough.
Please have a look at my comments: I'm afraid there are some await
missing.
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart
Outdated
Show resolved
Hide resolved
.bulkInsert(ProductList.user(name), widget.barcodes.toList()); | ||
} | ||
builder: (BuildContext context) => _UserLists( | ||
lists: lists.toSet(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may loose the order, mayn't you? (for the record that's my first "mayn't you?")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://api.dart.dev/stable/2.18.1/dart-core/Set/toSet.html
Creates a Set with the same elements and behavior as this Set.
The returned set behaves the same as this set with regard to adding and removing elements. It initially contains the same elements. If this set specifies an ordering of the elements, the returned set will have the same order.
Just double checked your may :D
Looks like the order is kept and this wouldn't be a problem would it? The lists in the list screen are also ordered alphabetically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this set specifies an ordering of the elements
I don't know what that means. We just add items. The set itself does not specify anything, does it?
I don't like this dart
confusion with tacitly "ordered" Set
s.
and this wouldn't be a problem
That would be a minor problem, I'll give you that.
I hope you passed ;) |
Added the awaits + renamed the one list and no I don't have something against a method which returns the selected lists I only think that it's simpler to understand this way. Returning the lists would mean we have a method which returns the return of a showAlert which would (preferably) show a StatelessWidget which would need to pop them. Doable but not as easy to read. And thanks 😄 |
Then we disagree on that matter. Not a big deal though.
As far as I remember you cannot display a
You're welcome :) Please get rid of the first And then we're probably done. |
I removed the loading dialog but we still need the async call for all lists, later we only get the lists which should be selected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev!
Looks ok to me - you're right, you have to call twice the "getUserLists" method, once for all lists and once for the lists that contain the barcodes.
@@ -224,31 +224,31 @@ class DaoProductList extends AbstractDao { | |||
/// Adds or removes list of barcodes to/from a [productList] in one go (depending on [include]) | |||
Future<void> bulkSet( | |||
final ProductList productList, | |||
final List<String> barcodesToAdd, { | |||
List<String> barcodes, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List<String> barcodes, { | |
final List<String> barcodes, { |
), | ||
) ?? | ||
<String>[]; | ||
final List<String> selectedLists = await daoProductList.getUserLists( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would be better off calling it in the first place with the parameters, wouldn't we?
cf. just above:
final List<String>? lists = await LoadingDialog.run<List<String>>(
context: context,
future: daoProductList.getUserLists(),
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't follow what you mean by this,
having both calls (with and without barcode filter) directly next to eachother?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed it was possible to get both data (all lists and all lists with barcodes) with one call, but that's not the case.
You're right: we do need two calls.
.bulkInsert(ProductList.user(name), widget.barcodes.toList()); | ||
} | ||
builder: (BuildContext context) => _UserLists( | ||
lists: lists.toSet(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this set specifies an ordering of the elements
I don't know what that means. We just add items. The set itself does not specify anything, does it?
I don't like this dart
confusion with tacitly "ordered" Set
s.
and this wouldn't be a problem
That would be a minor problem, I'll give you that.
I agree with you it's not written very explicitly, my guess is that it just keeps the order of the list. I started switching to sets here so that we avoid dublicates in lists from the ground up. |
I think it's a false good idea. As long as we need sorted collections and that we do handle the duplicates, switching to @M123-dev Anyway, you started this PR 3 weeks ago, the conversation level is 51, I approved 3 times including the latest version 6 hours ago, so without further ado please merge unless something really problematic is still there. |
Thanks for the review @monsieurtanuki |
What
Now you can add all scanned products to a List
For: Add all scanned products to a list in a couple clicks #3371
+ Changed an Ink to a Container for the problem mentioned in Discussion: The delete gestures are not equal #2985, the content moving out of the card. Not the card moving