From 33084fb40c772ec1f76cbbcb06bcbfc5b87a3042 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 30 Mar 2023 12:07:17 +0200 Subject: [PATCH] Bug 22440: New ILL requests table MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use kohaTable requesting the REST api instead of the old KohaTable Co-authored-by: Tomás Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Illrequest.pm | 14 +- Koha/Illrequestattributes.pm | 16 + Koha/Schema/Result/Illrequest.pm | 2 +- admin/columns_settings.yml | 17 +- api/v1/swagger/definitions/ill_request.yaml | 2 +- api/v1/swagger/paths/illrequests.yaml | 2 +- .../en/includes/ill-list-table-strings.inc | 18 +- .../prog/en/includes/ill-list-table.inc | 27 +- .../prog/en/includes/js-biblio-format.inc | 57 +- .../prog/en/modules/ill/ill-requests.tt | 113 ++- .../prog/en/modules/members/ill-requests.tt | 2 + koha-tmpl/intranet-tmpl/prog/js/datatables.js | 40 +- .../intranet-tmpl/prog/js/ill-list-table.js | 905 ++++++++---------- 13 files changed, 594 insertions(+), 621 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 227484d95c..8c58e7f7e7 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -24,6 +24,7 @@ use Try::Tiny qw( catch try ); use DateTime; use C4::Letters; +use Mojo::Util qw(deprecated); use Koha::Cache::Memory::Lite; use Koha::Database; @@ -177,6 +178,7 @@ sub statusalias { =cut sub illrequestattributes { + deprecated 'illrequestattributes is DEPRECATED in favor of extended_attributes'; my ( $self ) = @_; return Koha::Illrequestattributes->_new_from_dbic( scalar $self->_result->illrequestattributes @@ -247,20 +249,20 @@ sub library { return Koha::Library->_new_from_dbic( scalar $self->_result->library ); } -=head3 ill_extended_attributes +=head3 extended_attributes - my $ill_extended_attributes = $request->ill_extended_attributes; + my $extended_attributes = $request->extended_attributes; Returns the linked I resultset object. =cut -sub ill_extended_attributes { +sub extended_attributes { my ( $self ) = @_; - return Koha::Illrequestattributes->_new_from_dbic( - scalar $self->_result->ill_extended_attributes - ); + my $rs = $self->_result->extended_attributes; + # We call search to use the filters in Koha::Illrequestattributes->search + return Koha::Illrequestattributes->_new_from_dbic($rs)->search; } =head3 status_alias diff --git a/Koha/Illrequestattributes.pm b/Koha/Illrequestattributes.pm index 947ef0db22..fbf3409366 100644 --- a/Koha/Illrequestattributes.pm +++ b/Koha/Illrequestattributes.pm @@ -32,6 +32,22 @@ Koha::Illrequestattributes - Koha Illrequestattributes Object class =head2 Class Methods +=cut + +=head3 search + +my $attributes = Koha::Illrequestattributes->search( $params ); + +=cut + +sub search { + my ( $self, $params, $attributes ) = @_; + + unless ( exists $attributes->{order_by} ) { $attributes->{order_by} = ['me.type', 'value'] } + + return $self->SUPER::search( $params, $attributes ); +} + =head3 type =cut diff --git a/Koha/Schema/Result/Illrequest.pm b/Koha/Schema/Result/Illrequest.pm index 51dabbec12..5f1b0230dd 100644 --- a/Koha/Schema/Result/Illrequest.pm +++ b/Koha/Schema/Result/Illrequest.pm @@ -342,7 +342,7 @@ __PACKAGE__->has_many( ); __PACKAGE__->has_many( - "ill_extended_attributes", + "extended_attributes", "Koha::Schema::Result::Illrequestattribute", { "foreign.illrequest_id" => "self.illrequest_id" }, { cascade_copy => 0, cascade_delete => 0 }, diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 12091f3154..cdff0ea0bb 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -824,7 +824,7 @@ modules: ill-requests: columns: - - columnname: illrequest_id + columnname: ill_request_id - columnname: metadata_author - @@ -851,27 +851,12 @@ modules: columnname: library_branchname - columnname: status - - - columnname: placed - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: placed_formatted - - - columnname: updated - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: updated_formatted - columnname: replied - - - columnname: completed - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: completed_formatted - diff --git a/api/v1/swagger/definitions/ill_request.yaml b/api/v1/swagger/definitions/ill_request.yaml index 6178944755..7c668bdfb5 100644 --- a/api/v1/swagger/definitions/ill_request.yaml +++ b/api/v1/swagger/definitions/ill_request.yaml @@ -108,7 +108,7 @@ properties: - integer - "null" description: The linked comment objects count (x-koha-embed) - ill_extended_attributes: + extended_attributes: type: - array - "null" diff --git a/api/v1/swagger/paths/illrequests.yaml b/api/v1/swagger/paths/illrequests.yaml index bcee3d85a5..5e0d016998 100644 --- a/api/v1/swagger/paths/illrequests.yaml +++ b/api/v1/swagger/paths/illrequests.yaml @@ -27,7 +27,7 @@ - biblio - comments - comments+count - - ill_extended_attributes + - extended_attributes - library - id_prefix - patron diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc index 7734384155..f4327f40eb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc @@ -1,21 +1,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc index 755e6e550b..c0d75cc27b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc @@ -1,30 +1,23 @@ -[% IF prefilters.length > 0 %] - -[% ELSE %]
-[% END %] - + - - - - - - - - + + + + + + + + - - - @@ -38,4 +31,4 @@ -
Request IDAuthorTitleArticle titleIssueVolumeYearPagesRequest typeAuthorTitleArticle titleIssueVolumeYearPagesRequest type Order ID Patron Bibliographic record ID Library Status  Placed on  Updated on Replied  Completed on Access URL Cost
+ \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc index f953337856..c06002600f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc @@ -13,17 +13,24 @@ return ''; // empty string for no biblio } - var title = ''; - if (biblio.title != null && biblio.title != '') { - title += escape_str(biblio.title); - } else { - title += __("No title"); + var title = ''; + + if ( config && config.biblio_id_only ) { + title = escape_str(biblio.biblio_id); } - title += ''; + else { + title = ''; + if (biblio.title != null && biblio.title != '') { + title += escape_str(biblio.title); + } else { + title += __("No title"); + } + title += ''; - // add subtitle - if (biblio.subtitle != null && biblio.subtitle != '') { - title += ' ' + escape_str(biblio.subtitle) + ''; + // add subtitle + if (biblio.subtitle != null && biblio.subtitle != '') { + title += ' ' + escape_str(biblio.subtitle) + ''; + } } // set title as link @@ -39,23 +46,25 @@ } } - // add medium - if (biblio.medium != null && biblio.medium != '') { - title += ' ' + escape_str(biblio.medium) + ''; - } - - // add part numbers/names - let part_numbers = (typeof biblio.part_number === 'string') ? biblio.part_number.split("|") : []; - let part_names = (typeof biblio.part_name === 'string') ? biblio.part_name.split("|") : []; - let i = 0; - while (part_numbers[i] || part_names[i]) { - if (part_numbers[i]) { - title += ' ' + escape_str(part_numbers[i]) + ''; + if ( !config || !config.biblio_id_only ) { + // add medium + if (biblio.medium != null && biblio.medium != '') { + title += ' ' + escape_str(biblio.medium) + ''; } - if (part_names[i]) { - title += ' ' + escape_str(part_names[i]) + ''; + + // add part numbers/names + let part_numbers = (typeof biblio.part_number === 'string') ? biblio.part_number.split("|") : []; + let part_names = (typeof biblio.part_name === 'string') ? biblio.part_name.split("|") : []; + let i = 0; + while (part_numbers[i] || part_names[i]) { + if (part_numbers[i]) { + title += ' ' + escape_str(part_numbers[i]) + ''; + } + if (part_names[i]) { + title += ' ' + escape_str(part_names[i]) + ''; + } + i++; } - i++; } return title; 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 23c6c33f12..261fa61096 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 @@ -68,10 +68,15 @@ +
  • + + +
  • @@ -93,7 +98,8 @@
  • @@ -150,7 +156,7 @@ [% IF !whole.stage || whole.stage == 'form' %]

    Issue requested item to [% INCLUDE 'patron-title.inc' patron = request.patron %]

    [% IF !request.biblio_id || request.biblio_id.length == 0 %] -
    This item cannot be checked out out as there is no bibliographic record associated with it
    +
    This item cannot be issued as it has no biblio record associated with it
    [% END %] [% IF whole.value.errors.itemcount %]
    The bibliographic record for this request has multiple items, it should only have one. Please fix this then try again.
    @@ -599,15 +605,16 @@ Display supplier metadata - [% IF Koha.Preference('IllLog') %] - - - ILL request log - - [% END %] + + + ILL request log + -
    -

    Request details

    +
    +
    +

    Request details

    +
    +

    Details from library

      @@ -618,7 +625,7 @@
    1. Patron: [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %] - + [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
    2. @@ -664,7 +671,7 @@ [% IF request.price_paid %][% request.price_paid | $Price %][% ELSE %]N/A[% END %]
    3. - Request ID: + Request number: [% request.id_prefix _ request.illrequest_id | html %]
    4. @@ -672,7 +679,7 @@

      [% request.notesstaff | html %]

    5. - OPAC notes: + Notes:

      [% request.notesopac | html %]

    @@ -688,6 +695,7 @@ [% END %]
    +
    -
    -

    [% request.illcomments.count | html %] comments

    - [% IF request.illcomments.count && request.illcomments.count > 0 %] - [% FOREACH comment IN request.illcomments %] -
    -
    Comment by: - - [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %] - [% comment.timestamp | $KohaDates with_hours => 1 %]
    -

    [% comment.comment | html %]

    -
    +
    +
    +

    [% request.illcomments.count | html %] comments

    +
    +
    + [% IF request.illcomments.count && request.illcomments.count > 0 %] + [% FOREACH comment IN request.illcomments %] +
    +
    Comment by: + + [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %] + [% comment.timestamp | $KohaDates with_hours => 1 %]
    +

    [% comment.comment | html %]

    +
    + [% END %] [% END %] - [% END %] -
    -

    Add comment

    -
    -
    - - - -
    -
      -
    1. - - - Required -
    2. -
    -
    -
    - -
    -
    -
    +
    +

    Add comment

    +
    +
    + + + +
    +
      +
    1. + + + Required +
    2. +
    +
    +
    + +
    +
    +
    +
    @@ -780,12 +792,12 @@

    View ILL requests

    Details for all requests

    - [% INCLUDE 'ill-list-table.inc' %] + [% INCLUDE 'ill-list-table.inc' %]
    [% ELSIF query_type == 'availability' %]

    Availability

    -
    +

    Displaying availability results

    [% FOREACH key IN whole.keys %] @@ -830,6 +842,8 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'js-biblio-format.inc' %] + [% INCLUDE 'js-patron-format.inc' %] [% INCLUDE 'columns_settings.inc' %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'select2.inc' %] @@ -871,6 +885,7 @@ [% IF query_type == 'generic_confirm' && Koha.Preference('ILLCheckAvailability') %] [% Asset.js("js/ill-availability-partner.js") | $raw %] [% END %] + [% END %] [% TRY %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt index d3465cfaa2..4b7c30fb9e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt @@ -56,6 +56,8 @@ [% Asset.js("js/members-menu.js") | $raw %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] + [% INCLUDE 'js-biblio-format.inc' %] + [% INCLUDE 'js-patron-format.inc' %] [% INCLUDE 'calendar.inc' %]