Changeset 552 for trunk


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().

Location:
trunk/grails-app
Files:
3 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)
  • trunk/grails-app/services/DateUtilService.groovy

    r476 r552  
    9999
    100100    /**
    101     * Get the date one year in the future.
    102     * @param date The Date object to start with.
    103     * @returns A Date object one year in the future.
     101    * Get the date plus x years.
     102    * @param date The Date object to start with, defaults to today.
     103    * @param plusYears The number of years to add, defaults to 1.
     104    * @returns A Date object adjusted by x years.
    104105    */
    105     public static Date getNextYear(Date date) {
     106    public static Date plusYear(Date date = new Date(), Integer plusYears = 1) {
    106107        use(TimeCategory) {
    107             date + 1.years
    108         }
    109     }
    110 
    111     /**
    112     * Get the date one year ago.
    113     * @param date The Date object to start with.
    114     * @returns A Date object one year ago.
    115     */
    116     public static Date getPreviousYear(Date date) {
    117         use(TimeCategory) {
    118             date - 1.years
     108            date + plusYears.years
    119109        }
    120110    }
  • trunk/grails-app/views/taskDetailed/search.gsp

    r499 r552  
    171171                                                                                taskStatus.name,
    172172                                                                                taskType.name"
    173                                     filterPropertyValues="${['taskPriority.name':[values:TaskPriority.list()],
    174                                                                                 'leadPerson.lastName':[values:Person.executeQuery('select distinct t.lastName from Person t')],
    175                                                                                 'leadPerson.firstName':[values:Person.executeQuery('select distinct t.firstName from Person t')],
    176                                                                                 'taskGroup.name':[values:TaskGroup.list()],
    177                                                                                 'associatedAssets.name':[values:Asset.list()],
    178                                                                                 'primaryAsset.name':[values:Asset.list()],
    179                                                                                 'taskStatus.name':[values:TaskStatus.list()],
    180                                                                                 'taskType.name':[values:TaskType.list()],
    181                                                                                 targetCompletionDate:[years:2020..2000,precision:'day'],
    182                                                                                 targetStartDate:[years:2020..2000,precision:'day']
     173                                    filterPropertyValues="${['taskPriority.name':[values: associatedPropertyValues.taskPriorityList],
     174                                                                                'leadPerson.lastName':[values: associatedPropertyValues.lastNameList],
     175                                                                                'leadPerson.firstName':[values: associatedPropertyValues.firstNameList],
     176                                                                                'taskGroup.name':[values: associatedPropertyValues.taskGroupList],
     177                                                                                'associatedAssets.name':[values: associatedPropertyValues.assetList],
     178                                                                                'primaryAsset.name':[values: associatedPropertyValues.assetList],
     179                                                                                'taskStatus.name':[values: associatedPropertyValues.taskStatusList],
     180                                                                                'taskType.name':[values: associatedPropertyValues.taskTypeList],
     181                                                                                targetCompletionDate:[years: associatedPropertyValues.yearRange,precision:'day'],
     182                                                                                targetStartDate:[years: associatedPropertyValues.yearRange,precision:'day']
    183183                                                                                ]}"/>
    184184
Note: See TracChangeset for help on using the changeset viewer.