Bug 28135

Summary: Replace use of input type number in additem.js
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david, fridolin.somers, jonathan.druart, martin.renvoize, nick, severine.queune, testopia
Version: Main   
Hardware: All   
OS: All   
URL: https://wiki.koha-community.org/wiki/Coding_Guidelines#ACC2:_Input_type_.22number.22_should_be_avoided
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28283
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00
Bug Depends on:    
Bug Blocks: 26926    
Attachments: Bug 28135: Replace use of input type number in additem.js
Bug 28135: Replace use of input type number in additem.js
Bug 28135: Replace use of input type number in additem.js

Description Owen Leonard 2021-04-12 11:24:02 UTC
Inputs of type="number" need updating to adhere to ACC2 in additem.js
Comment 1 Owen Leonard 2021-04-12 11:30:35 UTC
Created attachment 119450 [details] [review]
Bug 28135: Replace use of input type number in additem.js

This patch corrects in instance where JavaScript is creating an input
tag with type "number."

To test, apply the patch and make sure the AcqCreateItem system
preference is set to "when receiving."

- Go to Acquisitions -> Vendor -> Invoices -> Invoice -> Go to receipt
  page -> Receive.
- On the page for receiving items you should see an add item form.
- Click the "Add multiple items" button at the bottom of the form.
- Test the "Number of items to add" field. It should not accept any
  input except numbers.
Comment 2 Séverine Queune 2021-04-14 08:19:24 UTC
Hi Owen,
The field accepts number with decimal (point or comma), even though only the number before separator is taken into account for the items creation.
Is that expected ?
Comment 3 Martin Renvoize 2021-05-04 10:35:59 UTC
Created attachment 120434 [details] [review]
Bug 28135: Replace use of input type number in additem.js

This patch corrects in instance where JavaScript is creating an input
tag with type "number."

To test, apply the patch and make sure the AcqCreateItem system
preference is set to "when receiving."

- Go to Acquisitions -> Vendor -> Invoices -> Invoice -> Go to receipt
  page -> Receive.
- On the page for receiving items you should see an add item form.
- Click the "Add multiple items" button at the bottom of the form.
- Test the "Number of items to add" field. It should not accept any
  input except numbers.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-05-04 10:36:45 UTC
This one seems to work for me.. what browser were you using to test Severine?
Comment 5 Nick Clemens 2021-05-07 18:21:30 UTC
(In reply to Martin Renvoize from comment #4)
> This one seems to work for me.. what browser were you using to test Severine?

I get a similar problem to Severine on Firefox - I ordered 13 copies, put 3.4 into the quantity to receive.

When I typed 3 it selected three items, when I put '.4' it deselected all, but let me proceed. The quantity field in the order is correct at 10, but the quantity in the received order is 'NULL'
Comment 6 Jonathan Druart 2021-05-10 07:46:27 UTC
(In reply to Nick Clemens from comment #5)
> (In reply to Martin Renvoize from comment #4)
> > This one seems to work for me.. what browser were you using to test Severine?
> 
> I get a similar problem to Severine on Firefox - I ordered 13 copies, put
> 3.4 into the quantity to receive.
> 
> When I typed 3 it selected three items, when I put '.4' it deselected all,
> but let me proceed. The quantity field in the order is correct at 10, but
> the quantity in the received order is 'NULL'

Nick, was this comment for bug 28283?

I am not able to recreate what you describe on FF 78.8 ESR
Comment 7 Nick Clemens 2021-05-10 10:01:11 UTC
Created attachment 120761 [details] [review]
Bug 28135: Replace use of input type number in additem.js

This patch corrects in instance where JavaScript is creating an input
tag with type "number."

To test, apply the patch and make sure the AcqCreateItem system
preference is set to "when receiving."

- Go to Acquisitions -> Vendor -> Invoices -> Invoice -> Go to receipt
  page -> Receive.
- On the page for receiving items you should see an add item form.
- Click the "Add multiple items" button at the bottom of the form.
- Test the "Number of items to add" field. It should not accept any
  input except numbers.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens 2021-05-10 10:05:12 UTC
(In reply to Jonathan Druart from comment #6)
> (In reply to Nick Clemens from comment #5)
> > (In reply to Martin Renvoize from comment #4)
> > > This one seems to work for me.. what browser were you using to test Severine?
> > 
> > I get a similar problem to Severine on Firefox - I ordered 13 copies, put
> > 3.4 into the quantity to receive.
> > 
> > When I typed 3 it selected three items, when I put '.4' it deselected all,
> > but let me proceed. The quantity field in the order is correct at 10, but
> > the quantity in the received order is 'NULL'
> 
> Nick, was this comment for bug 28283?
> 
> I am not able to recreate what you describe on FF 78.8 ESR

Yes, I tested the wrong thing.


Note: There is no feedback when the input is incorrect - and I can still input strings as long as they start with a number, e.g. "4A" "5.2" but only the first numeric portion is used
Comment 9 Jonathan Druart 2021-05-11 13:39:31 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 10 Fridolin Somers 2021-05-12 15:20:25 UTC
Not pushed to 20.11.x