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