-
-
Notifications
You must be signed in to change notification settings - Fork 368
fix: Removed the option to add an item through barcode from Add a Price page #6525
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
base: develop
Are you sure you want to change the base?
fix: Removed the option to add an item through barcode from Add a Price page #6525
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6525 +/- ##
==========================================
- Coverage 9.54% 5.84% -3.71%
==========================================
Files 325 499 +174
Lines 16411 29827 +13416
==========================================
+ Hits 1567 1744 +177
- Misses 14844 28083 +13239 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 @Abhishek-P0207!
Correct me if I'm wrong, but you've just removed the "add a product" block altogether, right?
That's not what was supposed to be done:
- there are cases when we land on that page from a single product page, and in that case only we shouldn't be able to add products
- there are cases when we land on that page from a "add prices from receipt" button, and in that case we should definitely be able to add products (especially as we start with an empty list of products)
Hmm , I will fix it. |
@monsieurtanuki I fixed it, but I have a doubt regarding the "Add price tags" button in the prices section. |
The "Add price tags" should not have option of Add an item right? |
You did? Where's the code?
That's correct
Don't worry, keep it that way. |
@monsieurtanuki The issue is fixed, please review it. |
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 @Abhishek-P0207!
Unfortunately your solution doesn't work.
It should NOT depend on the current status (what if I switch from receipt to price tag? what if I start with an empty list and add one product?).
The solution is in the model: "hey, just don't show an 'add product' button". And that bool
could be set as a final
in the model creation, depending on where you opened the "add price" page.
Hmm, Interesting. I will look into it. As Lab exams are going on now, I am not able to contribute in a continuous basis. exams will be over by day after tmrw, so can i contribute from then on? I will try to fix this if I find any free time in between. |
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 @Abhishek-P0207, and thank you for your code rewriting!
Please have a look at my comments.
Additional comments:
- I would have named the field "singleProduct" instead of "multipleProducts" (obviously with the opposite purpose), but it's just a matter of taste
- generally speaking it's not such a good idea to use default values when the default choice is not that obvious. More specifically here, without the default value the developer is explicitly asked "is that a single product model?", and it's a fair question to ask.
@@ -19,12 +19,14 @@ class PriceModel with ChangeNotifier { | |||
required final List<OsmLocation>? locations, | |||
required final Currency currency, | |||
final PriceMetaProduct? initialProduct, | |||
final bool? multipleProducts, |
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.
final bool? multipleProducts, | |
required this.multipleProducts, |
}) : _proof = null, | ||
existingPrices = null, | ||
_proofType = proofType, | ||
_date = DateTime.now(), | ||
_currency = currency, | ||
_locations = locations, | ||
_multipleProducts = multipleProducts ?? false, |
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.
_multipleProducts = multipleProducts ?? false, |
late bool _multipleProducts; | ||
bool showAddProductCard() { | ||
if (_multipleProducts == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
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.
late bool _multipleProducts; | |
bool showAddProductCard() { | |
if (_multipleProducts == true) { | |
return true; | |
} | |
return false; | |
} | |
/// "Should we support multiple products?" (instead of a single) | |
final bool multipleProducts; |
For the record, your previous syntax was a bit heavy:
bool showAddProductCard() {
if (_multipleProducts == true) {
return true;
}
return false;
}
The following would have been better:
bool get showAddProductCard => _multipleProducts;
@@ -65,6 +66,7 @@ class ProductPriceAddPage extends StatefulWidget { | |||
locations: osmLocations, | |||
initialProduct: product, | |||
currency: currency, | |||
multipleProducts: multiProduct, |
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.
multipleProducts: multiProduct, | |
multipleProducts: multipleProducts, |
Please try to keep consistency between classes.
@@ -152,7 +154,7 @@ class _ProductPriceAddPageState extends State<ProductPriceAddPage> | |||
index: i, | |||
), | |||
const SizedBox(height: LARGE_SPACE), | |||
const PriceAddProductCard(), | |||
if (model.showAddProductCard()) const PriceAddProductCard(), |
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 (model.showAddProductCard()) const PriceAddProductCard(), | |
if (model.multipleProducts) const PriceAddProductCard(), |
What
Fixed the issue of adding an unrelated item through barcode, from "Add a price" page of a specific product.
Screenshot
Before:

After:

Fixes bug(s)
Part of