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 list = { |
---|
16 | def result = assignedGroupService.list(params) |
---|
17 | if(!result.error) { |
---|
18 | return [ assignedGroupInstanceList: result.assignedGroupInstanceList, |
---|
19 | assignedGroupInstanceTotal: result.assignedGroupInstanceTotal ] |
---|
20 | } |
---|
21 | |
---|
22 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
23 | redirect( url: resource(dir:'') ) |
---|
24 | } |
---|
25 | |
---|
26 | def show = { |
---|
27 | def result = assignedGroupService.show(params) |
---|
28 | |
---|
29 | if(!result.error) |
---|
30 | return [ assignedGroupInstance: result.assignedGroupInstance ] |
---|
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 = assignedGroupService.delete(params) |
---|
42 | |
---|
43 | if(!result.error) { |
---|
44 | flash.message = g.message(code: "default.delete.success", args: ["AssignedGroup", 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 = assignedGroupService.edit(params) |
---|
61 | |
---|
62 | if(!result.error) |
---|
63 | return [ assignedGroupInstance : result.assignedGroupInstance ] |
---|
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 = assignedGroupService.update(params) |
---|
73 | |
---|
74 | if(!result.error) { |
---|
75 | flash.message = g.message(code: "default.update.success", args: ["AssignedGroup", 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:[assignedGroupInstance: result.assignedGroupInstance.attach()]) |
---|
87 | } |
---|
88 | |
---|
89 | def create = { |
---|
90 | def result = assignedGroupService.create(params) |
---|
91 | |
---|
92 | if(!result.error) |
---|
93 | return [assignedGroupInstance: result.assignedGroupInstance] |
---|
94 | |
---|
95 | if(result.error.code == "assignedGroup.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 = assignedGroupService.save(params) |
---|
107 | |
---|
108 | if(!result.error) { |
---|
109 | flash.message = g.message(code: "default.create.success", args: ["AssignedGroup", result.assignedGroupInstance.id]) |
---|
110 | redirect(controller:"taskDetailed", action:"show", id: result.assignedGroupInstance.task.id) |
---|
111 | return |
---|
112 | } |
---|
113 | |
---|
114 | render(view:'edit', model:[assignedGroupInstance: result.assignedGroupInstance]) |
---|
115 | } |
---|
116 | |
---|
117 | } |
---|