Bug 16458 - Setting to guarantor: JavaScript error form.branchcode is undefined
Summary: Setting to guarantor: JavaScript error form.branchcode is undefined
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-05 19:05 UTC by Marc Véron
Modified: 2017-12-07 22:16 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 16458: Update library when a guarantor is set (2.03 KB, patch)
2016-05-11 11:19 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 16458: Update library when a guarantor is set (2.13 KB, patch)
2016-05-11 16:53 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 16458: Update library when a guarantor is set (2.18 KB, patch)
2016-06-04 06:31 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2016-05-05 19:05:59 UTC
To reproduce:
- Go to a child parton's detail page
- Edit it using the toolbar item "Edit"
- Edit "Guarantor information", "Set to patron" or "Change patron"
- Select a patron
=>Result OK (patron search window closes, guarantor information is set,
  e.g. Library changes to Guarantor's library if it is different)
- Go back to child patron's detail page
- This time do not use toolbar "Edit" but the "Edit" link below "Date of birth" / "Guarantor"
- Edit "Guarantor information", "Set to patron" or "Change patron"
- Select a patron
=>Result NOT OK (patron search window does not close, JavaScript console says: 
  TypeError: form.branchcode is undefined
  (...)/intranet-tmpl/prog/js/members.js
  Line: 213
  Some of the Guarantor's information is not set, e.g. library if it is different.

I found this while testing Bug 16450, this error appears without and with 16450 applied.
Comment 1 Jonathan Druart 2016-05-06 14:50:43 UTC
It's a tricky one, the JS error occurs because the libraries select is not displayed in the page. Should we update the library even if it's not displayed?
Comment 2 Marc Véron 2016-05-06 20:29:59 UTC
(In reply to Jonathan Druart from comment #1)
> It's a tricky one, the JS error occurs because the libraries select is not
> displayed in the page. Should we update the library even if it's not
> displayed?

I think it should be consistent. 
If it's updated if you reach the form via the toolbar Edit it should be updated as well if you go via the "Edit" link. Or it should not be updated in both ways.

Maybe there are more values that are not consitently updated?
Comment 3 Jonathan Druart 2016-05-11 11:19:56 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2016-05-11 16:53:26 UTC Comment hidden (obsolete)
Comment 5 Marcel de Rooy 2016-05-20 06:49:03 UTC
I still see: TypeError: document.form.password is undefined (members.js line 107)
Comment 6 Jonathan Druart 2016-05-20 14:33:28 UTC
(In reply to Marcel de Rooy from comment #5)
> I still see: TypeError: document.form.password is undefined (members.js line
> 107)

Hi Marcel,
It's another bug, without this patch you are not able to set a guarantor.
It seems that you get the error when saving the patron form.
Comment 7 Marcel de Rooy 2016-06-04 06:31:29 UTC
Created attachment 52025 [details] [review]
Bug 16458: Update library when a guarantor is set

If you edit a patron from the Edit link of the patron information block
(step 1 of the memberentry script), the branchcode is not displayed. If
you set a guarantor to a child from this form, a JavaScript error will
be raised:
  JavaScript error form.branchcode is undefined

It happens because there is the branchcode is not displayed and there is
no element with a branchcode name.

To avoid this issue, a branchcode hidden input is added to the form and
it will be updated when a guarantor is selected (same behavior as when
you edit a patron using the complete form).

Test plan:
Edit a patron using the Edit link of the patron info block (not the Edit
button in the toolbar)
Set a guarantor
=> Notice that the branchcode of the patron has been updated with the
branchcode of the guarantor

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Marcel de Rooy 2016-06-04 06:32:56 UTC
(In reply to Jonathan Druart from comment #6)
> (In reply to Marcel de Rooy from comment #5)
> > I still see: TypeError: document.form.password is undefined (members.js line
> > 107)
> 
> Hi Marcel,
> It's another bug, without this patch you are not able to set a guarantor.
> It seems that you get the error when saving the patron form.

Well, ok. I am passing qa on this one.
@RM: There may be little bit more to fix in this area?
Comment 9 Brendan Gallagher 2016-06-04 07:33:26 UTC
Pushed to Master - Should be in the November 2016 Release.  Thanks!
Comment 10 Frédéric Demians 2016-06-15 07:37:52 UTC
Pushed in 16.05. Will be in 16.05.01.
Comment 11 Julian Maurice 2016-06-16 08:22:10 UTC
Patch pushed to 3.22.x, will be in 3.22.8