aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-02-09 15:55:24 +0000
committerMichael Wood <michael.g.wood@intel.com>2015-02-09 15:59:10 +0000
commit5150b3516fd3edd9fd16621f580e761b9329653b (patch)
tree24a594db7bdac195751b49e6bcc44a5921f22847
parent01d6d6d7fbe39bbdc96c74bb6ee16824ac51ce21 (diff)
downloaderror-report-web-5150b3516fd3edd9fd16621f580e761b9329653b.tar.gz
error-report-web-5150b3516fd3edd9fd16621f580e761b9329653b.tar.bz2
error-report-web-5150b3516fd3edd9fd16621f580e761b9329653b.zip
main: Make sure we remove a filters/order_by on hide of that column
If you're hiding a column which as a filter by or order by set on it we need to revert this order/filter so that you don't have to re-add the column to get rid of the filter/order. Signed-off-by: Michael Wood <michael.g.wood@intel.com>
-rw-r--r--Post/static/js/main.js38
-rw-r--r--templates/latest-errors.html2
2 files changed, 32 insertions, 8 deletions
diff --git a/Post/static/js/main.js b/Post/static/js/main.js
index 8aee78b..3eca147 100644
--- a/Post/static/js/main.js
+++ b/Post/static/js/main.js
@@ -94,21 +94,45 @@ $(document).ready(function(){
/* Toggle a column */
$(".col-toggle").change(function(){
+ var updateSearch = false;
+ var field = $(this).data('field');
+ var col = $(this).val();
+ var search;
+
+ if ($(this).prop("checked")) {
+ $("."+col).show();
+ } else {
+ $("."+col).hide();
+
+ /* If we're hiding a column which has an order_by or a filter applied
+ * then remove these parameters.
+ */
+
+ search = parseUrlParams();
+
+ if (search.hasOwnProperty('type') && search.type.search(col) != -1){
+ delete search.type;
+ delete search.filter;
+ updateSearch = true;
+ }
- if ($(this).prop("checked")){
- console.log("."+$(this).val());
- $("."+$(this).val()).show();
- } else {
- $("."+$(this).val()).hide();
+ if (search.hasOwnProperty('order_by') &&
+ search.order_by.search(field) != -1){
+ delete search.order_by;
+ updateSearch = true;
+ }
}
var disabled_cols = [];
/* Update the cookie */
- $("th").not(":visible").map(function(){
- disabled_cols.push($(this).prop("class"));
+ $(".col-toggle").not(":checked").map(function(){
+ disabled_cols.push($(this).val());
});
$.cookie("cols", disabled_cols);
+
+ if (updateSearch)
+ window.location.search = dumpsUrlParams(search);
});
/* Display or hide table columns before showing the table */
diff --git a/templates/latest-errors.html b/templates/latest-errors.html
index d8457bb..3934b9d 100644
--- a/templates/latest-errors.html
+++ b/templates/latest-errors.html
@@ -43,7 +43,7 @@
<li>
{# Some columns are required as minimum so disable unchecking #}
<label class="checkbox {%if col.disable_toggle%}muted{%endif%}">
- <input type="checkbox" class="col-toggle" id="checkbox-{{col.clclass}}" value="{{col.clclass}}" checked="checked" {%if col.disable_toggle%}disabled="disabled"{%endif%} />
+ <input type="checkbox" class="col-toggle" id="checkbox-{{col.clclass}}" value="{{col.clclass}}" checked="checked" {%if col.disable_toggle%}disabled="disabled"{%endif%} data-field="{{col.field}}" />
{{col.name}}
</label>
</li>