|
Lines 3-297
Link Here
|
| 3 |
[% USE Branches %] |
3 |
[% USE Branches %] |
| 4 |
[% USE Koha %] |
4 |
[% USE Koha %] |
| 5 |
[% USE KohaDates %] |
5 |
[% USE KohaDates %] |
| 6 |
|
6 |
[% SET footerjs = 1 %] |
| 7 |
[% INCLUDE 'doc-head-open.inc' %] |
7 |
[% INCLUDE 'doc-head-open.inc' %] |
| 8 |
<title>Koha › ILL requests ›</title> |
8 |
<title>Koha › ILL requests ›</title> |
| 9 |
[% INCLUDE 'doc-head-close.inc' %] |
9 |
[% INCLUDE 'doc-head-close.inc' %] |
| 10 |
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] |
|
|
| 11 |
[% Asset.css("css/datatables.css") | $raw %] |
10 |
[% Asset.css("css/datatables.css") | $raw %] |
| 12 |
[% INCLUDE 'datatables.inc' %] |
|
|
| 13 |
<script type="text/javascript"> |
| 14 |
//<![CDATA[ |
| 15 |
$(document).ready(function() { |
| 16 |
|
| 17 |
// Illview Datatable setup |
| 18 |
|
| 19 |
// Fields we don't want to display |
| 20 |
var ignore = [ |
| 21 |
'accessurl', |
| 22 |
'backend', |
| 23 |
'branchcode', |
| 24 |
'completed', |
| 25 |
'capabilities', |
| 26 |
'cost', |
| 27 |
'medium', |
| 28 |
'notesopac', |
| 29 |
'notesstaff', |
| 30 |
'placed', |
| 31 |
'replied' |
| 32 |
]; |
| 33 |
|
| 34 |
// Fields we need to expand (flatten) |
| 35 |
var expand = [ |
| 36 |
'metadata', |
| 37 |
'patron' |
| 38 |
]; |
| 39 |
|
| 40 |
// Expanded fields |
| 41 |
// This is auto populated |
| 42 |
var expanded = {}; |
| 43 |
|
| 44 |
// The core fields that should be displayed first |
| 45 |
var core = [ |
| 46 |
'metadata_Author', |
| 47 |
'metadata_Title', |
| 48 |
'borrowername', |
| 49 |
'biblio_id', |
| 50 |
'library', |
| 51 |
'status', |
| 52 |
'updated', |
| 53 |
'illrequest_id', |
| 54 |
'action' |
| 55 |
]; |
| 56 |
|
| 57 |
// Remove any fields we're ignoring |
| 58 |
var removeIgnore = function(dataObj) { |
| 59 |
dataObj.forEach(function(thisRow) { |
| 60 |
ignore.forEach(function(thisIgnore) { |
| 61 |
if (thisRow.hasOwnProperty(thisIgnore)) { |
| 62 |
delete thisRow[thisIgnore]; |
| 63 |
} |
| 64 |
}); |
| 65 |
}); |
| 66 |
}; |
| 67 |
|
| 68 |
// Expand any fields we're expanding |
| 69 |
var expandExpand = function(row) { |
| 70 |
expand.forEach(function(thisExpand) { |
| 71 |
if (row.hasOwnProperty(thisExpand)) { |
| 72 |
if (!expanded.hasOwnProperty(thisExpand)) { |
| 73 |
expanded[thisExpand] = []; |
| 74 |
} |
| 75 |
var expandObj = row[thisExpand]; |
| 76 |
Object.keys(expandObj).forEach( |
| 77 |
function(thisExpandCol) { |
| 78 |
var expColName = thisExpand + '_' + thisExpandCol; |
| 79 |
// Keep a list of fields that have been expanded |
| 80 |
// so we can create toggle links for them |
| 81 |
if (expanded[thisExpand].indexOf(expColName) == -1) { |
| 82 |
expanded[thisExpand].push(expColName); |
| 83 |
} |
| 84 |
expandObj[expColName] = |
| 85 |
expandObj[thisExpandCol]; |
| 86 |
delete expandObj[thisExpandCol]; |
| 87 |
} |
| 88 |
); |
| 89 |
$.extend(true, row, expandObj); |
| 90 |
delete row[thisExpand]; |
| 91 |
} |
| 92 |
}); |
| 93 |
}; |
| 94 |
|
| 95 |
// Build a de-duped list of all column names |
| 96 |
var allCols = {}; |
| 97 |
core.map(function(thisCore) { |
| 98 |
allCols[thisCore] = 1; |
| 99 |
}); |
| 100 |
|
| 101 |
// Strip the expand prefix if it exists, we do this for display |
| 102 |
var stripPrefix = function(value) { |
| 103 |
expand.forEach(function(thisExpand) { |
| 104 |
var regex = new RegExp(thisExpand + '_', 'g'); |
| 105 |
value = value.replace(regex, ''); |
| 106 |
}); |
| 107 |
return value; |
| 108 |
}; |
| 109 |
|
| 110 |
// Our 'render' function for borrowerlink |
| 111 |
var createPatronLink = function(data, type, row) { |
| 112 |
return '<a title="' + _("View borrower details") + '" ' + |
| 113 |
'href="/cgi-bin/koha/members/moremember.pl?' + |
| 114 |
'borrowernumber='+row.borrowernumber+'">' + |
| 115 |
row.patron_firstname + ' ' + row.patron_surname + |
| 116 |
'</a>'; |
| 117 |
}; |
| 118 |
|
| 119 |
// Our 'render' function for biblio_id |
| 120 |
var createBiblioLink = function(data, type, row) { |
| 121 |
return (row.biblio_id) ? |
| 122 |
'<a title="' + _("View biblio details") + '" ' + |
| 123 |
'href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + |
| 124 |
row.biblio_id + '">' + |
| 125 |
row.biblio_id + |
| 126 |
'</a>' : ''; |
| 127 |
}; |
| 128 |
|
| 129 |
// Our 'render' function for the library name |
| 130 |
var createLibrary = function(data, type, row) { |
| 131 |
return row.library.branchname; |
| 132 |
}; |
| 133 |
|
| 134 |
// Render function for request ID |
| 135 |
var createRequestId = function(data, type, row) { |
| 136 |
return row.id_prefix + row.illrequest_id; |
| 137 |
}; |
| 138 |
|
| 139 |
// Render function for request status |
| 140 |
var createStatus = function(data, type, row, meta) { |
| 141 |
var origData = meta.settings.oInit.originalData; |
| 142 |
if (origData.length > 0) { |
| 143 |
var status_name = meta.settings.oInit.originalData[0].capabilities[ |
| 144 |
row.status |
| 145 |
].name; |
| 146 |
switch( status_name ) { |
| 147 |
case "New request": |
| 148 |
return _("New request"); |
| 149 |
case "Requested": |
| 150 |
return _("Requested"); |
| 151 |
case "Requested from partners": |
| 152 |
return _("Requested from partners"); |
| 153 |
case "Request reverted": |
| 154 |
return _("Request reverted"); |
| 155 |
case "Queued request": |
| 156 |
return _("Queued request"); |
| 157 |
case "Cancellation requested": |
| 158 |
return _("Cancellation requested"); |
| 159 |
case "Completed": |
| 160 |
return _("Completed"); |
| 161 |
case "Delete request": |
| 162 |
return _("Delete request"); |
| 163 |
default: |
| 164 |
return status_name; |
| 165 |
} |
| 166 |
} else { |
| 167 |
return ''; |
| 168 |
} |
| 169 |
}; |
| 170 |
|
| 171 |
// Render function for creating a row's action link |
| 172 |
var createActionLink = function(data, type, row) { |
| 173 |
return '<a class="btn btn-default btn-sm" ' + |
| 174 |
'href="/cgi-bin/koha/ill/ill-requests.pl?' + |
| 175 |
'method=illview&illrequest_id=' + |
| 176 |
row.illrequest_id + |
| 177 |
'">' + _("Manage request") + '</a>'; |
| 178 |
}; |
| 179 |
|
| 180 |
// Columns that require special treatment |
| 181 |
var specialCols = { |
| 182 |
action: { |
| 183 |
name: '', |
| 184 |
func: createActionLink |
| 185 |
}, |
| 186 |
borrowername: { |
| 187 |
name: _("Patron"), |
| 188 |
func: createPatronLink |
| 189 |
}, |
| 190 |
illrequest_id: { |
| 191 |
name: _("Request number"), |
| 192 |
func: createRequestId |
| 193 |
}, |
| 194 |
status: { |
| 195 |
name: _("Status"), |
| 196 |
func: createStatus |
| 197 |
}, |
| 198 |
biblio_id: { |
| 199 |
name: _("Bibliograpic record ID"), |
| 200 |
func: createBiblioLink |
| 201 |
}, |
| 202 |
library: { |
| 203 |
name: _("Library"), |
| 204 |
func: createLibrary |
| 205 |
} |
| 206 |
}; |
| 207 |
|
| 208 |
// Filter partner list |
| 209 |
$('#partner_filter').keyup(function() { |
| 210 |
var needle = $('#partner_filter').val(); |
| 211 |
$('#partners > option').each(function() { |
| 212 |
var regex = new RegExp(needle, 'i'); |
| 213 |
if ( |
| 214 |
needle.length == 0 || |
| 215 |
$(this).is(':selected') || |
| 216 |
$(this).text().match(regex) |
| 217 |
) { |
| 218 |
$(this).show(); |
| 219 |
} else { |
| 220 |
$(this).hide(); |
| 221 |
} |
| 222 |
}); |
| 223 |
}); |
| 224 |
|
| 225 |
// Display the modal containing request supplier metadata |
| 226 |
$('#ill-request-display-metadata').on('click', function(e) { |
| 227 |
e.preventDefault(); |
| 228 |
$('#dataPreview').modal({show:true}); |
| 229 |
}); |
| 230 |
|
| 231 |
// Get our data from the API and process it prior to passing |
| 232 |
// it to datatables |
| 233 |
var ajax = $.ajax( |
| 234 |
'/api/v1/illrequests?embed=metadata,patron,capabilities,library' |
| 235 |
).done(function() { |
| 236 |
var data = JSON.parse(ajax.responseText); |
| 237 |
// Make a copy, we'll be removing columns next and need |
| 238 |
// to be able to refer to data that has been removed |
| 239 |
var dataCopy = $.extend(true, [], data); |
| 240 |
// Remove all columns we're not interested in |
| 241 |
removeIgnore(dataCopy); |
| 242 |
// Expand columns that need it and create an array |
| 243 |
// of all column names |
| 244 |
$.each(dataCopy, function(k, row) { |
| 245 |
expandExpand(row); |
| 246 |
}); |
| 247 |
|
| 248 |
// Assemble an array of column definitions for passing |
| 249 |
// to datatables |
| 250 |
var colData = []; |
| 251 |
Object.keys(allCols).forEach(function(thisCol) { |
| 252 |
// Create the base column object |
| 253 |
var colObj = { |
| 254 |
name: thisCol, |
| 255 |
className: thisCol |
| 256 |
}; |
| 257 |
// We may need to process the data going in this |
| 258 |
// column, so do it if necessary |
| 259 |
if ( |
| 260 |
specialCols.hasOwnProperty(thisCol) && |
| 261 |
specialCols[thisCol].hasOwnProperty('func') |
| 262 |
) { |
| 263 |
colObj.render = specialCols[thisCol].func; |
| 264 |
} else { |
| 265 |
colObj.data = thisCol; |
| 266 |
} |
| 267 |
colData.push(colObj); |
| 268 |
}); |
| 269 |
|
| 270 |
// Initialise the datatable |
| 271 |
$('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { |
| 272 |
'aoColumnDefs': [ // Last column shouldn't be sortable or searchable |
| 273 |
{ |
| 274 |
'aTargets': [ 'actions' ], |
| 275 |
'bSortable': false, |
| 276 |
'bSearchable': false |
| 277 |
}, |
| 278 |
], |
| 279 |
'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending |
| 280 |
'processing': true, // Display a message when manipulating |
| 281 |
'iDisplayLength': 10, // 10 results per page |
| 282 |
'sPaginationType': "full_numbers", // Pagination display |
| 283 |
'deferRender': true, // Improve performance on big datasets |
| 284 |
'data': dataCopy, |
| 285 |
'columns': colData, |
| 286 |
'originalData': data // Enable render functions to access |
| 287 |
// our original data |
| 288 |
})); |
| 289 |
} |
| 290 |
); |
| 291 |
|
| 292 |
}); |
| 293 |
//]]> |
| 294 |
</script> |
| 295 |
</head> |
11 |
</head> |
| 296 |
|
12 |
|
| 297 |
<body id="illrequests" class="ill"> |
13 |
<body id="illrequests" class="ill"> |
|
Lines 308-317
Link Here
|
| 308 |
[% END %] |
24 |
[% END %] |
| 309 |
</div> |
25 |
</div> |
| 310 |
|
26 |
|
| 311 |
<div id="doc3" class="yui-t2"> |
27 |
<div class="main container-fluid"> |
| 312 |
<div id="bd"> |
28 |
<div class="row"> |
| 313 |
<div id="yui-main"> |
29 |
<div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> |
| 314 |
<div id="interlibraryloans" class="yui-b"> |
30 |
<main> |
|
|
31 |
|
| 32 |
<div id="interlibraryloans"> |
| 315 |
[% IF !backends_available %] |
33 |
[% IF !backends_available %] |
| 316 |
<div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div> |
34 |
<div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div> |
| 317 |
[% ELSE %] |
35 |
[% ELSE %] |
|
Lines 486-492
Link Here
|
| 486 |
[% ELSIF query_type == 'illview' %] |
204 |
[% ELSIF query_type == 'illview' %] |
| 487 |
[% req_status = request.status %] |
205 |
[% req_status = request.status %] |
| 488 |
<h1>Manage ILL request</h1> |
206 |
<h1>Manage ILL request</h1> |
| 489 |
<div id="toolbar" class="btn-toolbar"> |
207 |
<div class="btn-toolbar"> |
| 490 |
<a title="Edit request" id="ill-toolbar-btn-edit-action" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=edit_action&illrequest_id=[% request.illrequest_id | html %]"> |
208 |
<a title="Edit request" id="ill-toolbar-btn-edit-action" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=edit_action&illrequest_id=[% request.illrequest_id | html %]"> |
| 491 |
<span class="fa fa-pencil"></span> |
209 |
<span class="fa fa-pencil"></span> |
| 492 |
Edit request |
210 |
Edit request |
|
Lines 635-647
Link Here
|
| 635 |
[% END %] |
353 |
[% END %] |
| 636 |
[% END %] |
354 |
[% END %] |
| 637 |
</div> |
355 |
</div> |
| 638 |
</div> |
356 |
|
| 639 |
</div> |
357 |
</main> |
| 640 |
</div> |
358 |
</div> <!-- /.col-sm-12 --> |
|
|
359 |
</div> <!-- /.row --> |
| 360 |
|
| 641 |
|
361 |
|
| 642 |
[% TRY %] |
362 |
[% TRY %] |
| 643 |
[% PROCESS backend_jsinclude %] |
363 |
[% PROCESS backend_jsinclude %] |
| 644 |
[% CATCH %] |
364 |
[% CATCH %] |
| 645 |
[% END %] |
365 |
[% END %] |
| 646 |
|
366 |
|
|
|
367 |
[% MACRO jsinclude BLOCK %] |
| 368 |
[% INCLUDE 'datatables.inc' %] |
| 369 |
<script> |
| 370 |
$(document).ready(function() { |
| 371 |
|
| 372 |
// Illview Datatable setup |
| 373 |
|
| 374 |
// Fields we don't want to display |
| 375 |
var ignore = [ |
| 376 |
'accessurl', |
| 377 |
'backend', |
| 378 |
'branchcode', |
| 379 |
'completed', |
| 380 |
'capabilities', |
| 381 |
'cost', |
| 382 |
'medium', |
| 383 |
'notesopac', |
| 384 |
'notesstaff', |
| 385 |
'placed', |
| 386 |
'replied' |
| 387 |
]; |
| 388 |
|
| 389 |
// Fields we need to expand (flatten) |
| 390 |
var expand = [ |
| 391 |
'metadata', |
| 392 |
'patron' |
| 393 |
]; |
| 394 |
|
| 395 |
// Expanded fields |
| 396 |
// This is auto populated |
| 397 |
var expanded = {}; |
| 398 |
|
| 399 |
// The core fields that should be displayed first |
| 400 |
var core = [ |
| 401 |
'metadata_Author', |
| 402 |
'metadata_Title', |
| 403 |
'borrowername', |
| 404 |
'biblio_id', |
| 405 |
'library', |
| 406 |
'status', |
| 407 |
'updated', |
| 408 |
'illrequest_id', |
| 409 |
'action' |
| 410 |
]; |
| 411 |
|
| 412 |
// Remove any fields we're ignoring |
| 413 |
var removeIgnore = function(dataObj) { |
| 414 |
dataObj.forEach(function(thisRow) { |
| 415 |
ignore.forEach(function(thisIgnore) { |
| 416 |
if (thisRow.hasOwnProperty(thisIgnore)) { |
| 417 |
delete thisRow[thisIgnore]; |
| 418 |
} |
| 419 |
}); |
| 420 |
}); |
| 421 |
}; |
| 422 |
|
| 423 |
// Expand any fields we're expanding |
| 424 |
var expandExpand = function(row) { |
| 425 |
expand.forEach(function(thisExpand) { |
| 426 |
if (row.hasOwnProperty(thisExpand)) { |
| 427 |
if (!expanded.hasOwnProperty(thisExpand)) { |
| 428 |
expanded[thisExpand] = []; |
| 429 |
} |
| 430 |
var expandObj = row[thisExpand]; |
| 431 |
Object.keys(expandObj).forEach( |
| 432 |
function(thisExpandCol) { |
| 433 |
var expColName = thisExpand + '_' + thisExpandCol; |
| 434 |
// Keep a list of fields that have been expanded |
| 435 |
// so we can create toggle links for them |
| 436 |
if (expanded[thisExpand].indexOf(expColName) == -1) { |
| 437 |
expanded[thisExpand].push(expColName); |
| 438 |
} |
| 439 |
expandObj[expColName] = |
| 440 |
expandObj[thisExpandCol]; |
| 441 |
delete expandObj[thisExpandCol]; |
| 442 |
} |
| 443 |
); |
| 444 |
$.extend(true, row, expandObj); |
| 445 |
delete row[thisExpand]; |
| 446 |
} |
| 447 |
}); |
| 448 |
}; |
| 449 |
|
| 450 |
// Build a de-duped list of all column names |
| 451 |
var allCols = {}; |
| 452 |
core.map(function(thisCore) { |
| 453 |
allCols[thisCore] = 1; |
| 454 |
}); |
| 455 |
|
| 456 |
// Strip the expand prefix if it exists, we do this for display |
| 457 |
var stripPrefix = function(value) { |
| 458 |
expand.forEach(function(thisExpand) { |
| 459 |
var regex = new RegExp(thisExpand + '_', 'g'); |
| 460 |
value = value.replace(regex, ''); |
| 461 |
}); |
| 462 |
return value; |
| 463 |
}; |
| 464 |
|
| 465 |
// Our 'render' function for borrowerlink |
| 466 |
var createPatronLink = function(data, type, row) { |
| 467 |
return '<a title="' + _("View patron details") + '" ' + |
| 468 |
'href="/cgi-bin/koha/members/moremember.pl?' + |
| 469 |
'borrowernumber='+row.borrowernumber+'">' + |
| 470 |
row.patron_firstname + ' ' + row.patron_surname + |
| 471 |
'</a>'; |
| 472 |
}; |
| 473 |
|
| 474 |
// Our 'render' function for biblio_id |
| 475 |
var createBiblioLink = function(data, type, row) { |
| 476 |
return (row.biblio_id) ? |
| 477 |
'<a title="' + _("View record details") + '" ' + |
| 478 |
'href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + |
| 479 |
row.biblio_id + '">' + |
| 480 |
row.biblio_id + |
| 481 |
'</a>' : ''; |
| 482 |
}; |
| 483 |
|
| 484 |
// Our 'render' function for the library name |
| 485 |
var createLibrary = function(data, type, row) { |
| 486 |
return row.library.branchname; |
| 487 |
}; |
| 488 |
|
| 489 |
// Render function for request ID |
| 490 |
var createRequestId = function(data, type, row) { |
| 491 |
return row.id_prefix + row.illrequest_id; |
| 492 |
}; |
| 493 |
|
| 494 |
// Render function for request status |
| 495 |
var createStatus = function(data, type, row, meta) { |
| 496 |
var origData = meta.settings.oInit.originalData; |
| 497 |
if (origData.length > 0) { |
| 498 |
var status_name = meta.settings.oInit.originalData[0].capabilities[ |
| 499 |
row.status |
| 500 |
].name; |
| 501 |
switch( status_name ) { |
| 502 |
case "New request": |
| 503 |
return _("New request"); |
| 504 |
case "Requested": |
| 505 |
return _("Requested"); |
| 506 |
case "Requested from partners": |
| 507 |
return _("Requested from partners"); |
| 508 |
case "Request reverted": |
| 509 |
return _("Request reverted"); |
| 510 |
case "Queued request": |
| 511 |
return _("Queued request"); |
| 512 |
case "Cancellation requested": |
| 513 |
return _("Cancellation requested"); |
| 514 |
case "Completed": |
| 515 |
return _("Completed"); |
| 516 |
case "Delete request": |
| 517 |
return _("Delete request"); |
| 518 |
default: |
| 519 |
return status_name; |
| 520 |
} |
| 521 |
} else { |
| 522 |
return ''; |
| 523 |
} |
| 524 |
}; |
| 525 |
|
| 526 |
// Render function for creating a row's action link |
| 527 |
var createActionLink = function(data, type, row) { |
| 528 |
return '<a class="btn btn-default btn-xs" ' + |
| 529 |
'href="/cgi-bin/koha/ill/ill-requests.pl?' + |
| 530 |
'method=illview&illrequest_id=' + |
| 531 |
row.illrequest_id + |
| 532 |
'">' + _("Manage request") + '</a>'; |
| 533 |
}; |
| 534 |
|
| 535 |
// Columns that require special treatment |
| 536 |
var specialCols = { |
| 537 |
action: { |
| 538 |
name: '', |
| 539 |
func: createActionLink |
| 540 |
}, |
| 541 |
borrowername: { |
| 542 |
name: _("Patron"), |
| 543 |
func: createPatronLink |
| 544 |
}, |
| 545 |
illrequest_id: { |
| 546 |
name: _("Request number"), |
| 547 |
func: createRequestId |
| 548 |
}, |
| 549 |
status: { |
| 550 |
name: _("Status"), |
| 551 |
func: createStatus |
| 552 |
}, |
| 553 |
biblio_id: { |
| 554 |
name: _("Bibliograpic record ID"), |
| 555 |
func: createBiblioLink |
| 556 |
}, |
| 557 |
library: { |
| 558 |
name: _("Library"), |
| 559 |
func: createLibrary |
| 560 |
} |
| 561 |
}; |
| 562 |
|
| 563 |
// Filter partner list |
| 564 |
$('#partner_filter').keyup(function() { |
| 565 |
var needle = $('#partner_filter').val(); |
| 566 |
$('#partners > option').each(function() { |
| 567 |
var regex = new RegExp(needle, 'i'); |
| 568 |
if ( |
| 569 |
needle.length == 0 || |
| 570 |
$(this).is(':selected') || |
| 571 |
$(this).text().match(regex) |
| 572 |
) { |
| 573 |
$(this).show(); |
| 574 |
} else { |
| 575 |
$(this).hide(); |
| 576 |
} |
| 577 |
}); |
| 578 |
}); |
| 579 |
|
| 580 |
// Display the modal containing request supplier metadata |
| 581 |
$('#ill-request-display-metadata').on('click', function(e) { |
| 582 |
e.preventDefault(); |
| 583 |
$('#dataPreview').modal({show:true}); |
| 584 |
}); |
| 585 |
|
| 586 |
// Get our data from the API and process it prior to passing |
| 587 |
// it to datatables |
| 588 |
var ajax = $.ajax( |
| 589 |
'/api/v1/illrequests?embed=metadata,patron,capabilities,library' |
| 590 |
).done(function() { |
| 591 |
var data = JSON.parse(ajax.responseText); |
| 592 |
// Make a copy, we'll be removing columns next and need |
| 593 |
// to be able to refer to data that has been removed |
| 594 |
var dataCopy = $.extend(true, [], data); |
| 595 |
// Remove all columns we're not interested in |
| 596 |
removeIgnore(dataCopy); |
| 597 |
// Expand columns that need it and create an array |
| 598 |
// of all column names |
| 599 |
$.each(dataCopy, function(k, row) { |
| 600 |
expandExpand(row); |
| 601 |
}); |
| 602 |
|
| 603 |
// Assemble an array of column definitions for passing |
| 604 |
// to datatables |
| 605 |
var colData = []; |
| 606 |
Object.keys(allCols).forEach(function(thisCol) { |
| 607 |
// Create the base column object |
| 608 |
var colObj = { |
| 609 |
name: thisCol, |
| 610 |
className: thisCol |
| 611 |
}; |
| 612 |
// We may need to process the data going in this |
| 613 |
// column, so do it if necessary |
| 614 |
if ( |
| 615 |
specialCols.hasOwnProperty(thisCol) && |
| 616 |
specialCols[thisCol].hasOwnProperty('func') |
| 617 |
) { |
| 618 |
colObj.render = specialCols[thisCol].func; |
| 619 |
} else { |
| 620 |
colObj.data = thisCol; |
| 621 |
} |
| 622 |
colData.push(colObj); |
| 623 |
}); |
| 624 |
|
| 625 |
// Initialise the datatable |
| 626 |
$('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { |
| 627 |
'aoColumnDefs': [ // Last column shouldn't be sortable or searchable |
| 628 |
{ |
| 629 |
'aTargets': [ 'actions' ], |
| 630 |
'bSortable': false, |
| 631 |
'bSearchable': false |
| 632 |
}, |
| 633 |
], |
| 634 |
'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending |
| 635 |
'processing': true, // Display a message when manipulating |
| 636 |
'sPaginationType': "full_numbers", // Pagination display |
| 637 |
'deferRender': true, // Improve performance on big datasets |
| 638 |
'data': dataCopy, |
| 639 |
'columns': colData, |
| 640 |
'originalData': data // Enable render functions to access |
| 641 |
// our original data |
| 642 |
})); |
| 643 |
} |
| 644 |
); |
| 645 |
|
| 646 |
}); |
| 647 |
</script> |
| 648 |
[% END %] |
| 649 |
|
| 647 |
[% INCLUDE 'intranet-bottom.inc' %] |
650 |
[% INCLUDE 'intranet-bottom.inc' %] |