Bug 27991 - Message field for checkout notes should have a maxlength set
Summary: Message field for checkout notes should have a maxlength set
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-18 17:11 UTC by Jason Robb
Modified: 2021-12-13 21:10 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.05,20.05.11
Circulation function:


Attachments
Bug 27991: Message field for OPAC problem reporting should have a maxlength set (2.76 KB, patch)
2021-03-18 18:10 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27991: Message field for OPAC problem reporting should have a maxlength set (2.81 KB, patch)
2021-03-19 08:19 UTC, Amit Gupta
Details | Diff | Splinter Review
Bug 27991: Message field for OPAC problem reporting should have a maxlength set (2.87 KB, patch)
2021-03-27 17:03 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Robb 2021-03-18 17:11:44 UTC
Currently when a user is submitting a problem report via the OPAC at opac-reportproblem.pl, they can write as much as they want in the "message" field. When the report is submitted, only the first 255 characters are kept due to the field size of problem_reports.content which can result in a cut off message.

It would be good to set a maxlength for the field and also make users aware of the limit. I'm using jQuery to set the maxlength attribute and add a character countdown so users know exactly how much they can type.

//Problem Reporting
$(document).ready(function() {
//Enforce character limit on message field
	$('#opac-reportproblem #message').attr('maxlength', '255');
//Add character countdown
	$('#opac-reportproblem #message').after('<span id="charcounter">255</span> characters remaining');
//Update character countdown as data is entered
	var maxLength = 255;
	$('#opac-reportproblem #message').keyup(function() {
	  var length = $(this).val().length;
	  var length = maxLength-length;
	  $('#opac-reportproblem #charcounter').text(length);
	}); 
});
Comment 1 Owen Leonard 2021-03-18 18:10:44 UTC
Created attachment 118469 [details] [review]
Bug 27991: Message field for OPAC problem reporting should have a maxlength set

This patch adds a maxlength attribute to the form field for entering
checkout notes in the OPAC, matching the character limit of the database
column. A note is added to show the 255 character limit.

To test, apply the patch and enable the AllowCheckoutNotes system
preference.

 - Log in to the OPAC as a user who has checkouts.
 - On the "Your summary" page, the "Report a problem" fields should
   have a hint below them, "255 characters maximum."
 - Try entering text in one of the fields. You should not be able to
   enter more than 255 characters:

   Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
   nunc mi, fringilla in mauris quis, hendrerit feugiat mi. Sed ultrices
   mollis nulla sit amet faucibus. Sed volutpat augue risus, eu rutrum
   eros commodo eu. Proin rhoncus nisi vitae magna_

 - Test that your submission is saved correctly.
Comment 2 Amit Gupta 2021-03-19 08:19:12 UTC
Created attachment 118492 [details] [review]
Bug 27991: Message field for OPAC problem reporting should  have a maxlength set

This patch adds a maxlength attribute to the form field for entering
checkout notes in the OPAC, matching the character limit of the database
column. A note is added to show the 255 character limit.

To test, apply the patch and enable the AllowCheckoutNotes system
preference.

 - Log in to the OPAC as a user who has checkouts.
 - On the "Your summary" page, the "Report a problem" fields should
   have a hint below them, "255 characters maximum."
 - Try entering text in one of the fields. You should not be able to
   enter more than 255 characters:

   Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
   nunc mi, fringilla in mauris quis, hendrerit feugiat mi. Sed ultrices
   mollis nulla sit amet faucibus. Sed volutpat augue risus, eu rutrum
   eros commodo eu. Proin rhoncus nisi vitae magna_

 - Test that your submission is saved correctly.

Works ok
Comment 3 Katrin Fischer 2021-03-27 16:56:07 UTC
The bug description I think meant something different to what was actually fixed here: OPAC problem reports, which would have made it a duplicate to bug 27726. 

But now we have fixed checkout notes here. Fixing the bug description :)
Comment 4 Katrin Fischer 2021-03-27 17:03:27 UTC
Created attachment 118914 [details] [review]
Bug 27991: Message field for OPAC problem reporting should have a maxlength set

This patch adds a maxlength attribute to the form field for entering
checkout notes in the OPAC, matching the character limit of the database
column. A note is added to show the 255 character limit.

To test, apply the patch and enable the AllowCheckoutNotes system
preference.

 - Log in to the OPAC as a user who has checkouts.
 - On the "Your summary" page, the "Report a problem" fields should
   have a hint below them, "255 characters maximum."
 - Try entering text in one of the fields. You should not be able to
   enter more than 255 characters:

   Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
   nunc mi, fringilla in mauris quis, hendrerit feugiat mi. Sed ultrices
   mollis nulla sit amet faucibus. Sed volutpat augue risus, eu rutrum
   eros commodo eu. Proin rhoncus nisi vitae magna_

 - Test that your submission is saved correctly.

Signed-off-by: Amit Gupta <amit.gupta@informaticsglobal.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Jonathan Druart 2021-04-06 13:58:46 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 6 Fridolin Somers 2021-04-19 09:29:48 UTC
Small usefull enhancement, I choose to backport.

Pushed to 20.11.x for 20.11.05
Comment 7 Andrew Fuerste-Henry 2021-04-25 14:04:35 UTC
Pushed to 20.05.x for 20.05.11
Comment 8 Victor Grousset/tuxayo 2021-04-25 17:19:00 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.