|
Lines 5-11
Link Here
|
| 5 |
* Format the patron response from a Koha RESTful API request. |
5 |
* Format the patron response from a Koha RESTful API request. |
| 6 |
* @param {Object} patron The patron json object as returned from the Koha RESTful API |
6 |
* @param {Object} patron The patron json object as returned from the Koha RESTful API |
| 7 |
* @param {Object} config A configuration object |
7 |
* @param {Object} config A configuration object |
| 8 |
* Valid keys are: `invert_name`, `display_cardnumber` and `url` |
8 |
* Valid keys are: `invert_name`, `display_cardnumber`, `url` |
|
|
9 |
* and `showlegal`. |
| 9 |
* @return {string} The formatted HTML string |
10 |
* @return {string} The formatted HTML string |
| 10 |
*/ |
11 |
*/ |
| 11 |
window.$patron_to_html = function (patron, config) { |
12 |
window.$patron_to_html = function (patron, config) { |
|
Lines 22-34
Link Here
|
| 22 |
var firstname = escape_str(patron.firstname); |
23 |
var firstname = escape_str(patron.firstname); |
| 23 |
var preferred_name = escape_str(patron.preferred_name); |
24 |
var preferred_name = escape_str(patron.preferred_name); |
| 24 |
var surname = escape_str(patron.surname); |
25 |
var surname = escape_str(patron.surname); |
|
|
26 |
var showFirstIfDifferentThanPreferred = [% Koha.Preference('ShowFirstIfDifferentThanPreferred') | html %]; |
| 25 |
|
27 |
|
| 26 |
if (patron.middle_name != null && patron.middle_name != "") { |
28 |
if (patron.middle_name != null && patron.middle_name != "") { |
| 27 |
firstname += " " + escape_str(patron.middle_name); |
29 |
firstname += " " + escape_str(patron.middle_name); |
| 28 |
preferred_name += " " + escape_str(patron.middle_name); |
30 |
preferred_name += " " + escape_str(patron.middle_name); |
| 29 |
} |
31 |
} |
| 30 |
|
32 |
|
| 31 |
if (patron.other_name != null && patron.other_name != "") { |
33 |
if (showFirstIfDifferentThanPreferred && config && config.showlegal && patron.preferred_name != patron.firstname) { |
|
|
34 |
preferred_name += " [" + escape_str(patron.firstname) + "]"; |
| 35 |
} else if (patron.other_name != null && patron.other_name != "") { |
| 32 |
firstname += " (" + escape_str(patron.other_name) + ")"; |
36 |
firstname += " (" + escape_str(patron.other_name) + ")"; |
| 33 |
preferred_name += " (" + escape_str(patron.other_name) + ")"; |
37 |
preferred_name += " (" + escape_str(patron.other_name) + ")"; |
| 34 |
} |
38 |
} |