1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
2 | |
---|
3 | class AssignedPersonDetailedController extends BaseController { |
---|
4 | |
---|
5 | def assignedPersonService |
---|
6 | |
---|
7 | def index = { |
---|
8 | flash.message = g.message(code: "assignedPerson.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 = assignedPersonService.delete(params) |
---|
17 | |
---|
18 | if(!result.error) { |
---|
19 | flash.message = g.message(code: "default.delete.success", args: ["AssignedPerson", 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 = assignedPersonService.edit(params) |
---|
36 | |
---|
37 | if(!result.error) { |
---|
38 | return [assignedPersonInstance: result.assignedPersonInstance, |
---|
39 | person: result.person, |
---|
40 | groupsForPerson: result.groupsForPerson] |
---|
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 = assignedPersonService.update(params) |
---|
51 | |
---|
52 | if(!result.error) { |
---|
53 | flash.message = g.message(code: "default.update.success", args: ["AssignedPerson", params.id]) |
---|
54 | redirect(controller:"taskDetailed", action:"show", id: result.assignedPersonInstance.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 == "person.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:[assignedPersonInstance: result.assignedPersonInstance.attach(), |
---|
71 | person: result.person.attach(), |
---|
72 | groupsForPerson: result.groupsForPerson]) |
---|
73 | } |
---|
74 | |
---|
75 | def create = { |
---|
76 | def result = assignedPersonService.create(params) |
---|
77 | |
---|
78 | if(!result.error) { |
---|
79 | return [assignedPersonInstance: result.assignedPersonInstance, |
---|
80 | person: result.person, |
---|
81 | groupsForPerson: result.groupsForPerson] |
---|
82 | } |
---|
83 | |
---|
84 | if(result.error.code == "assignedPerson.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 = assignedPersonService.save(params) |
---|
96 | |
---|
97 | if(!result.error) { |
---|
98 | flash.message = g.message(code: "default.create.success", args: ["AssignedPerson", result.assignedPersonInstance.id]) |
---|
99 | redirect(controller:"taskDetailed", action:"show", id: result.assignedPersonInstance.task.id) |
---|
100 | return |
---|
101 | } |
---|
102 | |
---|
103 | if(result.error.code == "person.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:[assignedPersonInstance: result.assignedPersonInstance, |
---|
110 | person: result.person.attach(), |
---|
111 | groupsForPerson: result.groupsForPerson]) |
---|
112 | } |
---|
113 | |
---|
114 | def groupsForPerson = { |
---|
115 | def result = assignedPersonService.groupsForPerson(params) |
---|
116 | |
---|
117 | if(!result.error) { |
---|
118 | render ( template:"groupsForPerson", |
---|
119 | model: [person: result.person, groupsForPerson: result.groupsForPerson] ) |
---|
120 | return |
---|
121 | } |
---|
122 | |
---|
123 | render { |
---|
124 | div(id:"groupsForPerson", g.message(code: result.error.code, args: result.error.args) ) |
---|
125 | } |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | } |
---|