turning off demo_page.css and demo_table.css for now
[myslice.git] / plugins / query_editor / __init__.py
index f5a334e..53adeae 100644 (file)
@@ -2,6 +2,8 @@ from unfold.plugin import Plugin
 
 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 template_file(self):
@@ -10,12 +12,14 @@ class QueryEditor(Plugin):
     def requirements (self):
         reqs = {
             'js_files' : [
+                # XXX datatables
                 'js/query_editor.js',
             ] ,
             'css_files': [
                 'css/query_editor.css',
-                'css/demo_page.css',
-                'css/demo_table.css',
+                'css/jquery-ui.css',
+#                'css/demo_page.css',
+#                'css/demo_table.css',
             ]
         }
         return reqs
@@ -30,7 +34,6 @@ class QueryEditor(Plugin):
         fields = []
         metadata = self.page.get_metadata()
         md_fields = metadata.details_by_object('resource')
-        print "METADATA FIELDS", md_fields
 
         # XXX use django templating system here
         for md_field in md_fields['column']:
@@ -44,18 +47,32 @@ class QueryEditor(Plugin):
                         v_desc = v.split('-')
                         options.append(v_desc[0])
 
-                    env = {'options': options}
+                    env = {
+                        'domid': self.domid,
+                        'options': options
+                    }
                     filter_input = render_to_string('filter_input_string_values.html', env)
                 else:
-                    env = {'filter_id': "%s-filter-%s" % (self.domid, md_field['name'])}
+                    env = {
+                        'domid': self.domid,
+                        'field': md_field['name']
+                    }
                     filter_input = render_to_string('filter_input_string.html', env)
                     
             elif md_field['type'] == 'int':
                 allowed_values = md_field.get('allowed_values', '0,0').split(',')
-                env = {'min': allowed_values[0], 'max': allowed_values[1]}
+                env = {
+                    'domid': self.domid,
+                    'field': md_field['name'],
+                    'min'  : allowed_values[0],
+                    'max'  : allowed_values[1]
+                }
                 filter_input = render_to_string('filter_input_integer.html', env)
             else:
-                env = {'filter_id': "%s-filter-%s" % (self.domid, md_field['name'])}
+                env = {
+                    'domid': self.domid,
+                    'field': md_field['name']
+                }
                 filter_input = render_to_string('filter_input_others.html', env)
 
             fields.append({
@@ -64,5 +81,6 @@ class QueryEditor(Plugin):
                 'resource_type': 'N/A',
                 'filter_input':  filter_input,
                 'header':        None,
+                'checked':       md_field['name'] in self.query.get_select()
             })
         return { 'fields': fields }