Skip to content

Commit

Permalink
Fixing the bug where filters don't apply on load
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 15, 2016
1 parent 69a385b commit 02e519a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
47 changes: 24 additions & 23 deletions panoramix/static/panoramix.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ var px = (function() {
function registerViz(name, initViz) {
visualizations[name] = initViz;
}
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++;
});
}
function druidify(){
prepForm();
$('div.alert').remove();
history.pushState({}, document.title, slice.querystring());
slice.render();
}

function initExploreView() {

Expand Down Expand Up @@ -268,23 +291,6 @@ var px = (function() {
$(this).parent().parent().remove();
});
}
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++;
});
}
$(window).bind("popstate", function(event) {
// Browser back button
var returnLocation = history.location || document.location;
Expand All @@ -293,12 +299,6 @@ var px = (function() {
returnLocation.reload();
});

function druidify(){
prepForm();
$('div.alert').remove();
history.pushState({}, document.title, slice.querystring());
slice.render();
}

$("#plus").click(add_filter);
$("#btn_save").click(function () {
Expand Down Expand Up @@ -422,6 +422,7 @@ var px = (function() {
registerViz: registerViz,
Slice: Slice,
Dashboard: Dashboard,
druidify: druidify,
initExploreView: initExploreView,
initDashboardView: initDashboardView,
}
Expand Down
3 changes: 2 additions & 1 deletion panoramix/templates/panoramix/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ <h4 class="modal-title">Datasource Description</h4>
<script>
$(document).ready(px.initExploreView);
$(document).ready(function() {
console.log(px);
var data = $('.slice').data('slice');
var slice = px.Slice(data);
$('.slice').data('slice', slice);
slice.render();
px.druidify();
});
$(':checkbox')
.addClass('pull-right')
Expand Down

0 comments on commit 02e519a

Please sign in to comment.