1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
2 | |
---|
3 | class AssignedGroupDetailedController extends BaseController { |
---|
4 | |
---|
5 | def assignedGroupService |
---|
6 | |
---|
7 | def index = { |
---|
8 | flash.message = g.message(code: "assignedGroup.task.not.found") |
---|
9 | redirect(controller:"taskDetailed", action:"search") |
---|
10 | } |
---|
11 | |
---|
12 | // the delete, save and update actions only accept POST requests |
---|
13 | static allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
14 | |
---|
15 | def delete = { |
---|
16 | def result = assignedGroupService.delete(params) |
---|
17 | |
---|
18 | if(!result.error) { |
---|
19 | flash.message = g.message(code: "default.delete.success", args: ["AssignedGroup", params.id]) |
---|
20 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
21 | return |
---|
22 | } |
---|
23 | |
---|
24 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
25 | |
---|
26 | if(result.error.code == "default.not.found") { |
---|
27 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
28 | return |
---|
29 | } |
---|
30 | |
---|
31 | redirect(action:show, id: params.id) |
---|
32 | } |
---|
33 | |
---|
34 | def edit = { |
---|
35 | def result = assignedGroupService.edit(params) |
---|
36 | |
---|
37 | if(!result.error) { |
---|
38 | return [assignedGroupInstance: result.assignedGroupInstance, |
---|
39 | personGroup: result.personGroup, |
---|
40 | personsInGroup: result.personsInGroup] |
---|
41 | } |
---|
42 | |
---|
43 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
44 | |
---|
45 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
46 | |
---|
47 | } |
---|
48 | |
---|
49 | def update = { |
---|
50 | def result = assignedGroupService.update(params) |
---|
51 | |
---|
52 | if(!result.error) { |
---|
53 | flash.message = g.message(code: "default.update.success", args: ["AssignedGroup", params.id]) |
---|
54 | redirect(controller:"taskDetailed", action:"show", id: result.assignedGroupInstance.task.id) |
---|
55 | return |
---|
56 | } |
---|
57 | |
---|
58 | if(result.error.code == "default.not.found") { |
---|
59 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
60 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
61 | return |
---|
62 | } |
---|
63 | |
---|
64 | if(result.error.code == "personGroup.not.found") { |
---|
65 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
66 | redirect(action:"edit", id: params.id) |
---|
67 | return |
---|
68 | } |
---|
69 | |
---|
70 | render(view:'edit', model:[assignedGroupInstance: result.assignedGroupInstance.attach(), |
---|
71 | personGroup: result.personGroup.attach(), |
---|
72 | personsInGroup: result.personsInGroup]) |
---|
73 | } |
---|
74 | |
---|
75 | def create = { |
---|
76 | def result = assignedGroupService.create(params) |
---|
77 | |
---|
78 | if(!result.error) { |
---|
79 | return [assignedGroupInstance: result.assignedGroupInstance, |
---|
80 | personGroup: result.personGroup, |
---|
81 | personsInGroup: result.personsInGroup] |
---|
82 | } |
---|
83 | |
---|
84 | if(result.error.code == "assignedGroup.task.not.found") { |
---|
85 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
86 | redirect(controller: "taskDetailed", action: "search") |
---|
87 | return |
---|
88 | } |
---|
89 | |
---|
90 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
91 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
92 | } |
---|
93 | |
---|
94 | def save = { |
---|
95 | def result = assignedGroupService.save(params) |
---|
96 | |
---|
97 | if(!result.error) { |
---|
98 | flash.message = g.message(code: "default.create.success", args: ["AssignedGroup", result.assignedGroupInstance.id]) |
---|
99 | redirect(controller:"taskDetailed", action:"show", id: result.assignedGroupInstance.task.id) |
---|
100 | return |
---|
101 | } |
---|
102 | |
---|
103 | if(result.error.code == "personGroup.not.found") { |
---|
104 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
105 | redirect(action:"create", params:["task.id": params.task?.id]) |
---|
106 | return |
---|
107 | } |
---|
108 | |
---|
109 | render(view:'create', model:[assignedGroupInstance: result.assignedGroupInstance, |
---|
110 | personGroup: result.personGroup.attach(), |
---|
111 | personsInGroup: result.personsInGroup]) |
---|
112 | } |
---|
113 | |
---|
114 | def personsInGroup = { |
---|
115 | def result = assignedGroupService.personsInGroup(params) |
---|
116 | |
---|
117 | if(!result.error) { |
---|
118 | render ( template:"personsInGroup", |
---|
119 | model: [personGroup: result.personGroup, personsInGroup: result.personsInGroup] ) |
---|
120 | return |
---|
121 | } |
---|
122 | |
---|
123 | render { |
---|
124 | div(id:"personsInGroup", g.message(code: result.error.code, args: result.error.args) ) |
---|
125 | } |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | } |
---|