From fc990504b20269b189d3674fde521c4b06a70b9e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 29 Oct 2019 12:00:25 -0400 Subject: [PATCH] LP1849137 Catalog Patron View embedding improvements Adds a readonly record detail view to the OPAC. This is used by the Angular catalog Patron View tab to present a version of the OPAC where all links, buttons, and inputs are disabled. Dynamically style the height of the embedded iframe to prevent nested scroll bars in the Patron View. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../src/app/staff/catalog/record/opac.component.html | 3 ++- .../src/app/staff/catalog/record/opac.component.ts | 17 ++++++++++++++--- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 1 + Open-ILS/src/templates/opac/parts/js.tt2 | 19 ++++++++++++++++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.html index 119b888579..8a67300789 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.html @@ -1,5 +1,6 @@ - + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.ts index 22eee58728..4a5bd036fa 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.ts @@ -1,4 +1,4 @@ -import {Component, Input} from '@angular/core'; +import {Component, Input, Renderer2} from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; const OPAC_BASE_URL = '/eg/opac/record'; @@ -18,7 +18,7 @@ export class OpacViewComponent { if (id && (id + '').match(/^\d+$/)) { this._recordId = id; this.url = this.sanitizer.bypassSecurityTrustResourceUrl( - `${OPAC_BASE_URL}/${id}`); + `${OPAC_BASE_URL}/${id}?readonly=1`); } else { this._recordId = null; this.url = null; @@ -29,6 +29,17 @@ export class OpacViewComponent { return this._recordId; } - constructor(private sanitizer: DomSanitizer) {} + constructor( + private sanitizer: DomSanitizer, + private renderer: Renderer2) {} + + handleLoad() { + const iframe = this.renderer.selectRootElement('#opac-iframe'); + + // 50 extra px adds enough space to avoid the scrollbar altogether + const height = 50 + iframe.contentWindow.document.body.offsetHeight; + + iframe.style.height = `${height}px`; + } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index c071c2452b..bc3972bac8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -18,6 +18,7 @@ sub load_record { my %kwargs = @_; my $ctx = $self->ctx; $ctx->{page} = 'record'; + $ctx->{readonly} = $self->cgi->param('readonly'); $self->timelog("load_record() began"); diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2 index 74a9bd49cf..28b043d4ef 100644 --- a/Open-ILS/src/templates/opac/parts/js.tt2 +++ b/Open-ILS/src/templates/opac/parts/js.tt2 @@ -2,10 +2,27 @@ [% INCLUDE "opac/i18n_strings.tt2" %] -[% IF ctx.want_jquery %] +[% IF ctx.want_jquery || ctx.readonly %] [% END; # ctx.want_jquery %] +[% IF ctx.readonly %] + +[% END %] +