Ignore:
Timestamp:
Jun 4, 2010, 12:15:24 PM (11 years ago)
Author:
roberth
Message:

Adding of contacts is made possible in the study creation wizard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/PersonController.groovy

    r496 r527  
    4949    def possibleGenders = [ 'Male', 'Female' ]
    5050
     51    /**
     52     * Fires after every action and determines the layout of the page
     53     */
     54    def afterInterceptor = { model, modelAndView ->
     55      println( params );
     56     
     57      if ( params['dialog'] ) {
     58        model.layout = 'dialog';
     59        model.extraparams = [ 'dialog': 'true' ] ;
     60      } else {
     61        model.layout = 'main';
     62        model.extraparams = [] ;
     63      }
     64    }
     65
    5166    def index = {
    5267        redirect(action: "list", params: params)
     
    6681    def save = {
    6782        def personInstance = new Person(params)
     83        def extraparams = new LinkedHashMap();
     84
     85        if( params[ 'dialog' ] ) {
     86          extraparams[ 'dialog' ] = params[ 'dialog' ]
     87        }
     88
    6889        if (personInstance.save(flush: true)) {
    6990            flash.message = "${message(code: 'default.created.message', args: [message(code: 'person.label', default: 'Person'), ( personInstance.firstName ? personInstance.firstName : "" ) + " " + ( personInstance.prefix ? personInstance.prefix : "" ) + " " + ( personInstance.lastName ? personInstance.lastName : "" )])}"
    70             redirect(action: "show", id: personInstance.id)
     91           
     92            redirect(action: "show", id: personInstance.id, params: extraparams )
    7193        }
    7294        else {
     
    99121    def update = {
    100122        def personInstance = Person.get(params.id)
     123
     124        def extraparams = new LinkedHashMap();
     125
     126        if( params[ 'dialog' ] ) {
     127          extraparams[ 'dialog' ] = params[ 'dialog' ]
     128        }
     129
    101130        if (personInstance) {
    102131            if (params.version) {
     
    112141            if (!personInstance.hasErrors() && personInstance.save(flush: true)) {
    113142                flash.message = "${message(code: 'default.updated.message', args: [message(code: 'person.label', default: 'Person'), ( personInstance.firstName ? personInstance.firstName : "" ) + " " + ( personInstance.prefix ? personInstance.prefix : "" ) + " " + ( personInstance.lastName ? personInstance.lastName : "" )])}"
    114                 redirect(action: "show", id: personInstance.id)
     143                redirect(action: "show", id: personInstance.id, params: extraparams)
    115144            }
    116145            else {
     
    120149        else {
    121150            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'person.label', default: 'Person'), params.id])}"
    122             redirect(action: "list")
     151            redirect(action: "list", params: extraparams)
    123152        }
    124153    }
     
    127156        def personInstance = Person.get(params.id)
    128157
     158        def extraparams = new LinkedHashMap();
     159
     160        if( params[ 'dialog' ] ) {
     161          extraparams[ 'dialog' ] = params[ 'dialog' ]
     162        }
     163
    129164        if (personInstance) {
    130165            def personName = ( personInstance.firstName ? personInstance.firstName : "" ) + " " + ( personInstance.prefix ? personInstance.prefix : "" ) + " " + ( personInstance.lastName ? personInstance.lastName : "" );
     
    132167                personInstance.delete(flush: true)
    133168                flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'person.label', default: 'Person'), personName])}"
    134                 redirect(action: "list")
     169                redirect(action: "list", params: extraparams)
    135170            }
    136171            catch (org.springframework.dao.DataIntegrityViolationException e) {
    137172                flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'person.label', default: 'Person'), personName])}"
    138                 redirect(action: "show", id: params.id)
     173                redirect(action: "show", id: params.id, params: extraparams)
    139174            }
    140175        }
    141176        else {
    142177            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'person.label', default: 'Person'), params.id])}"
    143             redirect(action: "list")
     178            redirect(action: "list", params: extraparams)
    144179        }
    145180    }
Note: See TracChangeset for help on using the changeset viewer.