Ignore:
Timestamp:
Nov 22, 2010, 10:33:51 AM (14 years ago)
Author:
gav
Message:

Dynamic task quick search feature.

File:
1 edited

Legend:

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

    r701 r713  
    6161        params.max = Math.min( params.max ? params.max.toInteger() : 100,  1000 )
    6262
     63        // View main data.
    6364        def taskInstanceList = []
    6465        def taskInstanceTotal
     
    6869        // Restore search unless a new search is being requested.
    6970        if(!params.quickSearch && !filterParams) {
    70             if(session.taskSearchQuickSearch)
    71                 params.quickSearch = session.taskSearchQuickSearch
    72             else if(session.taskSearchFilterParams) {
     71            if(session.taskSearchFilterParams) {
    7372                session.taskSearchFilterParams.each() { params[it.key] = it.value }
    7473                params.filter = session.taskSearchFilter
    7574                isFilterApplied = FilterUtils.isFilterApplied(params)
     75            }
     76        }
     77        if(!params.quickSearch) {
     78            if(session.taskSearchQuickSearch) {
     79                params.quickSearch = session.taskSearchQuickSearch
     80                params.person = Person.get(session.taskQuickSearchPersonId.toLong())
     81                params.startDate = session.taskQuickSearchStartDate
     82                params.endDate = session.taskQuickSearchEndDate
     83                params.includeCompleted = session.taskQuickSearchIncludeCompleted
    7684            }
    7785        }
     
    114122            session.taskSearchFilterParams = new LinkedHashMap(filterParams)
    115123            session.taskSearchFilter = new LinkedHashMap(params.filter)
    116             session.removeAttribute("taskSearchQuickSearch")
    117124        }
    118125        else {
    119126            // Quick Search:
    120             if(!params.quickSearch) params.quickSearch = "myTodays"
    121127            def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request))
    122128            taskInstanceList = result.taskInstanceList
    123129            taskInstanceTotal = result.taskInstanceList.totalCount
    124130            params.message = result.message
    125             filterParams.quickSearch = result.quickSearch
     131            params.quickSearch = result.quickSearch
     132            params.person = result.person
     133            params.startDate = result.startDate
     134            params.endDate = result.endDate
     135            params.includeCompleted = result.includeCompleted
    126136            // Remember search.
    127137            session.removeAttribute("taskSearchFilterParams")
    128138            session.removeAttribute("taskSearchFilter")
    129139            session.taskSearchQuickSearch = result.quickSearch
     140            session.taskQuickSearchPersonId = result.person.id
     141            session.taskQuickSearchStartDate = result.startDate
     142            session.taskQuickSearchEndDate = result.endDate
     143            session.taskQuickSearchIncludeCompleted = result.includeCompleted
    130144        }
    131145
     
    181195                        filterParams: filterParams,
    182196                        params: params,
    183                         associatedPropertyValues: associatedPropertyValues ]
     197                        associatedPropertyValues: associatedPropertyValues,
     198                        quickSearchSelection: taskSearchService.quickSearchSelection]
    184199
    185200    } // search
     
    206221        // Restore search unless a new search is being requested.
    207222        if(!params.quickSearch && !filterParams) {
    208             if(session.taskSearchCalendarQuickSearch)
    209                 params.quickSearch = session.taskSearchCalendarQuickSearch
    210             else if(session.taskSearchCalendarFilterParams) {
     223            if(session.taskSearchCalendarFilterParams) {
    211224                session.taskSearchCalendarFilterParams.each() { params[it.key] = it.value }
    212225                params.filter = session.taskSearchCalendarFilter
    213226                isFilterApplied = FilterUtils.isFilterApplied(params)
     227            }
     228        }
     229        if(!params.quickSearch) {
     230            if(session.taskSearchCalendarQuickSearch) {
     231                params.quickSearch = session.taskSearchCalendarQuickSearch
     232                params.person = Person.get(session.taskCalendarQuickSearchPersonId.toLong())
     233                params.startDate = session.taskCalendarQuickSearchStartDate
     234                params.endDate = session.taskCalendarQuickSearchEndDate
     235                params.includeCompleted = session.taskCalendarQuickSearchIncludeCompleted
    214236            }
    215237        }
     
    250272            session.taskSearchCalendarFilterParams = new LinkedHashMap(filterParams)
    251273            session.taskSearchCalendarFilter = new LinkedHashMap(params.filter)
    252             session.removeAttribute("taskSearchCalendarQuickSearch")
    253274        }
    254275        else {
     
    258279            taskInstanceTotal = result.taskInstanceList.totalCount
    259280            params.message = result.message
    260             filterParams.quickSearch = result.quickSearch
     281            params.quickSearch = result.quickSearch
     282            params.person = result.person
     283            params.startDate = result.startDate
     284            params.endDate = result.endDate
     285            params.includeCompleted = result.includeCompleted
    261286            // Remember search.
    262287            session.removeAttribute("taskSearchCalendarFilterParams")
    263288            session.removeAttribute("taskSearchCalendarFilter")
    264289            session.taskSearchCalendarQuickSearch = result.quickSearch
     290            session.taskCalendarQuickSearchPersonId = result.person.id
     291            session.taskCalendarQuickSearchStartDate = result.startDate
     292            session.taskCalendarQuickSearchEndDate = result.endDate
     293            session.taskCalendarQuickSearchIncludeCompleted = result.includeCompleted
    265294        }
    266295
     
    329358                        nextMonth: calendarMonthControls.nextMonth,
    330359                        previousYear: calendarMonthControls.previousYear,
    331                         nextYear: calendarMonthControls.nextYear]
     360                        nextYear: calendarMonthControls.nextYear,
     361                        quickSearchSelection: taskSearchService.quickSearchSelection]
    332362
    333363    } // searchCalendar
Note: See TracChangeset for help on using the changeset viewer.