Changeset 713 for trunk/grails-app
- Timestamp:
- Nov 22, 2010, 10:33:51 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r701 r713 61 61 params.max = Math.min( params.max ? params.max.toInteger() : 100, 1000 ) 62 62 63 // View main data. 63 64 def taskInstanceList = [] 64 65 def taskInstanceTotal … … 68 69 // Restore search unless a new search is being requested. 69 70 if(!params.quickSearch && !filterParams) { 70 if(session.taskSearchQuickSearch) 71 params.quickSearch = session.taskSearchQuickSearch 72 else if(session.taskSearchFilterParams) { 71 if(session.taskSearchFilterParams) { 73 72 session.taskSearchFilterParams.each() { params[it.key] = it.value } 74 73 params.filter = session.taskSearchFilter 75 74 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 76 84 } 77 85 } … … 114 122 session.taskSearchFilterParams = new LinkedHashMap(filterParams) 115 123 session.taskSearchFilter = new LinkedHashMap(params.filter) 116 session.removeAttribute("taskSearchQuickSearch")117 124 } 118 125 else { 119 126 // Quick Search: 120 if(!params.quickSearch) params.quickSearch = "myTodays"121 127 def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request)) 122 128 taskInstanceList = result.taskInstanceList 123 129 taskInstanceTotal = result.taskInstanceList.totalCount 124 130 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 126 136 // Remember search. 127 137 session.removeAttribute("taskSearchFilterParams") 128 138 session.removeAttribute("taskSearchFilter") 129 139 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 130 144 } 131 145 … … 181 195 filterParams: filterParams, 182 196 params: params, 183 associatedPropertyValues: associatedPropertyValues ] 197 associatedPropertyValues: associatedPropertyValues, 198 quickSearchSelection: taskSearchService.quickSearchSelection] 184 199 185 200 } // search … … 206 221 // Restore search unless a new search is being requested. 207 222 if(!params.quickSearch && !filterParams) { 208 if(session.taskSearchCalendarQuickSearch) 209 params.quickSearch = session.taskSearchCalendarQuickSearch 210 else if(session.taskSearchCalendarFilterParams) { 223 if(session.taskSearchCalendarFilterParams) { 211 224 session.taskSearchCalendarFilterParams.each() { params[it.key] = it.value } 212 225 params.filter = session.taskSearchCalendarFilter 213 226 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 214 236 } 215 237 } … … 250 272 session.taskSearchCalendarFilterParams = new LinkedHashMap(filterParams) 251 273 session.taskSearchCalendarFilter = new LinkedHashMap(params.filter) 252 session.removeAttribute("taskSearchCalendarQuickSearch")253 274 } 254 275 else { … … 258 279 taskInstanceTotal = result.taskInstanceList.totalCount 259 280 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 261 286 // Remember search. 262 287 session.removeAttribute("taskSearchCalendarFilterParams") 263 288 session.removeAttribute("taskSearchCalendarFilter") 264 289 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 265 294 } 266 295 … … 329 358 nextMonth: calendarMonthControls.nextMonth, 330 359 previousYear: calendarMonthControls.previousYear, 331 nextYear: calendarMonthControls.nextYear] 360 nextYear: calendarMonthControls.nextYear, 361 quickSearchSelection: taskSearchService.quickSearchSelection] 332 362 333 363 } // searchCalendar -
trunk/grails-app/i18n/messages.properties
r708 r713 374 374 # 375 375 376 task.search.include.completed=Incl. Completed 377 task.search.include.completed.help=Include completed tasks in the results. 378 379 task.search.text.all.tasks=All Tasks 380 task.search.text.all.tasks.help=All tasks that are not in the trash. Tasks in the trash must be explicitly requested in the advanced search. 376 381 task.search.text.all.tasks.message=All tasks for {0}. 377 382 task.search.text.all.tasks.none.found=No tasks found for {0}. … … 379 384 task.search.text.all.tasks.between.none.found=No tasks found between {0} and {1}. 380 385 386 task.search.text.budget.planned=Budget Planned 387 task.search.text.budget.planned.help=Tasks with a budget status of 'Planned'. 388 task.search.text.budget.planned.message=Tasks with a budget status of 'Planned' for {0}. 389 task.search.text.budget.planned.none.found=No tasks found with a budget status of 'Planned' for {0}. 390 task.search.text.budget.planned.between.message=Tasks with a budget status of 'Planned' between {0} and {1}. 391 task.search.text.budget.planned.between.none.found=No tasks found with a budget status of 'Planned' between {0} and {1}. 392 393 task.search.text.budget.unplanned=Budget Unplanned 394 task.search.text.budget.unplanned.help=Tasks with a budget status of 'Unplanned'. 395 task.search.text.budget.unplanned.message=Tasks with a budget status of 'Unplanned' for {0}. 396 task.search.text.budget.unplanned.none.found=No tasks found with a budget status of 'Unplanned' for {0}. 397 task.search.text.budget.unplanned.between.message=Tasks with a budget status of 'Unplanned' between {0} and {1}. 398 task.search.text.budget.unplanned.between.none.found=No tasks found with a budget status of 'Unplanned' between {0} and {1}. 399 400 task.search.text.persons.tasks=Person's Tasks 401 task.search.text.persons.tasks.help=Approved tasks that a person is assigned to. 381 402 task.search.text.persons.tasks.message=Tasks for {0} on {1}. 382 403 task.search.text.persons.tasks.none.found=No tasks found for {0} on {1}. … … 386 407 task.search.text.my.todays=Today 387 408 task.search.text.my.todays.description=My tasks and approved tasks that I am assigned to. 388 task.search.text.my.yesterdays=Yesterday 389 task.search.text.my.tomorrows=Tomorrow 390 task.search.text.my.past.week=Past Week 391 task.search.text.todays=Today 392 task.search.text.todays.description=All tasks that are not in the trash bin. 393 task.search.text.yesterdays=Yesterday 394 task.search.text.tomorrows=Tomorrow 395 task.search.text.past.week=Past Week 396 task.search.text.budget.unplanned=Unplanned Tasks 397 task.search.text.budget.unplanned.message=Tasks with budget status of 'Unplanned' between {0} and {1}. 398 task.search.text.budget.unplanned.none.found=No tasks found with budget status of 'Unplanned' between {0} and {1}. 399 task.search.text.budget.planned=Planned Tasks 400 task.search.text.budget.planned.description=Task with budget status of Planned, in the past week. 401 task.search.text.budget.planned.message=Tasks with budget status of 'Planned' between {0} and {1}. 402 task.search.text.budget.planned.none.found=No tasks found with budget status of 'Planned' between {0} and {1}. 403 task.search.text.planners.range=Planners Range 404 task.search.text.planners.range.description=Tasks in the past week and two weeks ahead. 409 410 task.search.text.persons.immediate.callouts=Person's Callouts 411 task.search.text.persons.immediate.callouts.help=Immediate callouts by person (lead person or created by). 412 task.search.text.persons.immediate.callouts.message=Immediate callouts for {0} on {1}. 413 task.search.text.persons.immediate.callouts.none.found=No immediate callouts found for {0} on {1}. 414 task.search.text.persons.immediate.callouts.between.message=Immediate callouts for {0} between {1} and {2}. 415 task.search.text.persons.immediate.callouts.between.none.found=No immediate callouts found for {0} between {1} and {2}. 416 405 417 task.search.calendar.text.too.many.results=Too many results, only {0} are shown. 406 418 task.search.text.work.done=Work Done -
trunk/grails-app/services/TaskSearchService.groovy
r701 r713 1 import net.kromhouts.HqlBuilder 1 2 import grails.orm.PagedResultList 2 3 import org.hibernate.FetchMode as FM … … 16 17 17 18 def paramsMax = 100000 19 20 // Be sure to update taskQuickSearchPane.js if quickSearchSelection is changed. 21 def getQuickSearchSelection() { 22 [ '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'), 25 'personsImmediateCallouts': g.message(code: 'task.search.text.persons.immediate.callouts'), 26 'personsTasks': g.message(code: 'task.search.text.persons.tasks') 27 ] 28 } 18 29 19 30 /** … … 22 33 * @param locale The locale to use when generating result.message. 23 34 */ 24 def getQuickSearch(params , locale) {35 def getQuickSearch(params = [:], locale) { 25 36 def result = [:] 26 result.quickSearch = params.quickSearch ?: "plannersRange" 27 28 def currentUser = authService.currentUser 37 result.quickSearch = params.quickSearch ?: "personsTasks" 38 if(params.person) 39 result.person = Person.get(params.person.id.toLong()) 40 else 41 result.person = authService.currentUser 42 result.startDate = params.startDate ?: dateUtilService.today 43 result.endDate = params.endDate ?: dateUtilService.today 44 // Auto swap date range. 45 if(result.startDate > result.endDate) { 46 def tempStartDate = result.startDate 47 result.startDate = result.endDate 48 result.endDate = tempStartDate 49 } 50 result.includeCompleted = params.includeCompleted = params.includeCompleted ? true:false 51 52 def getMessage = { Map m -> 53 messageSource.getMessage(m.code, m.args == null ? null : m.args.toArray(), locale) 54 } 55 56 def formatted = { Date d -> 57 g.formatDate(format: "EEE, dd-MMM-yyyy", date: d) 58 } 59 29 60 def startOfToday = dateUtilService.today 30 61 def startOfYesterday = dateUtilService.yesterday … … 32 63 def oneWeekAgo = dateUtilService.oneWeekAgo 33 64 34 def formattedStartOfToday = g.formatDate(format: "EEE, dd-MMM-yyyy", date: startOfToday) 35 def formattedStartOfYesterday = g.formatDate(format: "EEE, dd-MMM-yyyy", date: startOfYesterday) 36 def formattedStartOfTomorrow = g.formatDate(format: "EEE, dd-MMM-yyyy", date: startOfTomorrow) 37 def formattedOneWeekAgo = g.formatDate(format: "EEE, dd-MMM-yyyy", date: oneWeekAgo) 38 39 def getMessage = { Map m -> 40 messageSource.getMessage(m.code, m.args == null ? null : m.args.toArray(), locale) 65 def formattedStartOfToday = formatted(startOfToday) 66 def formattedStartOfYesterday = formatted(startOfYesterday) 67 def formattedStartOfTomorrow = formatted(startOfTomorrow) 68 def formattedOneWeekAgo = formatted(oneWeekAgo) 69 70 def allTasks = { 71 result.taskInstanceList = getTasks(params, result.startDate, result.endDate+1) 72 if(result.taskInstanceList.totalCount > 0) { 73 if(result.startDate == result.endDate) 74 result.message = getMessage(code:"task.search.text.all.tasks.message", 75 args:[ formatted(result.startDate) ]) 76 else 77 result.message = getMessage(code:"task.search.text.all.tasks.between.message", 78 args:[ formatted(result.startDate), formatted(result.endDate) ]) 79 } 80 else { 81 if(result.startDate == result.endDate) 82 result.message = getMessage(code:"task.search.text.all.tasks.none.found", 83 args:[ formatted(result.startDate) ]) 84 else 85 result.message = getMessage(code:"task.search.text.all.tasks.between.none.found", 86 args:[ formatted(result.startDate), formatted(result.endDate) ]) 87 } 88 89 } 90 91 def personsTasks = { 92 result.taskInstanceList = getPersonsTasks(params, result.person, result.startDate, result.endDate+1) 93 if(result.taskInstanceList.totalCount > 0) { 94 if(result.startDate == result.endDate) 95 result.message = getMessage(code:"task.search.text.persons.tasks.message", 96 args:[ result.person, formatted(result.startDate) ]) 97 else 98 result.message = getMessage(code:"task.search.text.persons.tasks.between.message", 99 args:[ result.person, formatted(result.startDate), formatted(result.endDate) ]) 100 } 101 else { 102 if(result.startDate == result.endDate) 103 result.message = getMessage(code:"task.search.text.persons.tasks.none.found", 104 args:[ result.person, formatted(result.startDate) ]) 105 else 106 result.message = getMessage(code:"task.search.text.persons.tasks.between.none.found", 107 args:[ result.person, formatted(result.startDate), formatted(result.endDate) ]) 108 } 109 110 } 111 112 def personsImmediateCallouts = { 113 result.taskInstanceList = getPersonsImmediateCallouts(params, result.person, result.startDate, result.endDate+1) 114 if(result.taskInstanceList.totalCount > 0) { 115 if(result.startDate == result.endDate) 116 result.message = getMessage(code:"task.search.text.persons.immediate.callouts.message", 117 args:[ result.person, formatted(result.startDate) ]) 118 else 119 result.message = getMessage(code:"task.search.text.persons.immediate.callouts.between.message", 120 args:[ result.person, formatted(result.startDate), formatted(result.endDate) ]) 121 } 122 else { 123 if(result.startDate == result.endDate) 124 result.message = getMessage(code:"task.search.text.persons.immediate.callouts.none.found", 125 args:[ result.person, formatted(result.startDate) ]) 126 else 127 result.message = getMessage(code:"task.search.text.persons.immediate.callouts.between.none.found", 128 args:[ result.person, formatted(result.startDate), formatted(result.endDate) ]) 129 } 130 41 131 } 42 132 43 133 switch (result.quickSearch) { 44 134 case "myTodays": 45 result.taskInstanceList = getPersonsTasks(params) 46 if(result.taskInstanceList.totalCount > 0) 47 result.message = getMessage(code:"task.search.text.persons.tasks.message", 48 args:[currentUser, formattedStartOfToday]) 49 else 50 result.message = getMessage(code:"task.search.text.persons.tasks.none.found", 51 args:[currentUser, formattedStartOfToday]) 135 result.quickSearch = "personsTasks" 136 result.startDate = startOfToday 137 result.endDate = startOfToday 138 personsTasks() 52 139 break 53 140 case "myYesterdays": 54 result.taskInstanceList = getPersonsTasks(params, currentUser, startOfYesterday, startOfToday) 55 if(result.taskInstanceList.totalCount > 0) 56 result.message = getMessage(code:"task.search.text.persons.tasks.message", 57 args:[currentUser, formattedStartOfYesterday]) 58 else 59 result.message = getMessage(code:"task.search.text.persons.tasks.none.found", 60 args:[currentUser, formattedStartOfYesterday]) 141 result.quickSearch = "personsTasks" 142 result.startDate = startOfYesterday 143 result.endDate = startOfYesterday 144 personsTasks() 61 145 break 62 146 case "myTomorrows": 63 result.taskInstanceList = getPersonsTasks(params, currentUser, startOfTomorrow, startOfTomorrow+1) 64 if(result.taskInstanceList.totalCount > 0) 65 result.message = getMessage(code:"task.search.text.persons.tasks.message", 66 args:[currentUser, formattedStartOfTomorrow]) 67 else 68 result.message = getMessage(code:"task.search.text.persons.tasks.none.found", 69 args:[currentUser, formattedStartOfTomorrow]) 147 result.quickSearch = "personsTasks" 148 result.startDate = startOfTomorrow 149 result.endDate = startOfTomorrow 150 personsTasks() 70 151 break 71 152 case "myPastWeek": 72 result.taskInstanceList = getPersonsTasks(params, currentUser, oneWeekAgo, startOfTomorrow) 73 if(result.taskInstanceList.totalCount > 0) 74 result.message = getMessage(code:"task.search.text.persons.tasks.between.message", 75 args:[currentUser, formattedOneWeekAgo, formattedStartOfToday]) 76 else 77 result.message = getMessage(code:"task.search.text.persons.tasks.between.none.found", 78 args:[currentUser, formattedOneWeekAgo, formattedStartOfToday]) 153 result.quickSearch = "personsTasks" 154 result.startDate = oneWeekAgo 155 result.endDate = startOfToday 156 personsTasks() 157 break 158 case "personsTasks": 159 personsTasks() 160 break 161 case "personsImmediateCallouts": 162 personsImmediateCallouts() 79 163 break 80 164 case "todays": 81 result.taskInstanceList = getTasks(params) 82 if(result.taskInstanceList.totalCount > 0) 83 result.message = getMessage(code:"task.search.text.all.tasks.message", 84 args:[formattedStartOfToday]) 85 else 86 result.message = getMessage(code:"task.search.text.all.tasks.none.found", 87 args:[formattedStartOfToday]) 165 result.quickSearch = "allTasks" 166 result.startDate = startOfToday 167 result.endDate = startOfToday 168 allTasks() 88 169 break 89 170 case "yesterdays": 90 result.taskInstanceList = getTasks(params, startOfYesterday, startOfToday) 91 if(result.taskInstanceList.totalCount > 0) 92 result.message = getMessage(code:"task.search.text.all.tasks.message", 93 args:[formattedStartOfYesterday]) 94 else 95 result.message = getMessage(code:"task.search.text.all.tasks.none.found", 96 args:[formattedStartOfYesterday]) 171 result.quickSearch = "allTasks" 172 result.startDate = startOfYesterday 173 result.endDate = startOfToday 174 allTasks() 97 175 break 98 176 case "tomorrows": 99 result.taskInstanceList = getTasks(params, startOfTomorrow, startOfTomorrow+1) 100 if(result.taskInstanceList.totalCount > 0) 101 result.message = getMessage(code:"task.search.text.all.tasks.message", 102 args:[formattedStartOfTomorrow]) 103 else 104 result.message = getMessage(code:"task.search.text.all.tasks.none.found", 105 args:[formattedStartOfTomorrow]) 177 result.quickSearch = "allTasks" 178 result.startDate = startOfTomorrow 179 result.endDate = startOfTomorrow+1 180 allTasks() 106 181 break 107 182 case "pastWeek": 108 result. taskInstanceList = getTasks(params, oneWeekAgo, startOfTomorrow)109 if(result.taskInstanceList.totalCount > 0)110 result.message = getMessage(code:"task.search.text.all.tasks.between.message",111 args:[formattedOneWeekAgo, formattedStartOfToday])112 else113 result.message = getMessage(code:"task.search.text.all.tasks.between.none.found",114 args:[formattedOneWeekAgo, formattedStartOfToday])183 result.quickSearch = "allTasks" 184 result.startDate = oneWeekAgo 185 result.endDate = startOfTomorrow 186 allTasks() 187 break 188 case "allTasks": 189 allTasks() 115 190 break 116 191 case "budgetUnplanned": 117 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(1), oneWeekAgo, startOfTomorrow) 118 if(result.taskInstanceList.totalCount > 0) 119 result.message = getMessage(code:"task.search.text.budget.unplanned.message", 120 args:[formattedOneWeekAgo, formattedStartOfToday]) 121 else 122 result.message = getMessage(code:"task.search.text.budget.unplanned.none.found", 123 args:[formattedOneWeekAgo, formattedStartOfToday]) 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 } 124 209 break 125 210 case "budgetPlanned": 126 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(2), oneWeekAgo, startOfTomorrow) 127 if(result.taskInstanceList.totalCount > 0) 128 result.message = getMessage(code:"task.search.text.budget.planned.message", 129 args:[formattedOneWeekAgo, formattedStartOfToday]) 130 else 131 result.message = getMessage(code:"task.search.text.budget.planned.none.found", 132 args:[formattedOneWeekAgo, formattedStartOfToday]) 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 } 133 228 break 134 229 default: 135 230 //case "plannersRange": 136 result.taskInstanceList = getTasks(params, oneWeekAgo, startOfToday+15) 137 if(result.taskInstanceList.totalCount > 0) 138 result.message = getMessage(code:"task.search.text.all.tasks.between.message", 139 args:[formattedOneWeekAgo, 140 g.formatDate(format: "EEE, dd-MMM-yyyy", date: startOfToday+14)]) 141 else 142 result.message = getMessage(code:"task.search.text.all.tasks.between.none.found", 143 args:[formattedOneWeekAgo, 144 g.formatDate(format: "EEE, dd-MMM-yyyy", date: startOfToday+14)]) 231 result.quickSearch = "allTasks" 232 result.startDate = oneWeekAgo 233 result.endDate = startOfToday+15 234 allTasks() 145 235 break 146 236 } // switch. … … 202 292 */ 203 293 def getPersonsTasks(params, person=null, startDate=null, endDate=null) { 204 def paginateParams = [:] 205 paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax)206 paginateParams.offset = params?.offset?.toInteger() ?: 0294 295 def max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 296 def offset = params?.offset?.toInteger() ?: 0 207 297 208 298 def orderBy = '' … … 212 302 def sort = "task." + params.sort 213 303 def order = (params.order == "asc") ? "asc" : "desc" 214 orderBy = " order by " + sort + ' ' + order 215 } 216 else 217 orderBy = " order by task.taskStatus, task.taskPriority, task.targetStartDate" 218 219 def namedParams = [:] 220 namedParams.person = person ?: authService.currentUser 221 namedParams.startDate = startDate ?: dateUtilService.today 222 namedParams.endDate = endDate ?: dateUtilService.tomorrow 223 224 def baseQuery = "from Task as task \ 225 left join task.assignedPersons as assignedPersonOfTask \ 226 left join assignedPersonOfTask.person as assignedPerson \ 227 left join task.assignedGroups as assignedGroupOfTask \ 228 left join assignedGroupOfTask.personGroup as personGroup \ 229 left join personGroup.persons as assignedPersonViaGroup \ 230 left join task.taskModifications as taskModification \ 231 left join taskModification.person as createdBy \ 232 left join taskModification.taskModificationType as taskModificationType \ 233 where (task.trash = false \ 234 and task.targetStartDate < :endDate \ 235 and task.targetCompletionDate >= :startDate \ 236 and ( \ 237 (taskModificationType.id = 1 \ 238 and createdBy = :person \ 239 and task.leadPerson = :person) \ 240 or ( \ 241 task.approved = true \ 242 and ( \ 243 task.leadPerson = :person \ 244 or assignedPerson = :person \ 245 or assignedPersonViaGroup = :person \ 246 ) \ 247 ) \ 248 ) \ 249 )" 250 251 def searchQuery = "select distinct task " + baseQuery + orderBy 252 def list = Task.executeQuery(searchQuery, namedParams, paginateParams) 253 254 def countQuery = "select count(distinct task) as taskCount " + baseQuery 255 def totalCount = Task.executeQuery(countQuery, namedParams)[0].toInteger() 304 orderBy = "by " + sort + ' ' + order 305 } 306 else 307 orderBy = "by task.taskStatus, task.taskPriority, task.targetStartDate" 308 309 def q = new HqlBuilder().query { 310 311 select 'count(distinct task) as taskCount' 312 from 'Task as task', 313 'left join task.assignedPersons as assignedPersonOfTask', 314 'left join assignedPersonOfTask.person as assignedPerson', 315 'left join task.assignedGroups as assignedGroupOfTask', 316 'left join assignedGroupOfTask.personGroup as personGroup', 317 'left join personGroup.persons as assignedPersonViaGroup', 318 'left join task.taskModifications as taskModification', 319 'left join taskModification.person as createdBy', 320 'left join taskModification.taskModificationType as taskModificationType' 321 where 'task.trash = false' 322 and 'task.targetStartDate < :endDate' 323 and 'task.targetCompletionDate >= :startDate' 324 if(!params.includeCompleted) { 325 and 'task.taskStatus.id != 3' // Complete. 326 } 327 and { 328 where '(taskModificationType.id = 1 and createdBy = :person and task.leadPerson = :person)' // Created. 329 or '(task.approved = true and (task.leadPerson = :person or assignedPerson = :person or assignedPersonViaGroup = :person))' 330 } 331 } 332 333 q.namedParams.person = person ?: authService.currentUser 334 q.namedParams.startDate = startDate ?: dateUtilService.today 335 q.namedParams.endDate = endDate ?: dateUtilService.tomorrow 336 337 def totalCount = Task.executeQuery(q.query, q.namedParams)[0].toInteger() 338 339 q.select = "distinct task" 340 q.order = orderBy 341 def list = Task.executeQuery(q.query, q.namedParams, q.paginateParams) 256 342 257 343 def taskInstanceList = new PagedResultList(list, totalCount) 258 344 return taskInstanceList 259 345 } // getPersonsTasks() 346 347 /** 348 * Get a person's immediateCallout tasks, by default all users and today's tasks. 349 * @param params The request params. 350 * @param person The person to get tasks for, defaults to null and therefore all immediateCallouts. 351 * @param startDate The start date to get tasks for, defaults to the start of today and is inclusive (greater than or equal to). 352 * @param endDate The end date to get tasks for, defaults to the start of tomorrow and is exclusive (less than). 353 */ 354 def getPersonsImmediateCallouts(params, person=null, startDate=null, endDate=null) { 355 356 def max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 357 def offset = params?.offset?.toInteger() ?: 0 358 359 def orderBy = '' 360 if(params.sort?.contains('.')) // protect against filterpane bug. 361 params.sort = null 362 if(params.sort && params.order) { 363 def sort = "task." + params.sort 364 def order = (params.order == "asc") ? "asc" : "desc" 365 orderBy = "by " + sort + ' ' + order 366 } 367 else 368 orderBy = "by task.taskStatus, task.taskPriority, task.targetStartDate" 369 370 def q = new HqlBuilder().query { 371 372 select 'count(distinct task) as taskCount' 373 from 'Task as task', 374 'left join task.taskModifications as taskModification', 375 'left join taskModification.person as createdBy', 376 'left join taskModification.taskModificationType as taskModificationType' 377 where 'task.taskType.id = 1' // Immediate Callout. 378 and 'task.targetStartDate < :endDate' 379 and 'task.targetCompletionDate >= :startDate' 380 if(!params.includeCompleted) { 381 and 'task.taskStatus.id != 3' // Complete. 382 } 383 if(person) { 384 namedParams.person = person 385 and '( (taskModificationType.id = 1 and createdBy = :person) or task.leadPerson = :person)' // Created or Lead Person. 386 } 387 and 'task.trash = false' 388 } 389 390 q.namedParams.startDate = startDate ?: dateUtilService.today 391 q.namedParams.endDate = endDate ?: dateUtilService.tomorrow 392 393 def totalCount = Task.executeQuery(q.query, q.namedParams)[0].toInteger() 394 395 q.select = "distinct task" 396 q.order = orderBy 397 def list = Task.executeQuery(q.query, q.namedParams, q.paginateParams) 398 399 def taskInstanceList = new PagedResultList(list, totalCount) 400 return taskInstanceList 401 } // getPersonsImmediateCallouts() 260 402 261 403 /** -
trunk/grails-app/views/taskDetailed/_quickSearchPane.gsp
r701 r713 2 2 <div class="overlayPane" id="searchPane" style="display:none;"> 3 3 <h2>Quick Search</h2> 4 <g:form method="post" id="searchForm" name="searchForm" > 4 5 <g:form method="post" controller="taskDetailed"> 5 6 <table> 6 7 <tbody> 7 8 8 9 <tr class="prop"> 9 <td valign="top" class="name"> 10 <label>My Tasks:</label> 11 </td> 10 <td valign="top" class="name">Select:</td> 12 11 <td valign="top" class="value"> 13 <g: link controller="taskDetailed"14 action="${actionName}"15 params="[quickSearch: 'myTodays']">16 <g:message code="task.search.text.my.todays" />17 </g:link> - <g:message code="task.search.text.my.todays.description" />18 <br />19 < g:link controller="taskDetailed"20 action="${actionName}" 21 params="[quickSearch: 'myYesterdays']">22 <g:message code="task.search.text.my.yesterdays" />23 </g:link>24 <br />25 <g:link controller="taskDetailed"26 action="${actionName}"27 params="[quickSearch: 'myTomorrows']">28 <g:message code="task.search.text.my.tomorrows" />29 </g:link>30 <br />31 <g:link controller="taskDetailed"32 action="${actionName}"33 params="[quickSearch: 'myPastWeek']">34 <g:message code="task.search.text.my.past.week" />35 </g:link>12 <g:select optionKey="key" 13 optionValue="value" 14 from="${quickSearchSelection}" 15 name="quickSearch" 16 id="quickSearchSelect" 17 value="${params.quickSearch}"> 18 </g:select> 19 20 <span id="allTasksHelp"> 21 <g:helpBalloon class="helpballoon" code="task.search.text.all.tasks" /> 22 </span> 23 <span id="budgetPlannedHelp"> 24 <g:helpBalloon class="helpballoon" code="task.search.text.budget.planned" /> 25 </span> 26 <span id="budgetUnplannedHelp"> 27 <g:helpBalloon class="helpballoon" code="task.search.text.budget.unplanned" /> 28 </span> 29 <span id="personsTasksHelp"> 30 <g:helpBalloon class="helpballoon" code="task.search.text.persons.tasks" /> 31 </span> 32 <span id="personsImmediateCalloutsHelp"> 33 <g:helpBalloon class="helpballoon" code="task.search.text.persons.immediate.callouts" /> 34 </span> 36 35 </td> 37 36 </tr> … … 39 38 <tr class="prop"> 40 39 <td valign="top" class="name"> 41 <label >All Tasks:</label>40 <label for="date">Between:</label> 42 41 </td> 43 42 <td valign="top" class="value"> 44 <g:link controller="taskDetailed" 45 action="${actionName}" 46 params="[quickSearch: 'todays']"> 47 <g:message code="task.search.text.todays" /> 48 </g:link> - <g:message code="task.search.text.todays.description" /> 49 <br /> 50 <g:link controller="taskDetailed" 51 action="${actionName}" 52 params="[quickSearch: 'yesterdays']"> 53 <g:message code="task.search.text.yesterdays" /> 54 </g:link> 55 <br /> 56 <g:link controller="taskDetailed" 57 action="${actionName}" 58 params="[quickSearch: 'tomorrows']"> 59 <g:message code="task.search.text.tomorrows" /> 60 </g:link> 61 <br /> 62 <g:link controller="taskDetailed" 63 action="${actionName}" 64 params="[quickSearch: 'pastWeek']"> 65 <g:message code="task.search.text.past.week" /> 66 </g:link> 67 <br /> 68 <g:link controller="taskDetailed" 69 action="${actionName}" 70 params="[quickSearch: 'plannersRange']"> 71 <g:message code="task.search.text.planners.range" /> 72 </g:link> - <g:message code="task.search.text.planners.range.description" /> 43 <richui:dateChooser name="startDate" format="dd-MM-yyyy" value="${params.startDate}" /> 44 and 45 <richui:dateChooser name="endDate" format="dd-MM-yyyy" value="${params.endDate}" /> 73 46 </td> 74 47 </tr> 75 48 76 <tr class="prop" >49 <tr class="prop" style="height:2.7em;"> 77 50 <td valign="top" class="name"> 78 <label >Budget:</label>51 <label for="person.id" id="personLabel">Person:</label> 79 52 </td> 80 53 <td valign="top" class="value"> 81 <g:link controller="taskDetailed" 82 action="${actionName}" 83 params="[quickSearch: 'budgetPlanned']"> 84 <g:message code="task.search.text.budget.planned" /> 85 </g:link> - <g:message code="task.search.text.budget.planned.description" /> 86 <br /> 87 <g:link controller="taskDetailed" 88 action="${actionName}" 89 params="[quickSearch: 'budgetUnplanned']"> 90 <g:message code="task.search.text.budget.unplanned" /> 91 </g:link> 54 <div id="personSelection"> 55 <g:select optionKey="id" 56 from="${Person.findAllByIsActive(true).sort { p1, p2 -> p1.firstName.compareToIgnoreCase(p2.firstName) }}" 57 name="person.id" 58 value="${params.person?.id}" 59 id="personSelector"> 60 </g:select> 61 </div> 92 62 </td> 93 63 </tr> 94 64 95 <tr class="prop" >65 <tr class="prop" style="height:2.7em;"> 96 66 <td valign="top" class="name"> 97 <label >Links:</label>67 <label for="includeCompleted" id="completedLabel">Incl. Completed:</label> 98 68 </td> 99 69 <td valign="top" class="value"> 100 <g:link controller="taskDetailed" 101 action="workDone"> 102 <g:message code="task.search.text.work.done" /> 103 </g:link> - <g:message code="task.search.text.work.done.description" /> 104 <br /> 105 <g:link controller="taskDetailed" 106 action="workLoad"> 107 <g:message code="task.search.text.work.load" /> 108 </g:link> - <g:message code="task.search.text.work.load.description" /> 70 <div id="completedSelection"> 71 <g:checkBox name="includeCompleted" 72 value="${params.includeCompleted}" 73 id="completedSelector"> 74 </g:checkBox> 75 <g:helpBalloon class="helpballoon" code="task.search.include.completed" /> 76 </div> 109 77 </td> 110 78 </tr> … … 112 80 </tbody> 113 81 </table> 82 114 83 <div class="buttons"> 115 84 <span class="button"> 85 <g:actionSubmit class="save" value="Update" action="${actionName}" /> 116 86 <g:actionSubmit class="cancel" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" /> 117 87 </span> 118 88 </div> 119 89 </g:form> 90 91 <table> 92 <tbody> 93 <tr class="prop"> 94 <td valign="top" class="name"> 95 <label>My Tasks:</label> 96 </td> 97 <td valign="top" class="value"> 98 <g:link controller="taskDetailed" 99 action="${actionName}" 100 params="[quickSearch: 'myTodays']"> 101 <g:message code="task.search.text.my.todays" /> 102 </g:link> - <g:message code="task.search.text.my.todays.description" /> 103 <br /> 104 </td> 105 </tr> 106 107 <tr class="prop"> 108 <td valign="top" class="name"> 109 <label>Links:</label> 110 </td> 111 <td valign="top" class="value"> 112 <g:link controller="taskDetailed" 113 action="workDone"> 114 <g:message code="task.search.text.work.done" /> 115 </g:link> - <g:message code="task.search.text.work.done.description" /> 116 <br /> 117 <g:link controller="taskDetailed" 118 action="workLoad"> 119 <g:message code="task.search.text.work.load" /> 120 </g:link> - <g:message code="task.search.text.work.load.description" /> 121 </td> 122 </tr> 123 124 </tbody> 125 </table> 126 120 127 </div> <!-- end search pane --> -
trunk/grails-app/views/taskDetailed/search.gsp
r615 r713 7 7 <nav:resources override="true"/> 8 8 <export:resource /> 9 <resource:dateChooser /> 10 <g:javascript src="taskQuickSearchPane.js" /> 9 11 </head> 10 12 <body> -
trunk/grails-app/views/taskDetailed/searchCalendar.gsp
r589 r713 8 8 <resource:calendarMonthView skin="calendarmonthviewCustom"/> 9 9 <export:resource /> 10 <resource:dateChooser /> 11 <g:javascript src="taskQuickSearchPane.js" /> 10 12 </head> 11 13 <body>
Note: See TracChangeset
for help on using the changeset viewer.