TPAC: Hide Awards and Added Content always
authorDan Scott <dscott@laurentian.ca>
Thu, 9 May 2013 16:58:17 +0000 (12:58 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 9 May 2013 17:01:02 +0000 (13:01 -0400)
Awards can only ever be displayed if you have Novelist or Chilifresh
patron reviews activated, but are currently always displayed. Which is
annoying. A better approach would be to display this only if you have
Novelist or Chilifresh activated, but as we at Conifer do not have these
across the board, always hide the tab.

Similarly, the added content tab appears to generate plenty of false
positives, so just hide it for now rather than irritate people.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/templates_conifer/opac/parts/record/extras.tt2 [new file with mode: 0644]

diff --git a/Open-ILS/src/templates_conifer/opac/parts/record/extras.tt2 b/Open-ILS/src/templates_conifer/opac/parts/record/extras.tt2
new file mode 100644 (file)
index 0000000..185a414
--- /dev/null
@@ -0,0 +1,105 @@
+[%
+    arrow_img = ctx.media_prefix _ '/images/rdetail_arrow.png';
+    arrow_down_img = ctx.media_prefix _ '/images/rdetail_arrow_down.png';
+%]
+<div>
+    <div id='rdetail_extras_div' style='width: 100%;'> 
+        [%
+            IF ctx.google_books_preview;
+                label = l('Google Preview');
+                name = 'google_preview';
+                href = 'javascript:GBDisplayPreview();';
+        %]
+        <div id="gbp_extra" class="rdetail_extras hide_me">
+            <div class="rdetail_extras_hr"></div>
+            <div id="gbp_extra_links" class="rdetail_extras_link">
+                <a id='gbp_arrow_link' name='[% name %]' href='[% href %]'><img alt='[% label %]' src='[% arrow_img %]'/></a>
+                <a id='gbp_arrow_down_link' name='[% name %]' href='[% href %]' class='hide_me'><img alt='[% label %]' src='[% arrow_down_img %]'/></a>
+                <a name='[% name %]_lbl' href='[% href %]' class="rdetail_extras_lbl">[% label %]</a></div>
+        </div>
+        <div id="gbp_extra_container" class='rdetail_extras_div'></div>
+        [%  END %]
+
+        [%  # Hidden extras are not yet implemented.  Some may require JS
+
+        MACRO tab_is_active(tab) BLOCK;
+            exp_name = 'expand_' _ tab;
+            IF ctx.$exp_name OR ctx.expand_all; 1; END;
+        END;
+
+        # Let's see if we should hide the content cafe / simple summary content
+        hide_summary = 1;
+        IF attrs.summaries.0; hide_summary = 0; ELSE;
+            # Expose content cafe if it's reasonable to do so.
+            # This approach only works when using embedded content cafe.
+            IF ENV.OILS_CONTENT_CAFE_USER; 
+                ident = attrs.isbn_clean || attrs.upc; 
+                IF ident; hide_summary = 0; END;
+            END;
+        END;
+
+        # if no added content is available, hide the main tab.
+        # if any content is available, use the first tab as the default display tab.
+        default_ac = '';
+        IF !tab_is_active('addedcontent');
+            hide_ac = 1;
+            FOR type IN ctx.added_content.keys;
+                IF ctx.added_content.$type.status != '2'; # not available
+                    hide_ac = 0;
+                END;
+                IF ctx.added_content.$type.status == '1';
+                    SET default_ac = type UNLESS default_ac;
+                END;
+            END;
+        END;
+
+        extras = [
+            {name => 'summaryplus',  label => l('Summaries &amp; More'), hide => hide_summary}, 
+            {name => 'annotation', label => l('Annotation'), hide => 1}, 
+            {name => 'awards',  label => l('Awards, Reviews, & Suggested Reads'), hide => 1},
+            {name => 'excerpt',  label => l('Excerpt'), hide => 1},
+            {name => 'issues',   label => l('Issues Held'), hide => !(ctx.have_holdings_to_show || ctx.have_mfhd_to_show)},
+            {name => 'preview',  label => l('Preview'), hide => 1}, 
+            {name => 'addedcontent',  label => l('Additional Content'), hide => 1},  # hide if all content is known to not exist
+            {name => 'cnbrowse', label => l('Shelf Browser')},
+            {name => 'marchtml', label => l('MARC Record')}
+        ];
+
+        FOREACH extra IN extras;
+            IF extra.hide; NEXT; END; 
+            name = extra.name;
+        %]
+        <div class="rdetail_extras">
+            <div class="rdetail_extras_hr"></div>
+            <div class="rdetail_extras_link">
+                [%  
+                    IF tab_is_active(name);
+                        href = mkurl('', {}, ['expand', 'ac']);
+                        img_url = arrow_down_img;
+                    ELSE;
+                        IF name == 'addedcontent' AND default_ac;
+                            href = mkurl('', {expand => name, ac => default_ac}) _ '#' _ name; 
+                        ELSE;
+                            href = mkurl('', {expand => name}) _ '#' _ name; 
+                        END;
+                        img_url = arrow_img;
+                    END;
+                %]
+                <a name='[% name %]' href='[% href %]'><img alt='[% extra.label %]' src='[% img_url %]'/></a>
+                <a name='[% name %]_lbl' href='[% href %]' class="rdetail_extras_lbl">[% extra.label %]</a>
+            </div>
+        </div>
+        <div class='rdetail_extras_div'>
+            [%  IF tab_is_active(name);
+                    IF name == 'marchtml';
+                        ctx.marchtml;
+                    ELSE;
+                        # Load the template for the selected extra
+                        INCLUDE "opac/parts/record/${name}.tt2";
+                    END;
+                END; 
+            %]
+        </div>
+        [% END %]
+    </div>
+</div>