added misc plugins towards wizards for the portal
[myslice.git] / plugins / wizard / __init__.py
1 from unfold.composite import Composite
2 from unfold.plugin    import Plugin
3
4 class Wizard(Composite):
5    
6     def __init__(self, *args, **kwargs):
7         Composite.__init__(self, *args, **kwargs)
8         self.validate_step_js = []
9         
10         # This, as well as the setting passing code, requires all step to be passed at init :/
11         for i, son in enumerate(self.sons):
12             try:
13                 js = son.get_validation_js() 
14                 js_name = "%s_validate_step_%d" % (self.domid.replace('-', '_'), i)
15                 self.add_js_chunks("""
16                 %s = function() {
17                     %s
18                 }
19                 """ % (js_name, js))
20             except Exception, e:
21                 js_name = 'null'
22             self.validate_step_js.append(js_name)
23
24 #            self.add_js_chunks("""
25 #            %s = function() {
26 #                %s
27 #            }
28 #            """ % (js_name, js))
29
30     def export_json_settings(self):
31         # We need initialization, even though we are not associated with a query
32         return True
33     
34     def requirements (self):
35         #return { 'js_files'     : ['js/wizard.js', 'js/jquery.smartWizard-2.0.min.js', ],
36         return { 'js_files'     : ['js/wizard.js', 'js/jquery.smartWizard-2.0.js', ],
37                  'css_files'    : ['css/wizard.css', 'css/smart_wizard.css', ] 
38                  }
39
40     def template_file (self):
41         return "wizard.html"
42
43     # the list of things passed to the js plugin
44     def json_settings_list (self): return ['plugin_uuid', 'start_step', 'validate_step_js']