From 918166be5e75e2ab3dd1d0764c2be2f3075edfb1 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Tue, 15 May 2012 09:56:27 -0400
Subject: [PATCH] TPAC added content shows default tab

Use the first available content as the default tab to show when the main
added content tab is expanded.

Note, if no content is known to exist until after JS has run, it's still
possible to expand the main tab and have no content selected by default.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---
 Open-ILS/src/templates/opac/parts/record/extras.tt2 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Open-ILS/src/templates/opac/parts/record/extras.tt2 b/Open-ILS/src/templates/opac/parts/record/extras.tt2
index d02efb08a4..7b5c378e0e 100644
--- a/Open-ILS/src/templates/opac/parts/record/extras.tt2
+++ b/Open-ILS/src/templates/opac/parts/record/extras.tt2
@@ -19,12 +19,16 @@
             END;
         END;
 
-        # if no added content is available, hide the main tab
+        # 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;
-                SET hide_ac = 0 IF 
-                    ctx.added_content.$type.status != '2'; # not available
+                IF ctx.added_content.$type.status != '2'; # not available
+                    hide_ac = 0;
+                    SET default_ac = type UNLESS default_ac;
+                END;
             END;
         END;
 
@@ -53,7 +57,11 @@
                         href = mkurl('', {}, ['expand', 'ac']);
                         img_url = ctx.media_prefix _ '/images/rdetail_arrow_down.png';
                     ELSE;
-                        href = mkurl('', {expand => name}) _ '#' _ name; 
+                        IF name == 'addedcontent' AND default_ac;
+                            href = mkurl('', {expand => name, ac => default_ac}) _ '#' _ name; 
+                        ELSE;
+                            href = mkurl('', {expand => name}) _ '#' _ name; 
+                        END;
                         img_url = ctx.media_prefix _ '/images/rdetail_arrow.png';
                     END;
                 %]
-- 
2.11.0