Ignore:
Timestamp:
Dec 8, 2010, 12:04:47 PM (14 years ago)
Author:
gav
Message:

Remove task budget status from task views.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/TaskSearchService.groovy

    r736 r737  
    2121    def getQuickSearchSelection() {
    2222        [ 'allTasks': g.message(code: 'task.search.text.all.tasks'),
    23         'budgetPlanned': g.message(code: 'task.search.text.budget.planned'),
    24         'budgetUnplanned': g.message(code: 'task.search.text.budget.unplanned'),
    2523        'personsImmediateCallouts': g.message(code: 'task.search.text.persons.immediate.callouts'),
    2624        'personsTasks': g.message(code: 'task.search.text.persons.tasks')
     
    188186            case "allTasks":
    189187                allTasks()
    190                 break
    191             case "budgetUnplanned":
    192                 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(1), result.startDate, result.endDate+1)
    193                 if(result.taskInstanceList.totalCount > 0) {
    194                     if(result.startDate == result.endDate)
    195                         result.message = getMessage(code:"task.search.text.budget.unplanned.message",
    196                                                                         args:[ formatted(result.startDate) ])
    197                     else
    198                         result.message = getMessage(code:"task.search.text.budget.unplanned.between.message",
    199                                                                         args:[ formatted(result.startDate), formatted(result.endDate) ])
    200                 }
    201                 else {
    202                     if(result.startDate == result.endDate)
    203                         result.message = getMessage(code:"task.search.text.budget.unplanned.none.found",
    204                                                                         args:[ formatted(result.startDate) ])
    205                     else
    206                         result.message = getMessage(code:"task.search.text.budget.unplanned.between.none.found",
    207                                                                         args:[ formatted(result.startDate), formatted(result.endDate) ])
    208                 }
    209                 break
    210             case "budgetPlanned":
    211                 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(2), result.startDate, result.endDate+1)
    212                 if(result.taskInstanceList.totalCount > 0) {
    213                     if(result.startDate == result.endDate)
    214                         result.message = getMessage(code:"task.search.text.budget.planned.message",
    215                                                                         args:[ formatted(result.startDate) ])
    216                     else
    217                         result.message = getMessage(code:"task.search.text.budget.planned.between.message",
    218                                                                         args:[ formatted(result.startDate), formatted(result.endDate) ])
    219                 }
    220                 else {
    221                     if(result.startDate == result.endDate)
    222                         result.message = getMessage(code:"task.search.text.budget.planned.none.found",
    223                                                                         args:[ formatted(result.startDate) ])
    224                     else
    225                         result.message = getMessage(code:"task.search.text.budget.planned.between.none.found",
    226                                                                         args:[ formatted(result.startDate), formatted(result.endDate) ])
    227                 }
    228188                break
    229189            default:
     
    402362
    403363    /**
    404     * Get tasks by budget status, by default planned in the last week.
    405     * @param params The request params.
    406     * @param budgetStatus Defaults to planned.
    407     * @param startDate The start date to get tasks for, defaults to the start of today and is inclusive (greater than or equal to).
    408     * @param endDate The end date to get tasks for, defaults to the start of tomorrow and is exclusive (less than).
    409     */
    410     def getBudgetTasks(params, taskBudgetStatus=null, startDate=null, endDate=null) {
    411         def paginateParams = [:]
    412         paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax)
    413         paginateParams.offset = params?.offset?.toInteger() ?: 0
    414 
    415         def sort = "task." + (params?.sort ?: "targetStartDate")
    416         def order = params?.order == "desc" ? "desc" : "asc"
    417         def orderBy = " order by " + sort + ' ' + order
    418 
    419         def namedParams = [:]
    420         namedParams.taskBudgetStatus = taskBudgetStatus ?: TaskBudgetStatus.read(2) // Planned.
    421         namedParams.startDate = startDate ?: dateUtilService.today
    422         namedParams.endDate = endDate ?: dateUtilService.tomorrow
    423 
    424         def baseQuery = "from Task as task \
    425                                         where (task.trash = false \
    426                                                     and task.taskBudgetStatus = :taskBudgetStatus \
    427                                                     and task.targetStartDate < :endDate \
    428                                                     and task.targetCompletionDate >= :startDate \
    429                                         )"
    430 
    431         def searchQuery = "select distinct task " + baseQuery + orderBy
    432         def list = Task.executeQuery(searchQuery, namedParams, paginateParams)
    433 
    434         def countQuery = "select count(distinct task) as taskCount " + baseQuery
    435         def totalCount = Task.executeQuery(countQuery, namedParams)[0].toInteger()
    436 
    437         def taskInstanceList = new PagedResultList(list, totalCount)
    438         return taskInstanceList
    439     } // getBudgetTasks()
    440 
    441     /**
    442364    * Get work done by person and date.
    443365    * A person ID and date may be specified in params otherwise the current user and today are used.
Note: See TracChangeset for help on using the changeset viewer.