From f4f4538408358a3a4b4cb838b31d54b92a4b86c8 Mon Sep 17 00:00:00 2001 From: jbai Date: Wed, 31 Aug 2016 16:50:20 -0700 Subject: [PATCH] fix the issue that action getSchema did not fired --- web/app/views/index.scala.html | 2 +- .../javascripts/components/components.js | 30 +++++++++++++++++++ .../javascripts/components/schema-comment.js | 5 +++- web/public/javascripts/main.js | 5 ++++ web/public/javascripts/routers/datasets.js | 4 --- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/web/app/views/index.scala.html b/web/app/views/index.scala.html index 47dd7d8444..e72a99575d 100644 --- a/web/app/views/index.scala.html +++ b/web/app/views/index.scala.html @@ -321,7 +321,7 @@
- {{#schema-comment schema=schema datasetId=this.model.id fieldId=schema.id getSchema="getSchema"}}{{/schema-comment}} + {{#schema-comment schema=schema datasetId=dataset.id fieldId=schema.id}}{{/schema-comment}} {{schema.commentHtml}}
diff --git a/web/public/javascripts/components/components.js b/web/public/javascripts/components/components.js index b940e240f3..73d2c2d230 100644 --- a/web/public/javascripts/components/components.js +++ b/web/public/javascripts/components/components.js @@ -102,6 +102,36 @@ App.DatasetSchemaComponent = Ember.Component.extend({ }, 500); }, actions: { + getSchema: function(){ + var _this = this + var id = _this.get('dataset.id') + var columnUrl = 'api/v1/datasets/' + id + "/columns"; + _this.set("isTable", true); + _this.set("isJSON", false); + $.get(columnUrl, function(data) { + if (data && data.status == "ok") + { + if (data.columns && (data.columns.length > 0)) + { + _this.set("hasSchemas", true); + data.columns = data.columns.map(function(item, idx){ + item.commentHtml = marked(item.comment).htmlSafe() + return item + }) + _this.set("schemas", data.columns); + setTimeout(initializeColumnTreeGrid, 500); + } + else + { + _this.set("hasSchemas", false); + } + } + else + { + _this.set("hasSchemas", false); + } + }); + }, setView: function (view) { switch (view) { case "tabular": diff --git a/web/public/javascripts/components/schema-comment.js b/web/public/javascripts/components/schema-comment.js index 9835ee59b9..5c5b0c0a35 100644 --- a/web/public/javascripts/components/schema-comment.js +++ b/web/public/javascripts/components/schema-comment.js @@ -497,7 +497,10 @@ App.SchemaCommentComponent = Ember.Component.extend({ }) .on('hidden.bs.modal', function(){ _this.set('propModal', false) - _this.sendAction('getSchema') + if (_this.parentView && _this.parentView.controller) + { + _this.parentView.controller.send('getSchema') + } $("#datasetSchemaColumnCommentModal").modal('hide'); }) }, 300) diff --git a/web/public/javascripts/main.js b/web/public/javascripts/main.js index 3c89ba6fb0..7696084a35 100644 --- a/web/public/javascripts/main.js +++ b/web/public/javascripts/main.js @@ -339,3 +339,8 @@ function filterListView(category, filter) } } +function initializeColumnTreeGrid() +{ + $('#json-table').treegrid(); +} + diff --git a/web/public/javascripts/routers/datasets.js b/web/public/javascripts/routers/datasets.js index 4bb70f33c6..5ca2a9c633 100644 --- a/web/public/javascripts/routers/datasets.js +++ b/web/public/javascripts/routers/datasets.js @@ -1,7 +1,3 @@ -function initializeColumnTreeGrid() -{ - $('#json-table').treegrid(); -} function initializeDependsTreeGrid() {