Changeset 286


Ignore:
Timestamp:
Jan 21, 2010, 4:07:26 PM (14 years ago)
Author:
gav
Message:

Add CustomTagLib with checkBoxList.

Location:
trunk
Files:
1 added
5 edited

Legend:

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

    r284 r286  
    218218                }
    219219            }
     220
    220221            assetInstance.properties = params
     222
     223            assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems)
     224
    221225            if(!assetInstance.hasErrors() && assetInstance.save(flush: true)) {
    222226                flash.message = "Asset ${params.id} updated"
  • trunk/grails-app/domain/Asset.groovy

    r268 r286  
    2323        "${this.name}"
    2424    }
     25
     26    //  This additional setter is used to convert the checkBoxList string
     27    //  of ids selected to the corresponding domain objects.
     28    public void setAssetSubItemsFromCheckBoxList(ids) {
     29        def idList = []
     30        ids.each() {
     31            if(it.isInteger())
     32                idList << it.toInteger()
     33        }
     34        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
     35    }
     36
    2537}
    2638
  • trunk/grails-app/taglib/AssetTreeTagLib.groovy

    r285 r286  
    1 
     1/**
     2* Asset Tree tags.
     3* Specific to gnumims hence the namespace.
     4*/
    25class AssetTreeTagLib {
    36    static namespace = 'gnumims'
  • trunk/grails-app/views/assetDetailed/edit.gsp

    r276 r286  
    8585                                </td>
    8686                                <td valign="top" class="value ${hasErrors(bean:assetInstance,field:'assetSubItems','errors')}">
    87                                    
    88                                     <g:select name="assetSubItems"
    89                                                     from="${AssetSubItem.list()}"
    90                                                     size="5" multiple="yes" optionKey="id"
    91                                                     value="${assetInstance?.assetSubItems}" />
     87                                    <custom:checkBoxList name="assetSubItems"
     88                                                                    from="${AssetSubItem.list()}"
     89                                                                    value="${assetInstance?.assetSubItems.collect{it.id}}"
     90                                                                    optionKey="id"/>
    9291
    9392                                </td>
  • trunk/web-app/css/main.css

    r282 r286  
    581581    margin: 2px;
    582582}
     583
     584/* CheckBoxList Tag Lib */
     585
     586.CheckBoxList {
     587    height: 300px;
     588    overflow: auto;
     589    overflow-x: hidden;
     590    width: 400px;
     591    border: 1px solid #ccc;
     592    list-style-type: none;
     593    margin: 0;
     594    padding: 0px;
     595}
     596.CheckBoxList li {
     597    padding: 5px;
     598}
Note: See TracChangeset for help on using the changeset viewer.