diff --git a/webapp/core/src/main/public/static/js/find/app/page/search/results/sunburst-view.js b/webapp/core/src/main/public/static/js/find/app/page/search/results/sunburst-view.js index 7a395ce400..1507a7ba5b 100644 --- a/webapp/core/src/main/public/static/js/find/app/page/search/results/sunburst-view.js +++ b/webapp/core/src/main/public/static/js/find/app/page/search/results/sunburst-view.js @@ -121,25 +121,31 @@ define([ 'click .parametric-pptx': function(evt) { evt.preventDefault(); - var $form = $('
'); + var data = this.exportPPTData(); - var categories = []; - var values = []; + if (data) { + var $form = $('
'); + $form[0].data.value = JSON.stringify(data); + $form.appendTo(document.body).submit().remove(); + } + } + }, ParametricResultsView.prototype.events), - this.dependentParametricCollection.each(function(model){ - categories.push(model.get('text') || i18n['search.resultsView.sunburst.others']); - values.push(model.get('count')); - }); + exportPPTData: function(){ + var categories = []; + var values = []; + + this.dependentParametricCollection.each(function(model){ + categories.push(model.get('text') || i18n['search.resultsView.sunburst.others']); + values.push(model.get('count')); + }); - $form[0].data.value = JSON.stringify({ + return values.length && categories.length ? { categories: categories, values: values, title: i18n['search.resultsView.sunburst.breakdown.by'](this.fieldsCollection.at(0).get('displayValue')) - }); - - $form.appendTo(document.body).submit().remove(); - } - }, ParametricResultsView.prototype.events), + } : null + }, initialize: function(options) { ParametricResultsView.prototype.initialize.call(this, _.defaults({ diff --git a/webapp/core/src/main/public/static/js/find/app/page/search/results/table/table-view.js b/webapp/core/src/main/public/static/js/find/app/page/search/results/table/table-view.js index 0243474da1..d02645bccc 100644 --- a/webapp/core/src/main/public/static/js/find/app/page/search/results/table/table-view.js +++ b/webapp/core/src/main/public/static/js/find/app/page/search/results/table/table-view.js @@ -35,32 +35,38 @@ define([ 'click .parametric-pptx': function(evt) { evt.preventDefault(); - var $form = $('
'); - $form[0].title.value = i18n['search.resultsView.table.breakdown.by'](this.fieldsCollection.at(0).get('displayValue')); + var data = this.exportPPTData(); - var rows = this.$table.find('tr'), nCols = 0; + if (data) { + var $form = $('
'); + $form[0].title.value = i18n['search.resultsView.table.breakdown.by'](this.fieldsCollection.at(0).get('displayValue')); + $form[0].data.value = JSON.stringify(data); + $form.appendTo(document.body).submit().remove(); + } + }, - var cells = []; + }, ParametricResultsView.prototype.events), - rows.each(function(idx, el){ - var tds = $(el).find('th,td'); - nCols = tds.length; + exportPPTData: function(){ + var rows = this.$table.find('tr'), nCols = 0; - tds.each(function (idx, el) { - cells.push($(el).text()); - }) - }); + var cells = []; - $form[0].data.value = JSON.stringify({ - rows: rows.length, - cols: nCols, - cells: cells - }); + rows.each(function(idx, el){ + var tds = $(el).find('th,td'); + nCols = tds.length; - $form.appendTo(document.body).submit().remove(); - }, + tds.each(function (idx, el) { + cells.push($(el).text()); + }) + }); - }, ParametricResultsView.prototype.events), + return rows.length ? { + rows: rows.length, + cols: nCols, + cells: cells + } : null; + }, initialize: function(options) { ParametricResultsView.prototype.initialize.call(this, _.defaults({