mirror of
https://github.com/apache/superset.git
synced 2026-04-24 02:25:13 +00:00
committed by
Maxime Beauchemin
parent
13095eb550
commit
485234bc78
@@ -23,35 +23,35 @@ require('../node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css');
|
||||
|
||||
var slice;
|
||||
|
||||
var getPanelClass = function (fieldPrefix) {
|
||||
return (fieldPrefix === "flt" ? "filter" : "having") + "_panel";
|
||||
};
|
||||
|
||||
function prepForm() {
|
||||
var i = 1;
|
||||
// Assigning the right id to form elements in filters
|
||||
$("#filters > div").each(function () {
|
||||
$(this).attr("id", function () {
|
||||
return "flt_" + i;
|
||||
});
|
||||
$(this).find("#flt_col_0")
|
||||
.attr("id", function () {
|
||||
return "flt_col_" + i;
|
||||
})
|
||||
.attr("name", function () {
|
||||
return "flt_col_" + i;
|
||||
});
|
||||
$(this).find("#flt_op_0")
|
||||
.attr("id", function () {
|
||||
return "flt_op_" + i;
|
||||
})
|
||||
.attr("name", function () {
|
||||
return "flt_op_" + i;
|
||||
});
|
||||
$(this).find("#flt_eq_0")
|
||||
.attr("id", function () {
|
||||
return "flt_eq_" + i;
|
||||
})
|
||||
.attr("name", function () {
|
||||
return "flt_eq_" + i;
|
||||
});
|
||||
i++;
|
||||
var fixId = function ($filter, fieldPrefix, i) {
|
||||
$filter.attr("id", function () {
|
||||
return fieldPrefix + "_" + i;
|
||||
});
|
||||
|
||||
["col", "op", "eq"].forEach(function (fieldMiddle) {
|
||||
var fieldName = fieldPrefix + "_" + fieldMiddle;
|
||||
$filter.find("#" + fieldName + "_0")
|
||||
.attr("id", function () {
|
||||
return fieldName + "_" + i;
|
||||
})
|
||||
.attr("name", function () {
|
||||
return fieldName + "_" + i;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
["flt", "having"].forEach(function (fieldPrefix) {
|
||||
var i = 1;
|
||||
$("#" + getPanelClass(fieldPrefix) + " #filters > div").each(function () {
|
||||
fixId($(this), fieldPrefix, i);
|
||||
i++;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@ function query(force, pushState) {
|
||||
if (force === undefined) {
|
||||
force = false;
|
||||
}
|
||||
if (pushState !== false) {
|
||||
history.pushState({}, document.title, slice.querystring());
|
||||
}
|
||||
$('.query-and-save button').attr('disabled', 'disabled');
|
||||
$('.btn-group.results span,a').attr('disabled', 'disabled');
|
||||
if (force) { // Don't hide the alert message when the page is just loaded
|
||||
@@ -69,6 +66,10 @@ function query(force, pushState) {
|
||||
}
|
||||
$('#is_cached').hide();
|
||||
prepForm();
|
||||
if (pushState !== false) {
|
||||
// update the url after prepForm() fix the field ids
|
||||
history.pushState({}, document.title, slice.querystring());
|
||||
}
|
||||
slice.render(force);
|
||||
}
|
||||
|
||||
@@ -291,24 +292,26 @@ function initExploreView() {
|
||||
$(".ui-helper-hidden-accessible").remove(); // jQuery-ui 1.11+ creates a div for every tooltip
|
||||
|
||||
function set_filters() {
|
||||
for (var i = 1; i < 10; i++) {
|
||||
var eq = px.getParam("flt_eq_" + i);
|
||||
var col = px.getParam("flt_col_" + i);
|
||||
if (eq !== '' && col !== '') {
|
||||
add_filter(i);
|
||||
["flt", "having"].forEach(function (prefix) {
|
||||
for (var i = 1; i < 10; i++) {
|
||||
var eq = px.getParam(prefix + "_eq_" + i);
|
||||
var col = px.getParam(prefix + "_col_" + i);
|
||||
if (eq !== '' && col !== '') {
|
||||
add_filter(i, prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
set_filters();
|
||||
|
||||
function add_filter(i) {
|
||||
var cp = $("#flt0").clone();
|
||||
$(cp).appendTo("#filters");
|
||||
function add_filter(i, fieldPrefix) {
|
||||
var cp = $("#"+fieldPrefix+"0").clone();
|
||||
$(cp).appendTo("#" + getPanelClass(fieldPrefix) + " #filters");
|
||||
$(cp).show();
|
||||
if (i !== undefined) {
|
||||
$(cp).find("#flt_eq_0").val(px.getParam("flt_eq_" + i));
|
||||
$(cp).find("#flt_op_0").val(px.getParam("flt_op_" + i));
|
||||
$(cp).find("#flt_col_0").val(px.getParam("flt_col_" + i));
|
||||
$(cp).find("#"+fieldPrefix+"_eq_0").val(px.getParam(fieldPrefix+"_eq_" + i));
|
||||
$(cp).find("#"+fieldPrefix+"_op_0").val(px.getParam(fieldPrefix+"_op_" + i));
|
||||
$(cp).find("#"+fieldPrefix+"_col_0").val(px.getParam(fieldPrefix+"_col_" + i));
|
||||
}
|
||||
$(cp).find('select').select2();
|
||||
$(cp).find('.remove').click(function () {
|
||||
@@ -324,7 +327,12 @@ function initExploreView() {
|
||||
returnLocation.reload();
|
||||
});
|
||||
|
||||
$("#plus").click(add_filter);
|
||||
$("#filter_panel #plus").click(function () {
|
||||
add_filter(undefined, "flt");
|
||||
});
|
||||
$("#having_panel #plus").click(function () {
|
||||
add_filter(undefined, "having");
|
||||
});
|
||||
$("#btn_save").click(function () {
|
||||
var slice_name = prompt("Name your slice!");
|
||||
if (slice_name !== "" && slice_name !== null) {
|
||||
|
||||
Reference in New Issue
Block a user