1 | /** |
---|
2 | * TemplateEditorController Controler |
---|
3 | * |
---|
4 | * Webflow driven template editor |
---|
5 | * |
---|
6 | * @author Jeroen Wesbeek |
---|
7 | * @since 20100415 |
---|
8 | * @package studycapturing |
---|
9 | * |
---|
10 | * Revision information: |
---|
11 | * $Rev: 372 $ |
---|
12 | * $Author: duh $ |
---|
13 | * $Date: 2010-04-22 13:45:22 +0000 (do, 22 apr 2010) $ |
---|
14 | */ |
---|
15 | package dbnp.studycapturing |
---|
16 | import dbnp.data.* |
---|
17 | import dbnp.studycapturing.* |
---|
18 | |
---|
19 | class TemplateEditorController { |
---|
20 | /** |
---|
21 | * index closure |
---|
22 | */ |
---|
23 | def index = { |
---|
24 | // got a entity get parameter? |
---|
25 | def entity = null |
---|
26 | if (params.entity) { |
---|
27 | // decode entity get parameter |
---|
28 | entity = new String(params.entity.toString().decodeBase64()) |
---|
29 | } |
---|
30 | |
---|
31 | // got with the flow! |
---|
32 | redirect(action: 'pages', params:["entity":entity]) |
---|
33 | } |
---|
34 | |
---|
35 | /** |
---|
36 | * Webflow |
---|
37 | */ |
---|
38 | def pagesFlow = { |
---|
39 | // start the flow |
---|
40 | onStart { |
---|
41 | println params |
---|
42 | if (params.entity) { |
---|
43 | //def name = params.entity |
---|
44 | //def name = "java.lang.Integer" |
---|
45 | //println name.class |
---|
46 | //def S = new dbnp.studycapturing.Study() |
---|
47 | |
---|
48 | //def name = "dbnp.studycapturing.Study" as Class |
---|
49 | //println name.newInstance() |
---|
50 | println Class.forName(new GString("dbnp.studycapturing.Study")) |
---|
51 | //flow.entity = (name as Class).newInstance() |
---|
52 | //flow.templates = Template.findAllByEntity(flow.entity) |
---|
53 | } else { |
---|
54 | // all templates for all entities; note that normally |
---|
55 | // this shouldn't happen as this flow is designed to |
---|
56 | // launch in a jquery dialog, passing an encoded entity |
---|
57 | flow.templates = Template.findAll() |
---|
58 | } |
---|
59 | flow.templates = Template.findAll() |
---|
60 | } |
---|
61 | |
---|
62 | // main template editor page |
---|
63 | templates { |
---|
64 | render(view: "/templateEditor/templates") |
---|
65 | onRender { |
---|
66 | println "render templates" |
---|
67 | } |
---|
68 | on("next").to "start" |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|