Bugzilla – Attachment 82461 Details for
Bug 20581
Allow manual selection of custom ILL request statuses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20581: Add display of status_alias to staff vw
Bug-20581-Add-display-of-statusalias-to-staff-vw.patch (text/plain), 26.07 KB, created by
Andrew Isherwood
on 2018-11-19 12:16:15 UTC
(
hide
)
Description:
Bug 20581: Add display of status_alias to staff vw
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2018-11-19 12:16:15 UTC
Size:
26.07 KB
patch
obsolete
>From 74395c1b46f454dc74ea1621b5747d48e402c6e1 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Tue, 17 Apr 2018 12:03:07 +0100 >Subject: [PATCH] Bug 20581: Add display of status_alias to staff vw > >- This patch adds display of the new status_alias value, when set, in >favour of the request's status value. >- It also allows the user to set a status_alias for an existing request. >When set, this value will be displayed in preference to the status. > >Signed-off-by: Niamh.Walker-Headon@it-tallaght.ie >--- > ill/ill-requests.pl | 11 +- > .../prog/en/modules/ill/ill-requests.tt | 535 ++++++++++++++++++++- > 2 files changed, 542 insertions(+), 4 deletions(-) > >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index 28e8cc634f..a2afb6f9a4 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -129,8 +129,11 @@ if ( $backends_available ) { > value => {} > }; > $template->param( >- whole => $backend_result, >- request => $request >+ whole => $backend_result, >+ request => $request, >+ status_aliases => scalar Koha::AuthorisedValues->search( >+ { category => 'ILLSTATUS' } >+ ) > ); > } else { > # Commit: >@@ -141,6 +144,10 @@ if ( $backends_available ) { > $request->price_paid($params->{price_paid}); > $request->notesopac($params->{notesopac}); > $request->notesstaff($params->{notesstaff}); >+ my $alias = ($params->{status_alias} =~ /\d/) ? >+ $params->{status_alias} : >+ undef; >+ $request->status_alias($alias); > $request->store; > my $backend_result = { > error => 0, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index f2a833f4f0..e9ab966b6c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -445,7 +445,25 @@ > <li class="status"> > <label class="status">Status:</label> > [% stat = request.status %] >- [% request.capabilities.$stat.name | html %] >+ [% current_alias = request.status_alias %] >+ <select id="status_alias" name="status_alias"> >+ [% IF !current_alias %] >+ <option value="" selected> >+ [% ELSE %] >+ <option value=""> >+ [% END %] >+ [% request.capabilities.$stat.name | html %] >+ </option> >+ [% FOREACH alias IN status_aliases %] >+ [% IF alias.id == current_alias %] >+ <option value="[% alias.id %]" selected> >+ [% ELSE %] >+ <option value="[% alias.id %]"> >+ [% END %] >+ [% alias.authorised_value | html %] >+ </option> >+ [% END %] >+ </select> > </li> > <li class="updated"> > <label class="updated">Last updated:</label> >@@ -555,7 +573,11 @@ > </li> > <li class="status"> > <span class="label status">Status:</span> >- [% request.capabilities.$req_status.name | html %] >+ [% IF request.statusalias %] >+ [% request.statusalias.authorised_value | html %] >+ [% ELSE %] >+ [% request.capabilities.$req_status.name | html%] >+ [% END %] > </li> > <li class="updated"> > <span class="label updated">Last updated:</span> >@@ -707,4 +729,513 @@ > [% CATCH %] > [% END %] > >+[% MACRO jsinclude BLOCK %] >+ [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'calendar.inc' %] >+ [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] >+ <script> >+ $(document).ready(function() { >+ >+ // Illview Datatable setup >+ >+ var table; >+ >+ // Filters that are active >+ var activeFilters = {}; >+ >+ // Fields we don't want to display >+ var ignore = [ >+ 'accessurl', >+ 'backend', >+ 'branchcode', >+ 'completed', >+ 'capabilities', >+ 'cost', >+ 'medium', >+ 'notesopac', >+ 'notesstaff', >+ 'replied' >+ ]; >+ >+ // Fields we need to expand (flatten) >+ var expand = [ >+ 'metadata', >+ 'patron' >+ ]; >+ >+ // Expanded fields >+ // This is auto populated >+ var expanded = {}; >+ >+ // The core fields that should be displayed first >+ var core = [ >+ 'metadata_author', >+ 'metadata_title', >+ 'borrowername', >+ 'biblio_id', >+ 'library', >+ 'status', >+ 'placed', >+ 'placed_formatted', >+ 'updated', >+ 'updated_formatted', >+ 'illrequest_id', >+ 'comments', >+ 'patron_cardnumber', >+ 'action' >+ ]; >+ >+ // Filterable columns >+ var filterable = { >+ status: { >+ prep: function(tableData, oData) { >+ var uniques = {}; >+ tableData.forEach(function(row) { >+ var resolvedName = getStatusName( >+ oData[0].capabilities[row.status].name >+ ); >+ uniques[resolvedName] = 1 >+ }); >+ Object.keys(uniques).sort().forEach(function(unique) { >+ $('#illfilter_status').append( >+ '<option value="' + unique + >+ '">' + unique + '</option>' >+ ); >+ }); >+ }, >+ listener: function() { >+ var me = 'status'; >+ $('#illfilter_status').change(function() { >+ var sel = $('#illfilter_status option:selected').val(); >+ if (sel && sel.length > 0) { >+ activeFilters[me] = function() { >+ table.column(5).search(sel); >+ } >+ } else { >+ if (activeFilters.hasOwnProperty(me)) { >+ delete activeFilters[me]; >+ } >+ } >+ }); >+ }, >+ clear: function() { >+ $('#illfilter_status').val(''); >+ } >+ }, >+ pickupBranch: { >+ prep: function(tableData, oData) { >+ var uniques = {}; >+ tableData.forEach(function(row) { >+ uniques[row.library.branchname] = 1 >+ }); >+ Object.keys(uniques).sort().forEach(function(unique) { >+ $('#illfilter_branchname').append( >+ '<option value="' + unique + >+ '">' + unique + '</option>' >+ ); >+ }); >+ }, >+ listener: function() { >+ var me = 'pickupBranch'; >+ $('#illfilter_branchname').change(function() { >+ var sel = $('#illfilter_branchname option:selected').val(); >+ if (sel && sel.length > 0) { >+ activeFilters[me] = function() { >+ table.column(4).search(sel); >+ } >+ } else { >+ if (activeFilters.hasOwnProperty(me)) { >+ delete activeFilters[me]; >+ } >+ } >+ }); >+ }, >+ clear: function() { >+ $('#illfilter_branchname').val(''); >+ } >+ }, >+ barcode: { >+ listener: function() { >+ var me = 'barcode'; >+ $('#illfilter_barcode').change(function() { >+ var val = $('#illfilter_barcode').val(); >+ if (val && val.length > 0) { >+ activeFilters[me] = function() { >+ table.column(12).search(val); >+ } >+ } else { >+ if (activeFilters.hasOwnProperty(me)) { >+ delete activeFilters[me]; >+ } >+ } >+ }); >+ }, >+ clear: function() { >+ $('#illfilter_barcode').val(''); >+ } >+ }, >+ dateModified: { >+ clear: function() { >+ $('#illfilter_datemodified_start, #illfilter_datemodified_end').val(''); >+ } >+ }, >+ datePlaced: { >+ clear: function() { >+ $('#illfilter_dateplaced_start, #illfilter_dateplaced_end').val(''); >+ } >+ } >+ }; >+ >+ // Remove any fields we're ignoring >+ var removeIgnore = function(dataObj) { >+ dataObj.forEach(function(thisRow) { >+ ignore.forEach(function(thisIgnore) { >+ if (thisRow.hasOwnProperty(thisIgnore)) { >+ delete thisRow[thisIgnore]; >+ } >+ }); >+ }); >+ }; >+ >+ // Expand any fields we're expanding >+ var expandExpand = function(row) { >+ expand.forEach(function(thisExpand) { >+ if (row.hasOwnProperty(thisExpand)) { >+ if (!expanded.hasOwnProperty(thisExpand)) { >+ expanded[thisExpand] = []; >+ } >+ var expandObj = row[thisExpand]; >+ Object.keys(expandObj).forEach( >+ function(thisExpandCol) { >+ var expColName = thisExpand + '_' + thisExpandCol; >+ // Keep a list of fields that have been expanded >+ // so we can create toggle links for them >+ if (expanded[thisExpand].indexOf(expColName) == -1) { >+ expanded[thisExpand].push(expColName); >+ } >+ expandObj[expColName] = >+ expandObj[thisExpandCol]; >+ delete expandObj[thisExpandCol]; >+ } >+ ); >+ $.extend(true, row, expandObj); >+ delete row[thisExpand]; >+ } >+ }); >+ }; >+ >+ // Build a de-duped list of all column names >+ var allCols = {}; >+ core.map(function(thisCore) { >+ allCols[thisCore] = 1; >+ }); >+ >+ // Strip the expand prefix if it exists, we do this for display >+ var stripPrefix = function(value) { >+ expand.forEach(function(thisExpand) { >+ var regex = new RegExp(thisExpand + '_', 'g'); >+ value = value.replace(regex, ''); >+ }); >+ return value; >+ }; >+ >+ // Our 'render' function for borrowerlink >+ var createPatronLink = function(data, type, row) { >+ var patronLink = '<a title="' + _("View borrower details") + '" ' + >+ 'href="/cgi-bin/koha/members/moremember.pl?' + >+ 'borrowernumber='+row.borrowernumber+'">'; >+ if ( row.patron_firstname ) { >+ patronLink = patronLink + row.patron_firstname + ' '; >+ } >+ patronLink = patronLink + row.patron_surname + '</a>'; >+ return patronLink; >+ }; >+ >+ // Our 'render' function for the library name >+ var createLibrary = function(data, type, row) { >+ return row.library.branchname; >+ }; >+ >+ // Render function for request ID >+ var createRequestId = function(data, type, row) { >+ return row.id_prefix + row.illrequest_id; >+ }; >+ >+ // Render function for request status >+ var createStatus = function(data, type, row, meta) { >+ if (row.status_alias) { >+ return row.status_alias.authorised_value; >+ } else { >+ var origData = meta.settings.oInit.originalData; >+ if (origData.length > 0) { >+ var status_name = meta.settings.oInit.originalData[0].capabilities[ >+ row.status >+ ].name; >+ return getStatusName(status_name); >+ } else { >+ return ''; >+ } >+ } >+ }; >+ >+ var getStatusName = function(origName) { >+ switch( origName ) { >+ case "New request": >+ return _("New request"); >+ case "Requested": >+ return _("Requested"); >+ case "Requested from partners": >+ return _("Requested from partners"); >+ case "Request reverted": >+ return _("Request reverted"); >+ case "Queued request": >+ return _("Queued request"); >+ case "Cancellation requested": >+ return _("Cancellation requested"); >+ case "Completed": >+ return _("Completed"); >+ case "Delete request": >+ return _("Delete request"); >+ default: >+ return origName; >+ } >+ }; >+ >+ // Render function for creating a row's action link >+ var createActionLink = function(data, type, row) { >+ return '<a class="btn btn-default btn-sm" ' + >+ 'href="/cgi-bin/koha/ill/ill-requests.pl?' + >+ 'method=illview&illrequest_id=' + >+ row.illrequest_id + >+ '">' + _("Manage request") + '</a>'; >+ }; >+ >+ // Columns that require special treatment >+ var specialCols = { >+ action: { >+ name: '', >+ func: createActionLink >+ }, >+ borrowername: { >+ name: _("Patron"), >+ func: createPatronLink >+ }, >+ illrequest_id: { >+ name: _("Request number"), >+ func: createRequestId >+ }, >+ status: { >+ name: _("Status"), >+ func: createStatus >+ }, >+ biblio_id: { >+ name: _("Biblio ID") >+ }, >+ library: { >+ name: _("Library"), >+ func: createLibrary >+ }, >+ updated: { >+ name: _("Updated on"), >+ }, >+ patron_cardnumber: { >+ name: _("Patron barcode") >+ } >+ }; >+ >+ // Toggle request attributes in Illview >+ $('#toggle_requestattributes').on('click', function(e) { >+ e.preventDefault(); >+ $('#requestattributes').toggleClass('content_hidden'); >+ }); >+ >+ // Toggle new comment form in Illview >+ $('#toggle_addcomment').on('click', function(e) { >+ e.preventDefault(); >+ $('#addcomment').toggleClass('content_hidden'); >+ }); >+ >+ // Filter partner list >+ $('#partner_filter').keyup(function() { >+ var needle = $('#partner_filter').val(); >+ $('#partners > option').each(function() { >+ var regex = new RegExp(needle, 'i'); >+ if ( >+ needle.length == 0 || >+ $(this).is(':selected') || >+ $(this).text().match(regex) >+ ) { >+ $(this).show(); >+ } else { >+ $(this).hide(); >+ } >+ }); >+ }); >+ >+ // Display the modal containing request supplier metadata >+ $('#ill-request-display-metadata').on('click', function(e) { >+ e.preventDefault(); >+ $('#dataPreview').modal({show:true}); >+ }); >+ >+ // Get our data from the API and process it prior to passing >+ // it to datatables >+ var ajax = $.ajax( >+ '/api/v1/illrequests?embed=metadata,patron,capabilities,library' >+ ).done(function() { >+ var data = JSON.parse(ajax.responseText); >+ // Make a copy, we'll be removing columns next and need >+ // to be able to refer to data that has been removed >+ var dataCopy = $.extend(true, [], data); >+ // Remove all columns we're not interested in >+ removeIgnore(dataCopy); >+ // Expand columns that need it and create an array >+ // of all column names >+ $.each(dataCopy, function(k, row) { >+ expandExpand(row); >+ }); >+ >+ // Assemble an array of column definitions for passing >+ // to datatables >+ var colData = []; >+ Object.keys(allCols).forEach(function(thisCol) { >+ // Create the base column object >+ var colObj = { >+ name: thisCol, >+ className: thisCol, >+ defaultContent: '' >+ }; >+ // We may need to process the data going in this >+ // column, so do it if necessary >+ if ( >+ specialCols.hasOwnProperty(thisCol) && >+ specialCols[thisCol].hasOwnProperty('func') >+ ) { >+ colObj.render = specialCols[thisCol].func; >+ } else { >+ colObj.data = thisCol; >+ } >+ colData.push(colObj); >+ }); >+ >+ // Initialise the datatable >+ table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { >+ 'aoColumnDefs': [ >+ { // Last column shouldn't be sortable or searchable >+ 'aTargets': [ 'actions' ], >+ 'bSortable': false, >+ 'bSearchable': false >+ }, >+ { // Hide the two date columns we use just for sorting >+ 'aTargets': [ 'placed', 'updated' ], >+ 'bVisible': false, >+ 'bSearchable': true >+ }, >+ { // When sorting 'placed', we want to use the >+ // unformatted column >+ 'aTargets': [ 'placed_formatted'], >+ 'iDataSort': 7 >+ }, >+ { // When sorting 'updated', we want to use the >+ // unformatted column >+ 'aTargets': [ 'updated_formatted'], >+ 'iDataSort': 9 >+ }, >+ { >+ 'aTargets': [ 'patron_cardnumber' ], >+ 'bVisible': false, >+ 'bSearchable': true >+ } >+ ], >+ 'aaSorting': [[ 9, 'desc' ]], // Default sort, updated descending >+ 'processing': true, // Display a message when manipulating >+ 'sPaginationType': "full_numbers", // Pagination display >+ 'deferRender': true, // Improve performance on big datasets >+ 'data': dataCopy, >+ 'columns': colData, >+ 'originalData': data, // Enable render functions to access >+ // our original data >+ 'initComplete': function() { >+ >+ // Prepare any filter elements that need it >+ for (var el in filterable) { >+ if (filterable.hasOwnProperty(el)) { >+ if (filterable[el].hasOwnProperty('prep')) { >+ filterable[el].prep(dataCopy, data); >+ } >+ if (filterable[el].hasOwnProperty('listener')) { >+ filterable[el].listener(); >+ } >+ } >+ } >+ >+ } >+ })); >+ >+ // Custom date range filtering >+ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { >+ var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate'); >+ var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate'); >+ var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate'); >+ var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate'); >+ var rowPlaced = data[6] ? new Date(data[6]) : null; >+ var rowModified = data[8] ? new Date(data[8]) : null; >+ var placedPassed = true; >+ var modifiedPassed = true; >+ if (placedStart && rowPlaced && rowPlaced < placedStart) { >+ placedPassed = false >+ }; >+ if (placedEnd && rowPlaced && rowPlaced > placedEnd) { >+ placedPassed = false; >+ } >+ if (modifiedStart && rowModified && rowModified < modifiedStart) { >+ modifiedPassed = false >+ }; >+ if (modifiedEnd && rowModified && rowModified > modifiedEnd) { >+ modifiedPassed = false; >+ } >+ >+ return placedPassed && modifiedPassed; >+ >+ }); >+ >+ } >+ ); >+ >+ var clearSearch = function() { >+ table.search('').columns().search(''); >+ activeFilters = {}; >+ for (var filter in filterable) { >+ if ( >+ filterable.hasOwnProperty(filter) && >+ filterable[filter].hasOwnProperty('clear') >+ ) { >+ filterable[filter].clear(); >+ } >+ } >+ table.draw(); >+ }; >+ >+ // Apply any search filters, or clear any previous >+ // ones >+ $('#illfilter_form').submit(function(event) { >+ event.preventDefault(); >+ table.search('').columns().search(''); >+ for (var active in activeFilters) { >+ if (activeFilters.hasOwnProperty(active)) { >+ activeFilters[active](); >+ } >+ } >+ table.draw(); >+ }); >+ >+ // Clear all filters >+ $('#clear_search').click(function() { >+ clearSearch(); >+ }); >+ >+ }); >+ </script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20581
:
74323
|
74324
|
74325
|
74326
|
74327
|
74362
|
75333
|
75334
|
75810
|
77819
|
77820
|
77821
|
77822
|
77823
|
77824
|
77825
|
77826
|
78376
|
78377
|
78378
|
78379
|
78380
|
78381
|
78382
|
78383
|
78384
|
78431
|
78515
|
78516
|
78517
|
78518
|
78519
|
78520
|
78521
|
78522
|
78523
|
80279
|
80280
|
80281
|
80282
|
80283
|
80284
|
80285
|
80286
|
80474
|
80475
|
80501
|
80503
|
80505
|
80598
|
80599
|
80600
|
82063
|
82064
|
82065
|
82066
|
82067
|
82068
|
82069
|
82070
|
82071
|
82072
|
82073
|
82074
|
82075
|
82076
|
82443
|
82444
|
82445
|
82446
|
82447
|
82448
|
82449
|
82450
|
82451
|
82452
|
82453
|
82454
|
82455
|
82456
|
82457
|
82458
|
82459
|
82460
|
82461
|
82462
|
82463
|
82464
|
82465
|
82466
|
82467
|
82468
|
82472
|
82483
|
82484
|
82485
|
82486
|
82487
|
82488
|
82489
|
82490
|
82491
|
82492
|
82493
|
82494
|
82495
|
82496
|
82733
|
84202
|
84404
|
84768
|
84770
|
84771
|
84772
|
84773
|
84774
|
84775
|
84776
|
84777
|
84778
|
84779
|
84780
|
84781
|
84782
|
84783
|
84784
|
84785
|
84791
|
84814
|
84818
|
84819
|
84844
|
84911
|
84912
|
84913
|
84914
|
84915
|
84916
|
84917
|
84918
|
84919
|
84920
|
84921
|
84922
|
84923
|
84924
|
84925
|
84926
|
84927
|
84928
|
84929
|
84930
|
84931
|
84964
|
85075
|
85076
|
85077
|
85078
|
85079
|
85080
|
85081
|
85082
|
85083
|
85084
|
85085
|
85086
|
85087
|
85088
|
85089
|
85090
|
85091
|
85092
|
85093
|
85094
|
85095
|
85096