Ignore:
Timestamp:
Dec 30, 2009, 4:33:42 AM (15 years ago)
Author:
gav
Message:

Add ajax feature to show persons in the group when creating and editing assignedGroup.
Remove the list and show detailed views since they are no longer used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/AssignedGroupDetailedController.groovy

    r248 r254  
    1212    // the delete, save and update actions only accept POST requests
    1313    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( controller: "appCore", action: "start" )
    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     }
    3914
    4015    def delete = {
     
    6035        def result = assignedGroupService.edit(params)
    6136
    62         if(!result.error)
    63             return [ assignedGroupInstance : result.assignedGroupInstance ]
     37        if(!result.error) {
     38            return [assignedGroupInstance: result.assignedGroupInstance,
     39                            personGroup: result.personGroup,
     40                            personsInGroup: result.personsInGroup]
     41        }
    6442
    6543        flash.message = g.message(code: result.error.code, args: result.error.args)
     
    7452        if(!result.error) {
    7553            flash.message = g.message(code: "default.update.success", args: ["AssignedGroup", params.id])
    76             redirect(action:show, id: params.id)
     54            redirect(controller:"taskDetailed", action:"show", id: result.assignedGroupInstance.task.id)
    7755            return
    7856        }
     
    8462        }
    8563
    86         render(view:'edit', model:[assignedGroupInstance: result.assignedGroupInstance.attach()])
     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])
    8773    }
    8874
     
    9076        def result = assignedGroupService.create(params)
    9177
    92         if(!result.error)
    93             return [assignedGroupInstance: result.assignedGroupInstance]
     78        if(!result.error) {
     79            return [assignedGroupInstance: result.assignedGroupInstance,
     80                            personGroup: result.personGroup,
     81                            personsInGroup: result.personsInGroup]
     82        }
    9483
    9584        if(result.error.code == "assignedGroup.task.not.found") {
     
    112101        }
    113102
    114         render(view:'edit', model:[assignedGroupInstance: result.assignedGroupInstance])
     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])
     112    }
     113
     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
    115127    }
    116128
Note: See TracChangeset for help on using the changeset viewer.