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