From 491269b402a4894eaf17a1ff66046636e44c31bc Mon Sep 17 00:00:00 2001
From: Cam Saul <cam@geotip.com>
Date: Tue, 26 May 2015 20:17:37 -0700
Subject: [PATCH] :smiling_imp: Show empty tables in explore

---
 .../app/explore/partials/database_list.html              | 9 +++++++--
 src/metabase/api/meta/table.clj                          | 7 ++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/resources/frontend_client/app/explore/partials/database_list.html b/resources/frontend_client/app/explore/partials/database_list.html
index 18e59b00da6..64364e397ed 100644
--- a/resources/frontend_client/app/explore/partials/database_list.html
+++ b/resources/frontend_client/app/explore/partials/database_list.html
@@ -21,11 +21,16 @@
                 <div class="col col-sm-12 mt4" ng-if="show_non_entities[dbId]">
                     <h5 class="text-bold mb2" ng-if="database.entities.length > 0">Other tables</h5>
                     <ul>
-                        <li class="border-bottom py1" ng-repeat="table in database.non_entities" ng-if="table.rows > 0">
+                        <li class="border-bottom py1" ng-repeat="table in database.non_entities">
                             <div class="clearfix">
                                 <span class="float-right text-grey-3 mt1">{{table.rows}} rows</span>
                                 <h4 class="text-normal inline-block">
-                                    <a class="link" cv-org-href="/explore/table/{{table.id}}">{{table.name}}</a>
+                                    <a ng-if="table.rows > 0" class="link" cv-org-href="/explore/table/{{table.id}}">
+                                        {{table.name}}
+                                    </a>
+                                    <span ng-if="table.rows === 0">
+                                        {{table.name}}
+                                    </span>
                                 </h4>
                             </div>
                             <p class="text-grey-3 m0 pb1" ng-if="table.description">{{table.description}}</p>
diff --git a/src/metabase/api/meta/table.clj b/src/metabase/api/meta/table.clj
index 8bf3494f183..da25dcc0c95 100644
--- a/src/metabase/api/meta/table.clj
+++ b/src/metabase/api/meta/table.clj
@@ -24,7 +24,12 @@
   (read-check Org org)
   (let [db-ids (sel :many :id Database :organization_id org)]
     (-> (sel :many Table :active true :db_id [in db-ids] (order :name :ASC))
-        (hydrate :db))))
+        (hydrate :db)
+        ;; if for some reason a Table doesn't have rows set then set it to 0 so UI doesn't barf
+        (#(map (fn [{:keys [rows] :as table}]
+                 (cond-> table
+                   (not rows) (assoc :rows 0)))
+               %)))))
 
 
 (defendpoint GET "/:id"
-- 
GitLab