Prechádzať zdrojové kódy

HUE-2018 [metastore] Add column position to table view

Adding js to jump to the particular column
Front end testing
Romain Rigaux 11 rokov pred
rodič
commit
38eea26

+ 3 - 1
apps/beeswax/src/beeswax/templates/execute.mako

@@ -370,7 +370,9 @@ ${layout.menubar(section='query')}
           <table class="table table-striped table-condensed" cellpadding="0" cellspacing="0">
             <tbody data-bind="foreach: $root.design.results.columns">
               <tr class="columnRow" data-bind="visible: $index() > 0">
-                <td rel="columntooltip" data-placement="left" data-bind="attr: {title: 'Scroll the column \'' + $data.name + '\''}"><a href="javascript:void(0)" data-row-selector="true" class="column-selector" data-bind="text: $data.name"></a></td>
+                <td rel="columntooltip" data-placement="left" data-bind="attr: {title: '${ _("Scroll to the column") }">
+                  <a href="javascript:void(0)" data-row-selector="true" class="column-selector" data-bind="text: $data.name"></a>
+                </td>
                 <td class="columnType" data-bind="text: $.trim($data.type)"></td>
               </tr>
             </tbody>

+ 23 - 2
apps/metastore/src/metastore/templates/describe_table.mako

@@ -34,6 +34,7 @@ ${ components.menubar() }
   <table class="table table-striped table-condensed datatables">
     <thead>
       <tr>
+        <th>&nbsp;</th>
         <th>${_('Name')}</th>
         <th>${_('Type')}</th>
         <th>${_('Comment')}</th>
@@ -42,7 +43,10 @@ ${ components.menubar() }
     <tbody>
       % for column in cols:
         <tr>
-          <td>${ column.name }</td>
+          <td>${ loop.index }</td>
+          <td title="${ _("Scroll to the column") }">
+            <a href="javascript:void(0)" data-row-selector="true" class="column-selector">${ column.name }</a>
+          </td>
           <td>${ column.type }</td>
           <td>${ column.comment != 'None' and column.comment or "" }</td>
         </tr>
@@ -208,7 +212,24 @@ ${ components.menubar() }
       "oLanguage": {
         "sEmptyTable": "${_('No data available')}",
         "sZeroRecords": "${_('No matching records')}",
-      }
+      },
+      "aoColumns": [
+        { "sWidth" : "10px" },
+        null,
+        null,
+        { "bSortable": false }
+      ],
+    });
+
+    $(".column-selector").on("click", function () {
+      var _t = $("#sample");
+      var _text = $.trim($(this).text().split("(")[0]);
+      var _col = _t.find("th").filter(function() {
+        return $.trim($(this).text()) == _text;
+      });
+      _t.find(".columnSelected").removeClass("columnSelected");
+      _t.find("tr td:nth-child(" + (_col.index() + 1) + ")").addClass("columnSelected");
+      $("a[href='#sample']").click();
     });
 
     % if has_write_access: