You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mi...@apache.org on 2016/06/25 17:01:50 UTC
zeppelin git commit: [ZEPPELIN-954] Fix table cell selection problem
on second run by properly destroying hot.
Repository: zeppelin
Updated Branches:
refs/heads/master 330d1da31 -> e1b384722
[ZEPPELIN-954] Fix table cell selection problem on second run by properly destroying hot.
### What is this PR for?
* Fix table cell selection problem on second run by properly destroying hot.
* Also make cells readonly. Previously one were able to paste into them.
### What type of PR is it?
[Bug Fix]
### Todos
### What is the Jira issue?
* [ZEPPELIN-954]
### How should this be tested?
Execute the following paragraph multiple times, and verify the table cells are still selectable.
```
%sh
echo %table
echo -e "col1\tcol2\tcol3"
echo -e "1\t2.1\tabcdefg"
```
Also try to paste anything into a cell to no avail.
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Hao Xia <ha...@optimizely.com>
Closes #1059 from jasonxh/hao/hot-fix and squashes the following commits:
38d3ef4 [Hao Xia] Use the data argument consistently
1eb7fe4 [Hao Xia] Reuse the table when possible
5bd9502 [Hao Xia] Fix selection problem on second run by properly destroying hot. Also make cells readonly. Previously one were able to paste into them.
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e1b38472
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e1b38472
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e1b38472
Branch: refs/heads/master
Commit: e1b38472235dcb9ab82006757e8d9bb102b6609f
Parents: 330d1da
Author: Hao Xia <ha...@optimizely.com>
Authored: Thu Jun 23 11:19:38 2016 -0700
Committer: Mina Lee <mi...@apache.org>
Committed: Sat Jun 25 10:01:46 2016 -0700
----------------------------------------------------------------------
.../notebook/paragraph/paragraph.controller.js | 79 ++++++++++++--------
1 file changed, 46 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1b38472/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index 6ab63cd..398191c 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -1221,43 +1221,56 @@ angular.module('zeppelinWebApp')
websocketMsgSrv.commitParagraph($scope.paragraph.id, title, text, config, params);
};
- var setTable = function(type, data, refresh) {
+ var setTable = function(data, refresh) {
var renderTable = function() {
var height = $scope.paragraph.config.graph.height;
- angular.element('#p' + $scope.paragraph.id + '_table').css('height', height);
- var resultRows = $scope.paragraph.result.rows;
- var columnNames = _.pluck($scope.paragraph.result.columnNames, 'name');
- var container = document.getElementById('p' + $scope.paragraph.id + '_table');
+ var container = angular.element('#p' + $scope.paragraph.id + '_table').css('height', height).get(0);
+ var resultRows = data.rows;
+ var columnNames = _.pluck(data.columnNames, 'name');
+
+ // on chart type change, destroy table to force reinitialization.
+ if ($scope.hot && !refresh) {
+ $scope.hot.destroy();
+ $scope.hot = null;
+ }
+
+ // create table if not exists.
+ if (!$scope.hot) {
+ $scope.hot = new Handsontable(container, {
+ rowHeaders: false,
+ stretchH: 'all',
+ sortIndicator: true,
+ columnSorting: true,
+ contextMenu: false,
+ manualColumnResize: true,
+ manualRowResize: true,
+ readOnly: true,
+ readOnlyCellClassName: '', // don't apply any special class so we can retain current styling
+ fillHandle: false,
+ fragmentSelection: true,
+ disableVisualSelection: true,
+ cells: function (row, col, prop) {
+ var cellProperties = {};
+ cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) {
+ if (!isNaN(value)) {
+ cellProperties.format = '0,0.[00000]';
+ td.style.textAlign = 'left';
+ Handsontable.renderers.NumericRenderer.apply(this, arguments);
+ } else if (value.length > '%html'.length && '%html ' === value.substring(0, '%html '.length)) {
+ td.innerHTML = value.substring('%html'.length);
+ } else {
+ Handsontable.renderers.TextRenderer.apply(this, arguments);
+ }
+ };
+ return cellProperties;
+ }
+ });
+ }
- var handsontable = new Handsontable(container, {
- data: resultRows,
+ // load data into table.
+ $scope.hot.updateSettings({
colHeaders: columnNames,
- rowHeaders: false,
- stretchH: 'all',
- sortIndicator: true,
- columnSorting: true,
- contextMenu: false,
- manualColumnResize: true,
- manualRowResize: true,
- editor: false,
- fillHandle: false,
- fragmentSelection: true,
- disableVisualSelection: true,
- cells: function (row, col, prop) {
- var cellProperties = {};
- cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) {
- if (!isNaN(value)) {
- cellProperties.format = '0,0.[00000]';
- td.style.textAlign = 'left';
- Handsontable.renderers.NumericRenderer.apply(this, arguments);
- } else if (value.length > '%html'.length && '%html ' === value.substring(0, '%html '.length)) {
- td.innerHTML = value.substring('%html'.length);
- } else {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- }
- };
- return cellProperties;
- }
+ data: resultRows
});
};