From 7ea45e80b5ebde631d6288ebcb4dca93d615f42b Mon Sep 17 00:00:00 2001
From: "Mark M. Florida" <markflorida@wustl.edu>
Date: Tue, 19 Jul 2016 13:15:25 -0500
Subject: [PATCH] XNAT-4421, XNAT-4422: tabs without groups now render
 properly; table rows are now properly appended to an existing table.

---
 src/main/webapp/scripts/xnat/ui/table.js | 15 +++++++++++----
 src/main/webapp/scripts/xnat/ui/tabs.js  |  3 ++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/main/webapp/scripts/xnat/ui/table.js b/src/main/webapp/scripts/xnat/ui/table.js
index e7070fc6..9bf87dc3 100755
--- a/src/main/webapp/scripts/xnat/ui/table.js
+++ b/src/main/webapp/scripts/xnat/ui/table.js
@@ -123,6 +123,7 @@ var XNAT = getObject(XNAT);
         var th = element('th', opts, content);
         this.last.th = th;
         this.last.tr.appendChild(th);
+        this._cols++; // do this here?
         return this;
     };
 
@@ -133,8 +134,8 @@ var XNAT = getObject(XNAT);
         if (data) {
             this.last.tr = tr;
             [].concat(data).forEach(function(item, i){
-                if (_this._cols && _this._cols > i) return;
-                _this.td(item)._cols++;
+                //if (_this._cols && _this._cols > i) return;
+                _this.td(item);
             });
         }
         // only add <tr> elements to <table>, <thead>, <tbody>, and <tfoot>
@@ -417,8 +418,14 @@ var XNAT = getObject(XNAT);
                 url: XNAT.url.rootUrl(opts.load||opts.url),
                 dataType: opts.dataType || 'json',
                 success: function(json){
-                    // handle data returned in ResultSet.Result array
-                    json = (json.ResultSet && json.ResultSet.Result) ? json.ResultSet.Result : json;
+                    // support custom path for returned data
+                    if (opts.path) {
+                        json = lookupObjectValue(json, opts.path);
+                    }
+                    else {
+                        // handle data returned in ResultSet.Result array
+                        json = (json.ResultSet && json.ResultSet.Result) ? json.ResultSet.Result : json;
+                    }
                     createTable(json);
                 }
             });
diff --git a/src/main/webapp/scripts/xnat/ui/tabs.js b/src/main/webapp/scripts/xnat/ui/tabs.js
index 0f6c65a7..9ef237c5 100755
--- a/src/main/webapp/scripts/xnat/ui/tabs.js
+++ b/src/main/webapp/scripts/xnat/ui/tabs.js
@@ -137,7 +137,7 @@ var XNAT = getObject(XNAT || {});
             $group = $('#' + groupId + '.tab-group');
         }
         else {
-            $group = $$(tabs.navTabs).find('ul.tab-group')
+            $group = $$(tabs.navTabs).find('ul.tab-group').first();
         }
 
         // add all the flippers
@@ -201,6 +201,7 @@ var XNAT = getObject(XNAT || {});
             $(navTabs).append(tab.groups(obj.meta.tabGroups));
         }
         else {
+            tabs.hasGroups = false;
             $(navTabs).spawn('ul.tab-group');
         }
 
-- 
GitLab