From d384e4b10bf9ba67f610bef72cf0e5b2dd747baf Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Tue, 15 Oct 2013 17:51:03 +0200 Subject: [PATCH] Fixed bug: select columns all checked in filters, autocomplete based on query_all fields - http://trac.myslice.info/ticket/5 --- plugins/hazelnut/static/js/hazelnut.js | 4 ++-- plugins/query_editor/__init__.py | 12 +++++++++--- plugins/query_editor/static/js/query_editor.js | 9 ++++++--- portal/sliceview.py | 3 ++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/hazelnut/static/js/hazelnut.js b/plugins/hazelnut/static/js/hazelnut.js index 249d2b4b..bdb2de70 100644 --- a/plugins/hazelnut/static/js/hazelnut.js +++ b/plugins/hazelnut/static/js/hazelnut.js @@ -133,8 +133,8 @@ /* Processing hidden_columns */ $.each(this.options.hidden_columns, function(i, field) { - manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field); - //self.hide_column(field); + //manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field); + self.hide_column(field); }); }, // initialize_table diff --git a/plugins/query_editor/__init__.py b/plugins/query_editor/__init__.py index 0312ef1f..2d73053a 100644 --- a/plugins/query_editor/__init__.py +++ b/plugins/query_editor/__init__.py @@ -5,6 +5,12 @@ from django.template.loader import render_to_string # XXX We need naming helpers in the python Plugin class also, used in template class QueryEditor(Plugin): + def __init__ (self, query, query_all = None, **settings): + Plugin.__init__ (self, **settings) + self.query=query + self.query_uuid = query.query_uuid + self.query_all = query_all + self.query_all_uuid = query_all.query_uuid if query_all else None def template_file(self): return "query_editor.html" @@ -22,9 +28,6 @@ class QueryEditor(Plugin): } return reqs - def json_settings_list (self): - return ['plugin_uuid', 'domid', 'query_uuid'] - def export_json_settings (self): return True @@ -82,4 +85,7 @@ class QueryEditor(Plugin): 'checked': md_field['name'] in self.query.get_select() }) #return { 'fields': fields, 'hidden_columns': hidden_columns } + #return { 'fields': fields , 'query_uuid': self.query_uuid, 'query_all_uuid': self.query_all_uuid } return { 'fields': fields } + + def json_settings_list (self): return ['plugin_uuid', 'domid', 'query_uuid', 'query_all_uuid', ] diff --git a/plugins/query_editor/static/js/query_editor.js b/plugins/query_editor/static/js/query_editor.js index 98588181..7338b69b 100644 --- a/plugins/query_editor/static/js/query_editor.js +++ b/plugins/query_editor/static/js/query_editor.js @@ -41,6 +41,10 @@ init: function(options, element) { this._super(options, element); this.listen_query(options.query_uuid); + // this one is the complete list of resources + // and will be bound to callbacks like on_all_new_record + this.listen_query(options.query_all_uuid, 'all'); + this.elts('queryeditor-auto-filter').change(this.event_filter_added('=')); this.elts('queryeditor-filter').change(this.event_filter_added('=')); @@ -185,10 +189,9 @@ //console.log("Query_Editor: query_done!"); //console.log(this.availableTags); }, - on_new_record: function(record) + /* Autocomplete based on query_all to get all the fields, where query get only the fields selected */ + on_all_new_record: function(record) { - //console.log("Query_Editor: new_record!"); - //console.log(record); availableTags = this.availableTags; jQuery.each(record,function(key,value){ value = unfold.get_value(value); diff --git a/portal/sliceview.py b/portal/sliceview.py index 9b96d4f4..1ff92d3e 100644 --- a/portal/sliceview.py +++ b/portal/sliceview.py @@ -117,7 +117,8 @@ class SliceView (LoginRequiredAutoLogoutView): filter_query_editor = QueryEditor( page = page, - query = query_resource_all, + query = sq_resource, + query_all = query_resource_all, title = "Select Columns", domid = 'select-columns', ) -- 2.43.0