This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 4df0897  [ZEPPELIN-3814] visualization - Add apply button to table 
settings
4df0897 is described below

commit 4df0897e92574b8f96a06e4df27e93bacf035e92
Author: George Klimov <klim.electronicm...@gmail.com>
AuthorDate: Thu Dec 20 01:54:18 2018 +0300

    [ZEPPELIN-3814] visualization - Add apply button to table settings
    
    ### What is this PR for?
    Now changes in table settings applies only after page refreshing which 
isn't convenient
    * Settings menu before PR:
    
![screenshot-1](https://user-images.githubusercontent.com/6136993/47079792-f49b6580-d20e-11e8-837e-98ba5443f3b3.png)
    * Menu with new button:
    
![3814](https://user-images.githubusercontent.com/6136993/51320121-ecea9780-1a6f-11e9-850f-fcaf061ff5f3.gif)
    
    ### What type of PR is it?
    Improvement
    
    ### What is the Jira issue?
    * issue - https://issues.apache.org/jira/browse/ZEPPELIN-3814
    
    ### How should this be tested?
    * CI pass
    * Manually tested
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: George Klimov <klim.electronicm...@gmail.com>
    
    Closes #3205 from egorklimov/DW-17956 and squashes the following commits:
    
    ffcd55ccb [George Klimov] Fix icon
    7daec9278 [George Klimov] button added
---
 .../builtins/visualization-table-setting.html              |  8 +++++++-
 .../src/app/visualization/builtins/visualization-table.js  | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git 
a/zeppelin-web/src/app/visualization/builtins/visualization-table-setting.html 
b/zeppelin-web/src/app/visualization/builtins/visualization-table-setting.html
index d01fd1b..4dc49b3 100644
--- 
a/zeppelin-web/src/app/visualization/builtins/visualization-table-setting.html
+++ 
b/zeppelin-web/src/app/visualization/builtins/visualization-table-setting.html
@@ -17,8 +17,14 @@ limitations under the License.
     <span style="vertical-align: middle; display: inline-block; margin-top: 
3px;">Table Options</span>
     <span style="float: right;">
        <div class="btn-group" role="group" aria-label="...">
+         <div type="button" ng-click="applyTableOption()"
+                       uib-tooltip="Apply new setting" tooltip-placement="top"
+                       class="btn btn-default" style="font-size: 11px; 
padding: 2px 5px 2px 5px;">
+           <i class="fa fa-floppy-o" aria-hidden="true"></i>
+         </div>
+
          <div type="button" ng-click="resetTableOption()"
-              uib-tooltip="Restore the default setting" 
tooltip-placement="left"
+              uib-tooltip="Restore the default setting" tooltip-placement="top"
               class="btn btn-default" style="font-size: 11px; padding: 2px 5px 
2px 5px;">
            <i class="fa fa-undo" aria-hidden="true"></i>
          </div>
diff --git a/zeppelin-web/src/app/visualization/builtins/visualization-table.js 
b/zeppelin-web/src/app/visualization/builtins/visualization-table.js
index 4227258..270a694 100644
--- a/zeppelin-web/src/app/visualization/builtins/visualization-table.js
+++ b/zeppelin-web/src/app/visualization/builtins/visualization-table.js
@@ -66,6 +66,7 @@ export default class TableVisualization extends Visualization 
{
     this.passthrough = new PassthroughTransformation(config);
     this.emitTimeout = null;
     this.isRestoring = false;
+    this.isUpdated = false;
 
     initializeTableConfig(config, TABLE_OPTION_SPECS);
   }
@@ -382,7 +383,12 @@ export default class TableVisualization extends 
Visualization {
       // gridApi.selection.on.rowSelectionChangedBatch(scope, () => { 
self.persistConfigWithGridState(self.config) })
     };
 
-    if (!gridElem) {
+    if (!gridElem || this.isUpdated) {
+      if (this.isUpdated) {
+        this.targetEl.find(gridElem).off();
+        this.targetEl.find(gridElem).detach();
+        this.isUpdated = false;
+      }
       // create, compile and append grid elem
       gridElem = angular.element(
         `<div id="${gridElemId}" ui-grid="${gridElemId}"
@@ -511,6 +517,12 @@ export default class TableVisualization extends 
Visualization {
           initializeTableConfig(configObj, TABLE_OPTION_SPECS);
           self.persistConfigWithGridState(configObj);
         },
+        applyTableOption: () => {
+          this.isUpdated = true;
+          // emit config to re-render table
+          configObj.initialized = true;
+          self.persistConfig(configObj);
+        },
         tableWidgetOnKeyDown: (event, optSpec) => {
           const code = event.keyCode || event.which;
           if (code === 13 && isInputWidget(optSpec)) {

Reply via email to