Bug 3534

Summary: Patron quick add form
Product: Koha Reporter: Richard <rpritsky>
Component: PatronsAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact:
Severity: new feature    
Priority: P5 - low CC: amy, indradg, jdemuth, jonathan.druart, jweaver, kyle, mtj, nick, nicole, oleonard, veron, wizzyrea
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch adds a new system preference: PatronQuickAddFields When either this pref or BorrowerMandatoryField is populated this will add a new dropdown to the bew patron toolbar. When a category is chosen from this dropdown the fields in PatronQuickAddFields and BorrowerMandatoryField will be displayed. There will be a button allowing a user to switch from the quickadd to the full form and fields will be copied between the forms when toggling. The Quick add will only be displayed on add of a new patron, future edits should display the full form.
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 17344, 18569, 18596, 18597, 18598, 19249    
Attachments: Rearranged new member entry template
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Fix tabs to spaces
Bug 3534 - Patron quick add form
Bug 3534 - Fix tabs to spaces
Bug 3534 - Patron quick add form
Bug 3534 - (QA followup) whitespace fixes
Bug 3534 [Follow-up] Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - Patron quick add form
Bug 3534 - QA Followup - use floating save
Bug 3534 - Patron quick add form
Bug 3534 - QA Followup - use floating save
Bug 3534 (QA Followup) Fix indentation, show guarantor form, ignore bad data in pref
Bug 3534 - Patron quick add form
Bug 3534 - QA Followup - use floating save
Bug 3534 (QA Followup) Fix indentation, show guarantor form, ignore bad data in pref
Bug 3534 - Patron quick add form
Bug 3534 - QA Followup - use floating save
Bug 3534 (QA Followup) Fix indentation, show guarantor form, ignore bad data in pref
Bug 3534 (QA Followup) Rebase and change floating save
Bug 3534 (QA Followup)
Bug 3534 - (QA Followup) Use single toolbar for regular/quickadd forms
Bug 3534 - Patron quick add form
Bug 3534 - QA Followup - use floating save
Bug 3534 (QA Followup) Fix indentation, show guarantor form, ignore bad data in pref
Bug 3534 (QA Followup) Rebase and change floating save
Bug 3534: Force margin-left: 0 for second button
Bug 3534: (QA Follow-up) Fix the return value for the new format, it should be a hashref, not a string

Description Chris Cormack 2010-05-21 01:11:51 UTC


---- Reported by rpritsky@gmail.com 2009-08-17 13:16:04 ----

Created an attachment
Rearranged new member entry template

Our clerks were a bit frustrated having to navigate multiple screens to add a new patron, especially to add required fields such as last name and barcode.  If the circ desk is busy, we want to add minimum info so that a new patron can check out items quickly and we can move on to the next patron.  Additional info can be added later from the registration card during lulls in activity.

The clerks are very happy with this new add patron setup.

I rearranged the field groups in memberentrygen.tmpl so that required fields appear on the first screen AND a save button is there as well. I'll attach the file for review. 

Can we integrate somehting like this in 3.2?



---- Additional Comments From oleonard@myacpl.org 2009-08-17 13:26:38 ----

I assume by "multiple screens" you mean they had to page down on the current screen?

I'd be open to a change like this, but it's important to understand that any particular library could have specified any number of fields as required. If we really wanted to solve the problem we ought to create some kind of "quick add" process that *only* showed the required fields, no matter which ones they are.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:11 UTC  ---

This bug was previously known as _bug_ 3534 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3534
Imported an attachment (id=1396)

Actual time not defined. Setting to 0.0
The original submitter of attachment 1396 [details] is unknown.
   Reassigning to the person who moved it here: chris@bigballofwax.co.nz.

Comment 1 Liz Rea 2011-09-13 02:55:52 UTC
I like the idea of sifting the required fields up to the top, with a submit button that becomes active when they are filled.
Comment 2 Katrin Fischer 2013-04-13 22:30:12 UTC
Rephrasing bug description and changing version.
Comment 3 Marc Véron 2014-09-11 16:19:21 UTC
There was a blog entry related to this bug using jQuery for a Patron quick add form. As far I remember it was declared as proof of concept.
The link was: http://www.myacpl.org/koha/category/koha/customizations/
(Link not valid as of today)

I tested the jQuery code in early 2012 and re-tested it today with current master by putting it into intranetuserjs system preference. It is not really a solution for this enhancement request, but it still works nice. That's why I put it here.

$(document).ready(function(){
var list = "<fieldset class=\"rows\"><legend>Quick Add<ol>";
$("label.required").each(function(){
item = $(this).parent().html()
item = "<li>"+item+"</li>";
list += item;
});
list += "</ol></fieldset><fieldset class=\"action\"><input type=\"submit\" value=\"Save\" onclick=\"return check_form_borrowers();\" name=\"save\"/><a href=\"/cgi-bin/koha/members/member.pl\" class=\"cancel\">Cancel</a></fieldset>";
$("#entryform").prepend(list);
});
Comment 4 Jesse Weaver 2015-11-02 19:23:25 UTC
We have received sponsorship for the following approach:

a) Add a new system preference "PatronQuickAddFields"
b) In this new preference we would list the fields to be in the quick add form ( similar to the list of required fields system preference )
c) When displaying the "new patron" form in quick add mode, all fields that are not mandatory or not listed in PatronQuickAddFields will be hidden
Comment 5 Nick Clemens (kidclamp) 2016-04-08 18:49:29 UTC Comment hidden (obsolete)
Comment 6 Nick Clemens (kidclamp) 2016-04-08 19:05:50 UTC Comment hidden (obsolete)
Comment 7 Nick Clemens (kidclamp) 2016-04-08 19:11:11 UTC Comment hidden (obsolete)
Comment 8 Nick Clemens (kidclamp) 2016-04-08 19:37:58 UTC Comment hidden (obsolete)
Comment 9 Marc Véron 2016-04-17 10:00:16 UTC
Great feature! 
But I have a problem when toggling between Quick add and Full form:

To reproduce:

Madatory fields:
surname|firstname|cardnumber

PatronQuickAdd: Use
PatronQuickAddFields (none)

autoMemberNum: Do  default the card number field on the patron addition screen to the next available card number 

Go to /cgi-bin/koha/members/members-home.pl
Hit "New Patron" and choose 

Quick add form displays as expected

Enter Surname AAA, First name BBB, Change card number from automatically generated value to other value, Change patron category e.g. from Child to Adult

Toggle to Full form (Button "Quick-add/Full form)

Result: 
Fields Surname and First name are empty, card number is set back to automatically generated value, patron category is reset to Child.


Toggle back to quick form
Result:
Values entered in quick add form re-appear.

Possible solution:
- Replace toggling function "Quick-add/Full form" by: "Save and edit in full form"
- In /cgi-bin/koha/members/members-home.pl, provide a choice to use "Quick add" or "Full form"
Comment 10 Nick Clemens (kidclamp) 2016-04-18 18:53:55 UTC Comment hidden (obsolete)
Comment 11 Nick Clemens (kidclamp) 2016-04-18 18:55:24 UTC
(In reply to Marc Véron from comment #9)
> Great feature! 
> But I have a problem when toggling between Quick add and Full form:

Fields should now populate when toggling between forms, quick add is now a choice from patron toolbar
Comment 12 Marc Véron 2016-04-19 06:35:59 UTC
Works great now,
However QA tools complain:
 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
   FAIL	  forbidden patterns
		forbidden pattern: tab char (line 277)
		forbidden pattern: tab char (line 840)
		forbidden pattern: tab char (line 272)
		forbidden pattern: tab char (line 831)
Comment 13 Nick Clemens (kidclamp) 2016-04-19 13:51:43 UTC Comment hidden (obsolete)
Comment 14 Marc Véron 2016-04-19 14:36:59 UTC Comment hidden (obsolete)
Comment 15 Marc Véron 2016-04-19 14:37:39 UTC Comment hidden (obsolete)
Comment 16 Jonathan Druart 2016-04-25 16:41:17 UTC
(In reply to Marc Véron from comment #3)
> There was a blog entry related to this bug using jQuery for a Patron quick
> add form. As far I remember it was declared as proof of concept.
> The link was: http://www.myacpl.org/koha/category/koha/customizations/
> (Link not valid as of today)

https://www.myacpl.org/koha/quick-patron-add/

Owen, could we get your opinion on this patch?
Comment 17 Jonathan Druart 2016-04-25 16:42:20 UTC
pplying: Bug 3534 - Fix tabs to spaces
fatal: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt).
Comment 18 Jonathan Druart 2016-04-25 16:46:58 UTC
I personally don't think that the new "Quick add New Patron" is well placed.
Maybe it would be better not to have it but always add the switch button ("Quick-add/Full form") on the add patron form (and move it to the top).
Comment 19 Jonathan Druart 2016-04-25 16:49:01 UTC
Also patch's author of the second patch is "Your Full Name <your_email>"
A lot of patches in the queue (FQA or NSO) are modifying this file, not sure the second patch is necessary.
Comment 20 Owen Leonard 2016-04-25 17:09:44 UTC
I suggested on IRC the separate button menu for "Quick add" because the version of the patch I tested made the quick add action default if PatronQuickAddFields were defined. I thought it was important that staff be able to choose to do a full add if they chose to.

The two buttons do look awkward, though. Maybe that wasn't a good idea. I'm not sure what the solution is. I'm going to 

The quick add button should at least be next to the "New patron" button. And the mixed case on the button label should be corrected.

As for the second patch, it makes changes to far more than the 4 line required by the QA tools. We should correct whitespace on changed lines, not all lines.
Comment 21 Nick Clemens (kidclamp) 2016-04-25 17:20:11 UTC Comment hidden (obsolete)
Comment 22 Nick Clemens (kidclamp) 2016-04-25 17:20:20 UTC Comment hidden (obsolete)
Comment 23 Nick Clemens (kidclamp) 2016-04-25 17:21:16 UTC
Moved button and fixed case
Restricted whitespace to affected lines (and set my git user.name and user.email)
Comment 24 Jonathan Druart 2016-04-26 15:39:53 UTC
(In reply to Jonathan Druart from comment #18)
> Maybe it would be better not to have it but always add the switch button
> ("Quick-add/Full form") on the add patron form (and move it to the top).

Nick, what do you think about this suggestion?
Comment 25 Nick Clemens (kidclamp) 2016-04-26 15:50:41 UTC
(In reply to Jonathan Druart from comment #24)
> (In reply to Jonathan Druart from comment #18)
> > Maybe it would be better not to have it but always add the switch button
> > ("Quick-add/Full form") on the add patron form (and move it to the top).
> 
> Nick, what do you think about this suggestion?

I like moving it to the top, but I am unsure about always defaulting to full form.  I would want to check with the sponsors, let me see if I can get an answer.
Comment 26 Owen Leonard 2016-04-26 16:18:06 UTC Comment hidden (obsolete)
Comment 27 Nick Clemens (kidclamp) 2016-04-26 23:58:37 UTC
(In reply to Owen Leonard from comment #26)
> Created attachment 50729 [details] [review] [review]
> Bug 3534 [Follow-up] Patron quick add form

+    [% IF quickadd && opadd %]
+        <a href="#" class="toggle_quick_add"><i class="fa fa-plus-square"></i> Show full form</a>
+        <a href="#" class="toggle_quick_add" style="display:none"><i class="fa fa-minus-square"></i> Show brief form</a>
+    [% ELSE %]
+        <a href="#" class="toggle_quick_add" style="display:none"><i class="fa fa-plus-square"></i> Show full form</a>
+        <a href="#" class="toggle_quick_add"><i class="fa fa-minus-square"></i> Show brief form</a>
+    [% END %]

This makes the toggle button show up on edits and form checks, but the quick-add isn't built in those scenarios. Are you thinking the user should be able to toggle even when not coming from the 'Quick add new patron' button?
Comment 28 Owen Leonard 2016-04-27 01:19:06 UTC
(In reply to Nick Clemens from comment #27)
> Are you thinking the user should
> be able to toggle even when not coming from the 'Quick add new patron'
> button?

No, just sloppiness on my part.
Comment 29 Owen Leonard 2016-04-28 14:14:20 UTC
Nick, something I noticed while re-working my patch: If you start an add using the quick add form but there is a problem (for instance, a duplicate card number) the form is redisplayed in its full form. Shouldn't it show the brief form instead?
Comment 30 Owen Leonard 2016-05-06 13:14:38 UTC
Nick, could I get you to rebase your patches? After that I'll see about fixing up mine.
Comment 31 Nick Clemens (kidclamp) 2016-05-10 15:01:11 UTC Comment hidden (obsolete)
Comment 32 Nick Clemens (kidclamp) 2016-05-10 15:41:58 UTC Comment hidden (obsolete)
Comment 33 Marc Véron 2016-05-10 19:28:40 UTC
I re-tested, it seems that the "Save" button in the quick add form no longer works.
Comment 34 Nick Clemens (kidclamp) 2016-05-11 15:18:44 UTC Comment hidden (obsolete)
Comment 35 Nick Clemens (kidclamp) 2016-05-11 15:18:51 UTC Comment hidden (obsolete)
Comment 36 Nick Clemens (kidclamp) 2016-05-11 16:18:58 UTC
(In reply to Marc Véron from comment #33)
> I re-tested, it seems that the "Save" button in the quick add form no longer
> works.
Yeah, the quick add save 'clicks' the full form save button, fixed the selector and should work again
Comment 37 Marc Véron 2016-06-02 07:04:56 UTC Comment hidden (obsolete)
Comment 38 Marc Véron 2016-06-02 07:06:10 UTC Comment hidden (obsolete)
Comment 39 Jonathan Druart 2016-06-07 15:50:02 UTC
QA comments:
1/ If you put a nonexisting field in the pref (test with surname|sex|xxx), you will see "Expiry date (leave blank for auto calc):". Any ideas why?
2/ Please fix indentations in JS code
3/ It does not seem possible to display the guarantor form, is it expected?
Comment 40 Nick Clemens (kidclamp) 2016-06-08 17:43:30 UTC Comment hidden (obsolete)
Comment 41 Nick Clemens (kidclamp) 2016-06-08 17:44:32 UTC
Fixed indents, made guarantor form mandatory (and skip those fields if added) and made sure bad data isn't processed
Comment 42 Katrin Fischer 2016-06-19 19:01:13 UTC
The mandatory fields show up nicely, but I have problems using the new PatronQuickAddFields for adding additional fields. The fields are not showing up. I have tried:
email
email|sex
email|B_address
Comment 43 Nick Clemens (kidclamp) 2016-06-20 13:15:51 UTC Comment hidden (obsolete)
Comment 44 Nick Clemens (kidclamp) 2016-06-20 13:16:07 UTC Comment hidden (obsolete)
Comment 45 Nick Clemens (kidclamp) 2016-06-20 13:16:12 UTC Comment hidden (obsolete)
Comment 46 Nick Clemens (kidclamp) 2016-06-20 13:16:52 UTC
(In reply to Katrin Fischer from comment #42)
> The mandatory fields show up nicely, but I have problems using the new
> PatronQuickAddFields for adding additional fields. The fields are not
> showing up.

I got my equalities mixed up, fixed!
Comment 47 Jonathan Druart 2016-06-27 13:58:05 UTC
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
Comment 48 Nick Clemens (kidclamp) 2016-06-28 17:06:00 UTC Comment hidden (obsolete)
Comment 49 Nick Clemens (kidclamp) 2016-06-28 17:06:05 UTC Comment hidden (obsolete)
Comment 50 Nick Clemens (kidclamp) 2016-06-28 17:06:14 UTC Comment hidden (obsolete)
Comment 51 Nick Clemens (kidclamp) 2016-06-28 17:06:19 UTC Comment hidden (obsolete)
Comment 52 Jonathan Druart 2016-07-02 13:31:46 UTC
(In reply to Nick Clemens from comment #51)
> Created attachment 52937 [details] [review] [review]
> Bug 3534 (QA Followup)     Rebase and change floating save

Why do you use another id for the toolbar? You won't need to add this specific JS code if you just use "toolbar" as the id.
Comment 53 Nick Clemens (kidclamp) 2016-07-05 18:37:29 UTC Comment hidden (obsolete)
Comment 54 Nick Clemens (kidclamp) 2016-07-05 18:38:55 UTC
(In reply to Jonathan Druart from comment #52)
> Why do you use another id for the toolbar? You won't need to add this
> specific JS code if you just use "toolbar" as the id.

It was just to keep the toolbar in the quick add form, it seemed cleaner.

Moving it to the top of the page works as well and doesn't require the js
Comment 55 Jonathan Druart 2016-07-06 15:05:37 UTC
Nick, with your last patches, there is a problem:
If you are on the quick add form, then switch to the full form, the toolbar is not floating.
If I remove the last patch, there is floating toolbar on the quick add form is not displayed correctly (there is a margin top).
I think you should trick the code to have only 1 toolbar for the 2 forms. You will need to add a flag to check, to know which form we want to save.
Comment 56 Nick Clemens (kidclamp) 2016-07-06 19:08:35 UTC Comment hidden (obsolete)
Comment 57 Nick Clemens (kidclamp) 2016-07-06 19:09:58 UTC
(In reply to Jonathan Druart from comment #55)
> I think you should trick the code to have only 1 toolbar for the 2 forms.
> You will need to add a flag to check, to know which form we want to save.

Indeed, combined to one toolbar, removed 'onclick' action from regular save and redirected to a js function
Comment 58 Jonathan Druart 2016-07-07 14:40:42 UTC
Created attachment 53171 [details] [review]
Bug 3534 - Patron quick add form

This patch adds a new system preference:
    PatronQuickAddFields

When either this pref or BorrowerMandatoryField is populated this will add a new dropdown to the bew patron toolbar.
When a category is chosen from this dropdown the fields in PatronQuickAddFields and BorrowerMandatoryField will be displayed.
There will be a button allowing a user to switch from the quickadd to the full form and fields will be copied between the forms when toggling.

The Quick add will only be displayed on add of a new patron, future edits should display the full form.

Test plan:
 1 - Apply patch
 2 - run updatedatabase.pl
 3 - Add a new patron and ensure nothing has changed
 4 - Populate either PatronQuickAddFields or BorrowerMandatory fields
 and note the new button for adding a patron
 5 - Click the Quick add and choose a type
 6 - Only required or quick add fields should be displayed
 7 - Verify toggling forms copies information
 8 - Ensure you cannot save patron without filling required fields
 (quick add fields should be optional)
 9 - Ensure you can save patron with fields filled out
10 - Ensure that a duplicate patron brings up the duplicate/add new
buttons with full form displayed
11 - Verify that subsequent edits use only full form
12 - Verify that data on form submitted is the data saved to patron
13 - Test with various values in both MandatoryBorrowerFields and PatronQuickAddFields

Sponsored by: VOKAL (Vermont Organization of Koha Automated Libraries)

Followed test plan, works as expected.
Re-tested together with followup, works as expected (2016-06-02)
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 59 Jonathan Druart 2016-07-07 14:40:47 UTC
Created attachment 53172 [details] [review]
Bug 3534 - QA Followup - use floating save

I am not sure if this is desired, it makes sense for consistency but
floats in a wierd place for a short form.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 60 Jonathan Druart 2016-07-07 14:40:53 UTC
Created attachment 53173 [details] [review]
Bug 3534 (QA Followup) Fix indentation, show guarantor form, ignore bad data in pref

Switch incorrect == to != when checking skipped fields

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 61 Jonathan Druart 2016-07-07 14:40:57 UTC
Created attachment 53174 [details] [review]
Bug 3534 (QA Followup) Rebase and change floating save

Bug 3534 - (QA Followup) Use single toolbar for regular/quickadd forms

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 62 Jonathan Druart 2016-07-07 14:41:02 UTC
Created attachment 53175 [details] [review]
Bug 3534: Force margin-left: 0 for second button

When quick adding a new patron, both button are in the DOM and the
second button has a margin-left (from .btn-toolbar > .btn + .btn).
This patch force the margin-left to 0 to avoid the button to move when
toggling them.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 63 Jonathan Druart 2016-07-07 14:41:24 UTC
I have squashed 2 patches for the readability.
Comment 64 Kyle M Hall (khall) 2016-07-07 18:38:10 UTC
Pushed to master for Koha 16.11, thanks Nick!
Comment 65 Mason James 2017-05-24 03:14:01 UTC
New feature, skipping for 16.05.x
Comment 66 Kyle M Hall (khall) 2019-02-07 16:19:59 UTC
Created attachment 84851 [details] [review]
Bug 3534: (QA Follow-up) Fix the return value for the new format, it should be a hashref, not a string