Lines 3-8
Link Here
|
3 |
[% USE Branches %] |
3 |
[% USE Branches %] |
4 |
[% USE Koha %] |
4 |
[% USE Koha %] |
5 |
[% USE KohaDates %] |
5 |
[% USE KohaDates %] |
|
|
6 |
[% USE ColumnsSettings %] |
6 |
|
7 |
|
7 |
[% INCLUDE 'doc-head-open.inc' %] |
8 |
[% INCLUDE 'doc-head-open.inc' %] |
8 |
<title>Koha › ILL requests ›</title> |
9 |
<title>Koha › ILL requests ›</title> |
Lines 10-70
Link Here
|
10 |
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] |
11 |
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] |
11 |
[% Asset.css("css/datatables.css") | $raw %] |
12 |
[% Asset.css("css/datatables.css") | $raw %] |
12 |
[% INCLUDE 'datatables.inc' %] |
13 |
[% INCLUDE 'datatables.inc' %] |
|
|
14 |
[% INCLUDE 'columns_settings.inc' %] |
13 |
<script type="text/javascript"> |
15 |
<script type="text/javascript"> |
14 |
//<![CDATA[ |
16 |
//<![CDATA[ |
15 |
$(document).ready(function() { |
17 |
$(document).ready(function() { |
16 |
|
18 |
|
17 |
// Illview Datatable setup |
19 |
// Illview Datatable setup |
18 |
|
20 |
|
19 |
// Fields we don't want to display |
21 |
var columns_settings = [% ColumnsSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; |
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 |
|
22 |
|
34 |
// Fields we need to expand (flatten) |
23 |
// Fields we need to expand (flatten) |
35 |
var expand = [ |
24 |
var expand = [ |
36 |
'metadata', |
25 |
'metadata', |
37 |
'patron' |
26 |
'patron', |
|
|
27 |
'library' |
38 |
]; |
28 |
]; |
39 |
|
29 |
|
40 |
// Expanded fields |
30 |
// Expanded fields |
41 |
// This is auto populated |
31 |
// This is auto populated |
42 |
var expanded = {}; |
32 |
var expanded = {}; |
43 |
|
33 |
|
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 |
34 |
// Expand any fields we're expanding |
69 |
var expandExpand = function(row) { |
35 |
var expandExpand = function(row) { |
70 |
expand.forEach(function(thisExpand) { |
36 |
expand.forEach(function(thisExpand) { |
Lines 75-81
Link Here
|
75 |
var expandObj = row[thisExpand]; |
41 |
var expandObj = row[thisExpand]; |
76 |
Object.keys(expandObj).forEach( |
42 |
Object.keys(expandObj).forEach( |
77 |
function(thisExpandCol) { |
43 |
function(thisExpandCol) { |
78 |
var expColName = thisExpand + '_' + thisExpandCol; |
44 |
var expColName = thisExpand + '_' + thisExpandCol.replace(/\s/g,'_'); |
79 |
// Keep a list of fields that have been expanded |
45 |
// Keep a list of fields that have been expanded |
80 |
// so we can create toggle links for them |
46 |
// so we can create toggle links for them |
81 |
if (expanded[thisExpand].indexOf(expColName) == -1) { |
47 |
if (expanded[thisExpand].indexOf(expColName) == -1) { |
Lines 92-103
Link Here
|
92 |
}); |
58 |
}); |
93 |
}; |
59 |
}; |
94 |
|
60 |
|
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 |
61 |
// Strip the expand prefix if it exists, we do this for display |
102 |
var stripPrefix = function(value) { |
62 |
var stripPrefix = function(value) { |
103 |
expand.forEach(function(thisExpand) { |
63 |
expand.forEach(function(thisExpand) { |
Lines 113-118
Link Here
|
113 |
'href="/cgi-bin/koha/members/moremember.pl?' + |
73 |
'href="/cgi-bin/koha/members/moremember.pl?' + |
114 |
'borrowernumber='+row.borrowernumber+'">' + |
74 |
'borrowernumber='+row.borrowernumber+'">' + |
115 |
row.patron_firstname + ' ' + row.patron_surname + |
75 |
row.patron_firstname + ' ' + row.patron_surname + |
|
|
76 |
' [' + row.patron_cardnumber + ' ]' |
116 |
'</a>'; |
77 |
'</a>'; |
117 |
}; |
78 |
}; |
118 |
|
79 |
|
Lines 136-141
Link Here
|
136 |
return row.id_prefix + row.illrequest_id; |
97 |
return row.id_prefix + row.illrequest_id; |
137 |
}; |
98 |
}; |
138 |
|
99 |
|
|
|
100 |
// Render function for type |
101 |
var createType = function(data, type, row) { |
102 |
if (!row.hasOwnProperty('metadata_Type') || !row.metadata_Type) { |
103 |
if (row.hasOwnProperty('medium') && row.medium) { |
104 |
row.metadata_Type = row.medium; |
105 |
} else { |
106 |
row.metadata_Type = null; |
107 |
} |
108 |
} |
109 |
return row.metadata_Type; |
110 |
}; |
111 |
|
139 |
// Render function for request status |
112 |
// Render function for request status |
140 |
var createStatus = function(data, type, row, meta) { |
113 |
var createStatus = function(data, type, row, meta) { |
141 |
var origData = meta.settings.oInit.originalData; |
114 |
var origData = meta.settings.oInit.originalData; |
Lines 180-207
Link Here
|
180 |
// Columns that require special treatment |
153 |
// Columns that require special treatment |
181 |
var specialCols = { |
154 |
var specialCols = { |
182 |
action: { |
155 |
action: { |
183 |
name: '', |
|
|
184 |
func: createActionLink |
156 |
func: createActionLink |
185 |
}, |
157 |
}, |
186 |
borrowername: { |
158 |
borrowernumber: { |
187 |
name: _("Patron"), |
|
|
188 |
func: createPatronLink |
159 |
func: createPatronLink |
189 |
}, |
160 |
}, |
190 |
illrequest_id: { |
161 |
illrequest_id: { |
191 |
name: _("Request number"), |
|
|
192 |
func: createRequestId |
162 |
func: createRequestId |
193 |
}, |
163 |
}, |
194 |
status: { |
164 |
status: { |
195 |
name: _("Status"), |
|
|
196 |
func: createStatus |
165 |
func: createStatus |
197 |
}, |
166 |
}, |
|
|
167 |
<<<<<<< HEAD |
198 |
biblio_id: { |
168 |
biblio_id: { |
199 |
name: _("Bibliograpic record ID"), |
169 |
name: _("Bibliograpic record ID"), |
200 |
func: createBiblioLink |
170 |
func: createBiblioLink |
|
|
171 |
======= |
172 |
metadata_Medium: { |
173 |
func: createType |
174 |
>>>>>>> Bug 21063: Add ability to show / hide columns |
201 |
}, |
175 |
}, |
202 |
library: { |
176 |
metadata_Type: { |
203 |
name: _("Library"), |
177 |
func: createType |
204 |
func: createLibrary |
|
|
205 |
} |
178 |
} |
206 |
}; |
179 |
}; |
207 |
|
180 |
|
Lines 237-244
Link Here
|
237 |
// Make a copy, we'll be removing columns next and need |
210 |
// Make a copy, we'll be removing columns next and need |
238 |
// to be able to refer to data that has been removed |
211 |
// to be able to refer to data that has been removed |
239 |
var dataCopy = $.extend(true, [], data); |
212 |
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 |
213 |
// Expand columns that need it and create an array |
243 |
// of all column names |
214 |
// of all column names |
244 |
$.each(dataCopy, function(k, row) { |
215 |
$.each(dataCopy, function(k, row) { |
Lines 248-274
Link Here
|
248 |
// Assemble an array of column definitions for passing |
219 |
// Assemble an array of column definitions for passing |
249 |
// to datatables |
220 |
// to datatables |
250 |
var colData = []; |
221 |
var colData = []; |
251 |
Object.keys(allCols).forEach(function(thisCol) { |
222 |
columns_settings.forEach(function(thisCol) { |
|
|
223 |
var colName = thisCol.columnname; |
252 |
// Create the base column object |
224 |
// Create the base column object |
253 |
var colObj = { |
225 |
var colObj = $.extend({}, thisCol); |
254 |
name: thisCol, |
226 |
colObj.name = colName; |
255 |
className: thisCol |
227 |
colObj.className = colName; |
256 |
}; |
|
|
257 |
// We may need to process the data going in this |
228 |
// We may need to process the data going in this |
258 |
// column, so do it if necessary |
229 |
// column, so do it if necessary |
259 |
if ( |
230 |
if ( |
260 |
specialCols.hasOwnProperty(thisCol) && |
231 |
specialCols.hasOwnProperty(colName) && |
261 |
specialCols[thisCol].hasOwnProperty('func') |
232 |
specialCols[colName].hasOwnProperty('func') |
262 |
) { |
233 |
) { |
263 |
colObj.render = specialCols[thisCol].func; |
234 |
colObj.render = specialCols[colName].func; |
264 |
} else { |
235 |
} else { |
265 |
colObj.data = thisCol; |
236 |
colObj.data = colName; |
266 |
} |
237 |
} |
|
|
238 |
// Make sure properties that aren't present in the API |
239 |
// response are populated with null to avoid Datatables |
240 |
// choking on their absence |
241 |
dataCopy.forEach(function(thisData) { |
242 |
if (!thisData.hasOwnProperty(colName)) { |
243 |
thisData[colName] = null; |
244 |
} |
245 |
}); |
267 |
colData.push(colObj); |
246 |
colData.push(colObj); |
268 |
}); |
247 |
}); |
269 |
|
248 |
|
270 |
// Initialise the datatable |
249 |
// Initialise the datatable |
271 |
$('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { |
250 |
var illTable = KohaTable("ill-requests", { |
272 |
'aoColumnDefs': [ // Last column shouldn't be sortable or searchable |
251 |
'aoColumnDefs': [ // Last column shouldn't be sortable or searchable |
273 |
{ |
252 |
{ |
274 |
'aTargets': [ 'actions' ], |
253 |
'aTargets': [ 'actions' ], |
Lines 276-282
Link Here
|
276 |
'bSearchable': false |
255 |
'bSearchable': false |
277 |
}, |
256 |
}, |
278 |
], |
257 |
], |
279 |
'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending |
258 |
'aaSorting': [[ 7, 'desc' ]], // Default sort, updated descending |
280 |
'processing': true, // Display a message when manipulating |
259 |
'processing': true, // Display a message when manipulating |
281 |
'iDisplayLength': 10, // 10 results per page |
260 |
'iDisplayLength': 10, // 10 results per page |
282 |
'sPaginationType': "full_numbers", // Pagination display |
261 |
'sPaginationType': "full_numbers", // Pagination display |
Lines 285-291
Link Here
|
285 |
'columns': colData, |
264 |
'columns': colData, |
286 |
'originalData': data // Enable render functions to access |
265 |
'originalData': data // Enable render functions to access |
287 |
// our original data |
266 |
// our original data |
288 |
})); |
267 |
}, columns_settings); |
289 |
} |
268 |
} |
290 |
); |
269 |
); |
291 |
|
270 |
|
Lines 613-627
Link Here
|
613 |
<table id="ill-requests"> |
592 |
<table id="ill-requests"> |
614 |
<thead> |
593 |
<thead> |
615 |
<tr id="illview-header"> |
594 |
<tr id="illview-header"> |
616 |
<th>Author</th> |
595 |
<th scope="col">Request ID</th> |
617 |
<th>Title</th> |
596 |
<th scope="col">Author</th> |
618 |
<th>Patron</th> |
597 |
<th scope="col">Title</th> |
619 |
<th>Bibliographic record ID</th> |
598 |
<th scope="col">Article title</th> |
620 |
<th>Library</th> |
599 |
<th scope="col">Issue</th> |
621 |
<th>Status</th> |
600 |
<th scope="col">Volume</th> |
622 |
<th>Updated on</th> |
601 |
<th scope="col">Year</th> |
623 |
<th>Request number</th> |
602 |
<th scope="col">Pages</th> |
624 |
<th class="actions"></th> |
603 |
<th scope="col">Type</th> |
|
|
604 |
<th scope="col">Order ID</th> |
605 |
<th scope="col">Biblio ID</th> |
606 |
<th scope="col">Patron</th> |
607 |
<th scope="col">Branch</th> |
608 |
<th scope="col">Status</th> |
609 |
<th scope="col">Placed on</th> |
610 |
<th scope="col">Replied</th> |
611 |
<th scope="col" class="updated">Updated on</th> |
612 |
<th scope="col">Completed on</th> |
613 |
<th scope="col">Access URL</th> |
614 |
<th scope="col">Cost</th> |
615 |
<th scope="col">OPAC notes</th> |
616 |
<th scope="col">Staff notes</th> |
617 |
<th scope="col">Backend</th> |
618 |
<th scope="col" class="actions"></th> |
625 |
</tr> |
619 |
</tr> |
626 |
</thead> |
620 |
</thead> |
627 |
<tbody id="illview-body"> |
621 |
<tbody id="illview-body"> |
628 |
- |
|
|