fixed hazelnut checkbox management
[myslice.git] / plugins / hazelnut / hazelnut.py
1 from unfold.plugin import Plugin
2
3 class Hazelnut (Plugin):
4
5     # set checkboxes if a final column with checkboxes is desired
6     # pass columns as the initial set of columns
7     #   if None then this is taken from the query's fields
8     def __init__ (self, query, query_all_uuid=None, checkboxes=False, columns=None, datatables_options={}, **settings):
9         Plugin.__init__ (self, **settings)
10         self.query          = query
11         self.query_all_uuid = query_all_uuid
12         self.checkboxes=checkboxes
13         if columns is not None:
14             self.columns=columns
15         else:
16             self.columns=self.query.fields
17         self.datatables_options=datatables_options
18
19     def template_file (self):
20         return "hazelnut.html"
21
22     def template_env (self, request):
23         env={}
24         env.update(self.__dict__)
25         env['columns']=self.columns
26         return env
27
28     def requirements (self):
29         reqs = {
30             'js_files' : [ "js/hazelnut.js", 
31                            "js/manifold.js", "js/manifold-query.js", 
32                            "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
33                            "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js", 
34                            "js/unfold-helper.js",
35                            ] ,
36             'css_files': [ "css/hazelnut.css" , 
37                            "css/dataTables.bootstrap.css",
38                            ],
39             }
40         return reqs
41
42     # the list of things passed to the js plugin
43     def json_settings_list (self):
44         return ['plugin_uuid', 'domid', 'query_uuid', 'query_all_uuid', 'checkboxes','datatables_options']