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 list = { |
---|
16 | def result = assignedPersonService.list(params) |
---|
17 | if(!result.error) { |
---|
18 | return [ assignedPersonInstanceList: result.assignedPersonInstanceList, |
---|
19 | assignedPersonInstanceTotal: result.assignedPersonInstanceTotal ] |
---|
20 | } |
---|
21 | |
---|
22 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
23 | redirect( controller: "appCore", action: "start" ) |
---|
24 | } |
---|
25 | |
---|
26 | def show = { |
---|
27 | def result = assignedPersonService.show(params) |
---|
28 | |
---|
29 | if(!result.error) |
---|
30 | return [ assignedPersonInstance: result.assignedPersonInstance ] |
---|
31 | |
---|
32 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
33 | |
---|
34 | if(params.task?.id) |
---|
35 | redirect(controller:"taskDetailed", action:"show", id: params.task.id) |
---|
36 | |
---|
37 | redirect(controller:"taskDetailed", action:"search") |
---|
38 | } |
---|
39 | |
---|
40 | def delete = { |
---|
41 | def result = assignedPersonService.delete(params) |
---|
42 | |
---|
43 | if(!result.error) { |
---|
44 | flash.message = g.message(code: "default.delete.success", args: ["AssignedPerson", params.id]) |
---|
45 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
46 | return |
---|
47 | } |
---|
48 | |
---|
49 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
50 | |
---|
51 | if(result.error.code == "default.not.found") { |
---|
52 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
53 | return |
---|
54 | } |
---|
55 | |
---|
56 | redirect(action:show, id: params.id) |
---|
57 | } |
---|
58 | |
---|
59 | def edit = { |
---|
60 | def result = assignedPersonService.edit(params) |
---|
61 | |
---|
62 | if(!result.error) |
---|
63 | return [ assignedPersonInstance : result.assignedPersonInstance ] |
---|
64 | |
---|
65 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
66 | |
---|
67 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | def update = { |
---|
72 | def result = assignedPersonService.update(params) |
---|
73 | |
---|
74 | if(!result.error) { |
---|
75 | flash.message = g.message(code: "default.update.success", args: ["AssignedPerson", params.id]) |
---|
76 | redirect(action:show, id: params.id) |
---|
77 | return |
---|
78 | } |
---|
79 | |
---|
80 | if(result.error.code == "default.not.found") { |
---|
81 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
82 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
83 | return |
---|
84 | } |
---|
85 | |
---|
86 | render(view:'edit', model:[assignedPersonInstance: result.assignedPersonInstance.attach()]) |
---|
87 | } |
---|
88 | |
---|
89 | def create = { |
---|
90 | def result = assignedPersonService.create(params) |
---|
91 | |
---|
92 | if(!result.error) |
---|
93 | return [assignedPersonInstance: result.assignedPersonInstance] |
---|
94 | |
---|
95 | if(result.error.code == "assignedPerson.task.not.found") { |
---|
96 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
97 | redirect(controller: "taskDetailed", action: "search") |
---|
98 | return |
---|
99 | } |
---|
100 | |
---|
101 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
102 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
103 | } |
---|
104 | |
---|
105 | def save = { |
---|
106 | def result = assignedPersonService.save(params) |
---|
107 | |
---|
108 | if(!result.error) { |
---|
109 | flash.message = g.message(code: "default.create.success", args: ["AssignedPerson", result.assignedPersonInstance.id]) |
---|
110 | redirect(controller:"taskDetailed", action:"show", id: result.assignedPersonInstance.task.id) |
---|
111 | return |
---|
112 | } |
---|
113 | |
---|
114 | render(view:'edit', model:[assignedPersonInstance: result.assignedPersonInstance]) |
---|
115 | } |
---|
116 | |
---|
117 | } |
---|