Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

'+ new item' allows negative numbers. #824

Closed
marcorosas1991 opened this issue Nov 27, 2016 · 5 comments
Closed

'+ new item' allows negative numbers. #824

marcorosas1991 opened this issue Nov 27, 2016 · 5 comments
Labels
🐛bug issue/pull request that documents/fixes a bug in progress indicates that issue/pull request is currently being worked on

Comments

@marcorosas1991
Copy link
Contributor

Is there a reason for allowing negative quantities when adding a new item on the system?
Playing with the form, it doesn't accept 0 as a quantity, but it allows negative numbers.

Expected behavior:
It should prevent entering negative numbers on the form.

Actual behavior:
Negative numbers can be inputted on 'new item form', and saved to inventory.

Steps to reproduce:

  • Open and login to Hospital Run.
  • Click Inventory on left side panel
  • Click Items
  • Click '+ new item'
  • Fill required fields
  • Enter a negative number for quantity
  • Press 'Add'
  • Click Items again to see the new list
  • Look for entered product

Screenshots (if applicable):
screen shot 2016-11-26 at 9 54 06 pm
screen shot 2016-11-26 at 9 54 36 pm

OS and Browser:
Chrome Version 54.0.2840.98 (64-bit)
MacOS 10.12.1

@marcorosas1991
Copy link
Contributor Author

Do you agree @jkleinsc with this issue?

@jkleinsc
Copy link
Member

jkleinsc commented Dec 5, 2016

@marcorosas1991 I agree... you shouldn't be able to enter in a negative value.
This should be a pretty simple fix. There is data validation on quantity on the inventory model that just needs to be modified to disallow numbers less than 1. Docs for number validation are here:
https://github.com/DockYard/ember-validations#numericality

@marcorosas1991
Copy link
Contributor Author

marcorosas1991 commented Dec 5, 2016

Ok sounds good. I'll work on it. @tangollama

@marcorosas1991
Copy link
Contributor Author

marcorosas1991 commented Dec 8, 2016

@jkleinsc I updated the quantity field in the inventory model, and it works. The form is not submitted when there is a negative quantity. I found an issue with this solution. There is not a visual feedback about the error.

I look around and found https://github.com/HospitalRun/hospitalrun-frontend/blob/master/app/components/quantity-conv.js lines 29-47 determine if there is an error with the quantity and add a CSS class. I thought I could check here if the number is negative, but if I'm right, this change would apply to all quantities. Is there any use case when the quantity can be negative?

Probably users won't input negative values too often, but it is nice to have the right feedback about it.

Thanks!

screen shot 2016-12-07 at 9 38 42 pm

Form is not submitted.

screen shot 2016-12-07 at 9 38 57 pm


No visual feed back on quantity field.

@jkleinsc jkleinsc added in progress indicates that issue/pull request is currently being worked on 🐛bug issue/pull request that documents/fixes a bug labels Dec 8, 2016
@jkleinsc
Copy link
Member

jkleinsc commented Dec 8, 2016

@marcorosas1991 there isn't anywhere in the app where a negative number should be used, so it would be fine to modify https://github.com/HospitalRun/hospitalrun-frontend/blob/master/app/components/quantity-conv.js#L33 to check for negative numbers.

Thanks for working on this issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛bug issue/pull request that documents/fixes a bug in progress indicates that issue/pull request is currently being worked on
Projects
None yet
Development

No branches or pull requests

2 participants