Changeset 582


Ignore:
Timestamp:
Jun 8, 2010, 4:28:09 PM (14 years ago)
Author:
gav
Message:

New defaultSort for Tasks, sort by status then priority then target start date.
Small improvement to custom:sortableColumnWithImg to allow imgTitle to be specified.

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r567 r582  
    7878        // Remember sort if supplied, otherwise try to restore.
    7979        if(params.sort && params.order) {
    80              session.taskSearchSort = params.sort
    81              session.taskSearchOrder = params.order
     80            // Reset to defaultSort if requested.
     81            if(params.sort == 'defaultSort') {
     82                params.sort = null
     83                params.order = null
     84                session.removeAttribute("taskSearchSort")
     85                session.removeAttribute("taskSearchOrder")
     86            }
     87            else {
     88                session.taskSearchSort = params.sort
     89                session.taskSearchOrder = params.order
     90            }
    8291        }
    8392        else if(session.taskSearchSort && session.taskSearchOrder) {
     
    8897        if(isFilterApplied) {
    8998            // filterPane:
     99            params.sort = params.sort ?: "id"
     100            params.order = params.order ?: "desc"
    90101            if(params.sort == "attentionFlag") // See ticket #64 in Trac.
    91102                params.sort = "id"
     
    146157        filterParams.max = params.max
    147158        filterParams.offset = params.offset?.toInteger() ?: 0
    148         filterParams.sort = params.sort ?: "attentionFlag"
     159        filterParams.sort = params.sort ?: "id"
    149160        filterParams.order = params.order ?: "desc"
    150161
  • trunk/grails-app/services/TaskSearchService.groovy

    r529 r582  
    161161        paginateParams.offset = params?.offset?.toInteger() ?: 0
    162162
    163         def sort = "task." + (params?.sort ?: "attentionFlag")
    164         def order = params?.order == "asc" ? "asc" : "desc"
    165         def orderBy = " order by " + sort + ' ' + order
     163        def orderBy = ''
     164        if(params.sort?.contains('.')) // protect against filterpane bug.
     165            params.sort = null
     166        if(params.sort && params.order) {
     167            def sort = "task." + params.sort
     168            def order = (params.order == "asc") ? "asc" : "desc"
     169            orderBy = " order by " + sort + ' ' + order
     170        }
     171        else
     172            orderBy = " order by task.taskStatus, task.taskPriority, task.targetStartDate"
    166173
    167174        def namedParams = [:]
     
    198205        paginateParams.offset = params?.offset?.toInteger() ?: 0
    199206
    200         def sort = "task." + (params?.sort ?: "attentionFlag")
    201         def order = params?.order == "asc" ? "asc" : "desc"
    202         def orderBy = " order by " + sort + ' ' + order
     207        def orderBy = ''
     208        if(params.sort?.contains('.')) // protect against filterpane bug.
     209            params.sort = null
     210        if(params.sort && params.order) {
     211            def sort = "task." + params.sort
     212            def order = (params.order == "asc") ? "asc" : "desc"
     213            orderBy = " order by " + sort + ' ' + order
     214        }
     215        else
     216            orderBy = " order by task.taskStatus, task.taskPriority, task.targetStartDate"
    203217
    204218        def namedParams = [:]
  • trunk/grails-app/taglib/CustomTagLib.groovy

    r417 r582  
    173173
    174174        // Image.
    175         def imgSrc = attrs.remove("imgSrc")
    176         def imgAlt = attrs.remove("imgAlt")
    177         def img = "<img src=${imgSrc} alt=${imgAlt} />"
     175        def img = "<img "
     176        def imgAttrs = [:]
     177        imgAttrs.src = attrs.remove("imgSrc")
     178        imgAttrs.alt = attrs.remove("imgAlt")
     179        imgAttrs.title = attrs.remove("imgTitle")
     180        imgAttrs.each { k, v ->
     181            if(v)
     182                img += "${k}=\"${v.encodeAsHTML()}\" "
     183        }
     184        img += "/>"
    178185
    179186        writer << "<th "
     
    184191        }
    185192        writer << ">${link(action:action, params:linkParams) { img } }"
    186 //         writer << body()
    187193        writer << "</th>"
    188     }
     194
     195    } // sortableColumnWithImg
    189196
    190197} // end class
  • trunk/grails-app/views/taskDetailed/search.gsp

    r570 r582  
    8989                                <custom:sortableColumnWithImg property="attentionFlag"
    9090                                                                                                imgSrc="${resource(dir:'images/skin',file:'flag_red.png')}"
    91                                                                                                 imgAlt="Flag" params="${filterParams}" />
     91                                                                                                imgAlt="Flag"
     92                                                                                                params="${filterParams}" />
    9293
    9394                                <g:sortableColumn property="id" title="Id" params="${filterParams}" />
     
    103104                                <g:sortableColumn  property="taskStatus" title="Status" params="${filterParams}" />
    104105
    105                                 <th></th>
     106                                <custom:sortableColumnWithImg property="defaultSort"
     107                                                                                                imgSrc="${resource(dir:'images/skin',file:'table_sort.png')}"
     108                                                                                                imgAlt="Sort"
     109                                                                                                imgTitle="Default Sort"
     110                                                                                                params="${filterParams}" />
    106111
    107112                            </tr>
Note: See TracChangeset for help on using the changeset viewer.