Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dashboard filters carrying over to explore slice #3461

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions superset/assets/javascripts/dashboard/components/SliceCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function SliceCell({ expandedSlices, removeSlice, slice }) {
<span>{slice.slice_name}</span>
</div>
<div className="col-md-12 chart-controls">
<div className="pull-right">
<div id={'controls_' + slice.slice_id} className="pull-right">
<a title="Move chart" data-toggle="tooltip">
<i className="fa fa-arrows drag" />
</a>
Expand All @@ -42,10 +42,20 @@ function SliceCell({ expandedSlices, removeSlice, slice }) {
>
<i className="fa fa-pencil" />
</a>
<a href={getExploreUrl(slice.form_data, 'csv')} title="Export CSV" data-toggle="tooltip">
<a
className="exportCSV"
href={getExploreUrl(slice.form_data, 'csv')}
title="Export CSV"
data-toggle="tooltip"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these lines the same as in master, but formatted differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

className was added, and eslint wants the code formatted this way when having it on one line would exceed 100 characters

<i className="fa fa-table" />
</a>
<a href={getExploreUrl(slice.form_data)} title="Explore chart" data-toggle="tooltip">
<a
className="exploreChart"
href={getExploreUrl(slice.form_data)}
title="Explore chart"
data-toggle="tooltip"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

<i className="fa fa-share" />
</a>
<a
Expand Down
21 changes: 11 additions & 10 deletions superset/assets/javascripts/modules/superset.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const px = function (state) {
}
const Slice = function (data, datasource, controller) {
const token = $('#token_' + data.slice_id);
const controls = $('#controls_' + data.slice_id);
const containerId = 'con_' + data.slice_id;
const selector = '#' + containerId;
const container = $(selector);
Expand All @@ -80,16 +81,11 @@ const px = function (state) {
};
return Mustache.render(s, context);
},
jsonEndpoint() {
return this.endpoint('json');
jsonEndpoint(data) {
return this.endpoint(data, 'json');
},
endpoint(endpointType = 'json') {
const formDataExtra = Object.assign({}, formData);
const flts = controller.effectiveExtraFilters(sliceId);
if (flts) {
formDataExtra.extra_filters = flts;
}
let endpoint = getExploreUrl(formDataExtra, endpointType, this.force);
endpoint(data, endpointType = 'json') {
let endpoint = getExploreUrl(data, endpointType, this.force);
if (endpoint.charAt(0) !== '/') {
// Known issue for IE <= 11:
// https://connect.microsoft.com/IE/feedbackdetail/view/1002846/pathname-incorrect-for-out-of-document-elements
Expand Down Expand Up @@ -207,11 +203,16 @@ const px = function (state) {
} else {
this.force = force;
}
const formDataExtra = Object.assign({}, formData);
const extraFilters = controller.effectiveExtraFilters(sliceId);
formDataExtra.filters = formDataExtra.filters.concat(extraFilters);
controls.find('a.exploreChart').attr('href', getExploreUrl(formDataExtra));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not look a very react-ish way to handle this, shouldn't the component that renders the link should take formDataExtra and render again when it changes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xrmx eventually this whole module will get refactored out as we write a 100% React dashboard app (currently we have a lot of non-react JS in that app...), this is ok as is for now. We'll have to nuke all the jQuery code out of there in the future...

controls.find('a.exportCSV').attr('href', getExploreUrl(formDataExtra, 'csv'));
token.find('img.loading').show();
container.fadeTo(0.5, 0.25);
container.css('height', this.height());
$.ajax({
url: this.jsonEndpoint(),
url: this.jsonEndpoint(formDataExtra),
timeout: timeout * 1000,
success: (queryResponse) => {
try {
Expand Down