Ignore:
Timestamp:
May 31, 2010, 1:29:04 PM (14 years ago)
Author:
gav
Message:

Get Task Search filterpane associatedPropertyValues in controller instead of in gsp.
Sort and only get active items for associatedPropertyValues.
Small refator of DateUtilService with new plusYear().

File:
1 edited

Legend:

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

    r525 r552  
    149149        filterParams.order = params.order ?: "desc"
    150150
     151        // Get some associatedProperty values for filterpane.
     152        def associatedPropertyValues = [:]
     153        def associatedPropertyMax = 10000
     154        associatedPropertyValues.taskPriorityList = TaskPriority.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     155        def lastNameQuery = 'select distinct p.lastName from Person p where p.isActive = ? order by p.lastName'
     156        associatedPropertyValues.lastNameList = Person.executeQuery(lastNameQuery, [true], [max:associatedPropertyMax])
     157        def firstNameQuery = 'select distinct p.firstName from Person p where p.isActive = ? order by p.firstName'
     158        associatedPropertyValues.firstNameList = Person.executeQuery(firstNameQuery, [true], [max:associatedPropertyMax])
     159        associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     160        associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     161        associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     162        associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])
     163        def startOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), -10))
     164        def endOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), 10))
     165        associatedPropertyValues.yearRange = startOfYearRange..endOfYearRange
     166
    151167        return[ taskInstanceList: taskInstanceList,
    152168                        taskInstanceTotal: taskInstanceTotal,
    153169                        filterParams: filterParams,
    154                         params: params ]
     170                        params: params,
     171                        associatedPropertyValues: associatedPropertyValues]
    155172
    156173    } // search
     
    800817        result.previousMonth.year = dateUtilService.getYearFromDate(result.previousMonth.date)
    801818        result.nextYear = [:]
    802         result.nextYear.date = dateUtilService.getNextYear(showDate)
     819        result.nextYear.date = dateUtilService.plusYear(showDate)
    803820        result.nextYear.month = dateUtilService.getMonthFromDate(result.nextYear.date)
    804821        result.nextYear.year = dateUtilService.getYearFromDate(result.nextYear.date)
    805822        result.previousYear = [:]
    806         result.previousYear.date = dateUtilService.getPreviousYear(showDate)
     823        result.previousYear.date = dateUtilService.plusYear(showDate, -1)
    807824        result.previousYear.month = dateUtilService.getMonthFromDate(result.previousYear.date)
    808825        result.previousYear.year = dateUtilService.getYearFromDate(result.previousYear.date)
Note: See TracChangeset for help on using the changeset viewer.