Skip to content

Commit

Permalink
Support exportPPTData on the sunburst and table views to make it easi…
Browse files Browse the repository at this point in the history
…er to export their data into reports once they have widgets created for them.
  • Loading branch information
tung-jin-chew-hp committed Mar 8, 2017
1 parent 0dc3ddb commit ff82dde
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,31 @@ define([
'click .parametric-pptx': function(evt) {
evt.preventDefault();

var $form = $('<form class="hide" enctype="multipart/form-data" method="post" target="_blank" action="api/bi/export/ppt/sunburst"><textarea name="data"></textarea><input type="submit"></form>');
var data = this.exportPPTData();

var categories = [];
var values = [];
if (data) {
var $form = $('<form class="hide" enctype="multipart/form-data" method="post" target="_blank" action="api/bi/export/ppt/sunburst"><textarea name="data"></textarea><input type="submit"></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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,38 @@ define([
'click .parametric-pptx': function(evt) {
evt.preventDefault();

var $form = $('<form class="hide" enctype="multipart/form-data" method="post" target="_blank" action="api/bi/export/ppt/table"><input name="title"><textarea name="data"></textarea><input type="submit"></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 class="hide" enctype="multipart/form-data" method="post" target="_blank" action="api/bi/export/ppt/table"><input name="title"><textarea name="data"></textarea><input type="submit"></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({
Expand Down

0 comments on commit ff82dde

Please sign in to comment.