From cbeaafba3e2cfe2a91b62a18934e632161d105d3 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 5 Mar 2019 12:11:26 +0000 Subject: [PATCH] Bug 21063: (follow-up) Fix missing table values As per comment #48 here: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21063#c48 >pages This was a misnamed property in colums_settings.yml >comments This was a missing embed in the API call, probably a rebase error >article (part title) This was a bug. A combination of a misnamed property in columns_settings.yml and a missing "render" method on the datatable >completed on This was an oversight and had apparently never worked. It has now been added >cost I cannot replicate this, cost is displaying fine for me --- Koha/Illrequest.pm | 2 ++ Koha/REST/V1/Illrequests.pm | 2 +- admin/columns_settings.yml | 9 +++++++-- api/v1/swagger/paths/illrequests.json | 6 ++++++ .../prog/en/modules/ill/ill-requests.tt | 22 ++++++++++++++++++++-- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 8bec6074f1..5f7019a139 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -25,6 +25,7 @@ use File::Basename qw( basename ); use Encode qw( encode ); use Mail::Sendmail; use Try::Tiny; +use DateTime; use Koha::Database; use Koha::Email; @@ -659,6 +660,7 @@ Mark a request as completed (status = COMP). sub mark_completed { my ( $self ) = @_; $self->status('COMP')->store; + $self->completed(DateTime->now)->store; return { error => 0, status => '', diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 7e79eb60fa..f8385a7fd2 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -43,7 +43,7 @@ sub list { my $args = $c->req->params->to_hash // {}; my $output = []; - my @format_dates = ( 'placed', 'updated' ); + my @format_dates = ( 'placed', 'updated', 'completed' ); # Create a hash where all keys are embedded values # Enables easy checking diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 31a13fc863..f93d7585dd 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -360,7 +360,7 @@ modules: - columnname: metadata_title - - columnname: metadata_item_part_title + columnname: metadata_article_title - columnname: metadata_issue - @@ -368,7 +368,7 @@ modules: - columnname: metadata_year - - columnname: metadata_item_part_pages + columnname: metadata_pages - columnname: metadata_type - @@ -399,6 +399,11 @@ modules: columnname: replied - columnname: completed + cannot_be_toggled: 1 + cannot_be_modified: 1 + is_hidden: 1 + - + columnname: completed_formatted - columnname: accessurl - diff --git a/api/v1/swagger/paths/illrequests.json b/api/v1/swagger/paths/illrequests.json index ac63bc4f55..99ec0dd95b 100644 --- a/api/v1/swagger/paths/illrequests.json +++ b/api/v1/swagger/paths/illrequests.json @@ -51,6 +51,12 @@ "required": false, "type": "string" }, { + "name": "completed_formatted", + "in": "query", + "description": "The date the request was considered complete formatted", + "required": false, + "type": "string" + }, { "name": "status", "in": "query", "description": "A full status string e.g. REQREV", 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 ab4b3a916d..59128904e7 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 @@ -527,7 +527,8 @@   Updated on Replied - Completed on +   + Completed on Access URL Cost Comments @@ -749,6 +750,14 @@ '' : ''; }; + // Our 'render' function for title + var createTitle = function(data, type, row) { + return ( + row.hasOwnProperty('metadata_container_title') && + row.metadata_container_title + ) ? row.metadata_container_title : row.metadata_title; + }; + // Render function for request ID var createRequestId = function(data, type, row) { return row.id_prefix + row.illrequest_id; @@ -834,6 +843,9 @@ func: createBiblioLink, skipSanitize: true }, + metadata_title: { + func: createTitle + }, metadata_Type: { func: createType }, @@ -905,7 +917,7 @@ // 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,status_alias' + '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias,comments' ).done(function() { var data = JSON.parse(ajax.responseText); // Make a copy, we'll be removing columns next and need @@ -960,6 +972,7 @@ }); colData.push(colObj); }); + console.log(colData); // Initialise the datatable table = KohaTable("ill-requests", { @@ -978,6 +991,11 @@ // unformatted column 'aTargets': [ 'updated_formatted'], 'iDataSort': 16 + }, + { // When sorting 'completed', we want to use the + // unformatted column + 'aTargets': [ 'completed_formatted'], + 'iDataSort': 19 } ], 'aaSorting': [[ 16, 'desc' ]], // Default sort, updated descending -- 2.11.0