[242] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
| 2 | |
---|
| 3 | class AssignedGroupDetailedController extends BaseController { |
---|
| 4 | |
---|
[247] | 5 | def assignedGroupService |
---|
[242] | 6 | |
---|
[247] | 7 | def index = { |
---|
| 8 | flash.message = g.message(code: "assignedGroup.task.not.found") |
---|
| 9 | redirect(controller:"taskDetailed", action:"search") |
---|
| 10 | } |
---|
| 11 | |
---|
[242] | 12 | // the delete, save and update actions only accept POST requests |
---|
| 13 | static allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
| 14 | |
---|
| 15 | def delete = { |
---|
[247] | 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 |
---|
[242] | 22 | } |
---|
[247] | 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 |
---|
[242] | 29 | } |
---|
[247] | 30 | |
---|
| 31 | redirect(action:show, id: params.id) |
---|
[242] | 32 | } |
---|
| 33 | |
---|
| 34 | def edit = { |
---|
[247] | 35 | def result = assignedGroupService.edit(params) |
---|
[242] | 36 | |
---|
[254] | 37 | if(!result.error) { |
---|
| 38 | return [assignedGroupInstance: result.assignedGroupInstance, |
---|
| 39 | personGroup: result.personGroup, |
---|
| 40 | personsInGroup: result.personsInGroup] |
---|
| 41 | } |
---|
[247] | 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 | |
---|
[242] | 47 | } |
---|
| 48 | |
---|
| 49 | def update = { |
---|
[247] | 50 | def result = assignedGroupService.update(params) |
---|
[242] | 51 | |
---|
[247] | 52 | if(!result.error) { |
---|
| 53 | flash.message = g.message(code: "default.update.success", args: ["AssignedGroup", params.id]) |
---|
[254] | 54 | redirect(controller:"taskDetailed", action:"show", id: result.assignedGroupInstance.task.id) |
---|
[247] | 55 | return |
---|
[242] | 56 | } |
---|
[247] | 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 |
---|
[242] | 62 | } |
---|
[247] | 63 | |
---|
[254] | 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]) |
---|
[242] | 73 | } |
---|
| 74 | |
---|
| 75 | def create = { |
---|
[247] | 76 | def result = assignedGroupService.create(params) |
---|
| 77 | |
---|
[254] | 78 | if(!result.error) { |
---|
| 79 | return [assignedGroupInstance: result.assignedGroupInstance, |
---|
| 80 | personGroup: result.personGroup, |
---|
| 81 | personsInGroup: result.personsInGroup] |
---|
| 82 | } |
---|
[247] | 83 | |
---|
| 84 | if(result.error.code == "assignedGroup.task.not.found") { |
---|
| 85 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
[242] | 86 | redirect(controller: "taskDetailed", action: "search") |
---|
[247] | 87 | return |
---|
[242] | 88 | } |
---|
[247] | 89 | |
---|
| 90 | flash.message = g.message(code: result.error.code, args: result.error.args) |
---|
| 91 | redirect(controller:"taskDetailed", action:"show", id: params.task?.id) |
---|
[242] | 92 | } |
---|
| 93 | |
---|
| 94 | def save = { |
---|
[247] | 95 | def result = assignedGroupService.save(params) |
---|
[242] | 96 | |
---|
[247] | 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 |
---|
[242] | 101 | } |
---|
[247] | 102 | |
---|
[254] | 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]) |
---|
[242] | 112 | } |
---|
[247] | 113 | |
---|
[254] | 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 | |
---|
[242] | 129 | } |
---|