- Timestamp:
- Apr 7, 2010, 1:49:22 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r475 r476 2 2 import org.codehaus.groovy.grails.commons.ConfigurationHolder 3 3 import com.zeddware.grails.plugins.filterpane.FilterUtils 4 import org.springframework.web.servlet.support.RequestContextUtils as RCU 4 5 5 6 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) … … 35 36 36 37 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 38 def setSearchCalendarParamsMax = { 39 def max = 1000 40 if(params.newMax.isInteger()) { 41 def i = params.newMax.toInteger() 42 if(i > 0 && i <= max) 43 session.taskSearchCalendarParamsMax = params.newMax 44 if(i > max) 45 session.taskSearchCalendarParamsMax = max 46 } 47 forward(action: 'searchCalendar', params: params) 48 } 49 50 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 37 51 def search = { 38 52 … … 41 55 42 56 // Protect filterPane. 43 params.max = Math.min( params.max ? params.max.toInteger() : 10, 1000 )57 params.max = Math.min( params.max ? params.max.toInteger() : 20, 1000 ) 44 58 45 59 def taskInstanceList = [] 46 60 def taskInstanceTotal 47 def filterParams = [:] 48 def personInstance = authService.currentUser 49 50 // Quick Search: 51 if(!FilterUtils.isFilterApplied(params)) { 52 53 if(params.quickSearch == "searchMyTodays") { 54 taskInstanceList = taskSearchService.getMyTodays(params) 55 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks for ${personInstance.firstName} ${personInstance.lastName}." } 56 else { params.message = "No tasks found for today." } 57 } 58 else if(params.quickSearch == "searchInTheLastWeek") { 59 taskInstanceList = taskSearchService.getInTheLastWeek(params) 60 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." } 61 else { params.message = "No tasks found for the last week." } 62 } 63 else if(params.quickSearch == "searchMyInTheLastWeek") { 64 taskInstanceList = taskSearchService.getMyInTheLastWeek(params) 65 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." } 66 else { params.message = "No tasks found for the last week." } 67 } 68 else { 69 //Default: 70 taskInstanceList = taskSearchService.getTodays(params) 71 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks." } 72 else { params.message = "No tasks found for today." } 73 params.quickSearch = "searchTodays" 74 } 75 76 taskInstanceTotal = taskInstanceList.totalCount 77 filterParams.quickSearch = params.quickSearch 78 } 79 else { 61 def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 62 def isFilterApplied = FilterUtils.isFilterApplied(params) 63 64 // Restore search unless a new search is being requested. 65 if(!params.quickSearch && !filterParams) { 66 if(session.taskSearchQuickSearch) 67 params.quickSearch = session.taskSearchQuickSearch 68 else if(session.taskSearchFilterParams) { 69 session.taskSearchFilterParams.each() { params[it.key] = it.value } 70 params.filter = session.taskSearchFilter 71 isFilterApplied = FilterUtils.isFilterApplied(params) 72 } 73 } 74 75 if(isFilterApplied) { 80 76 // filterPane: 81 77 taskInstanceList = filterService.filter( params, Task ) 82 78 taskInstanceTotal = filterService.count( params, Task ) 83 79 filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 80 // Remember search. 81 session.taskSearchFilterParams = new LinkedHashMap(filterParams) 82 session.taskSearchFilter = new LinkedHashMap(params.filter) 83 session.taskSearchQuickSearch = null 84 } 85 else { 86 // Quick Search: 87 if(!params.quickSearch) params.quickSearch = "myTodays" 88 def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request)) 89 taskInstanceList = result.taskInstanceList 90 taskInstanceTotal = result.taskInstanceList.totalCount 91 params.message = result.message 92 filterParams.quickSearch = result.quickSearch 93 // Remember search. 94 session.taskSearchFilterParams = null 95 session.taskSearchFilter = null 96 session.taskSearchQuickSearch = result.quickSearch 84 97 } 85 98 … … 93 106 String title 94 107 if(params.quickSearch) 95 title = "${params.quickSearch} tasks."108 title = params.message 96 109 else 97 110 title = "Filtered tasks." … … 116 129 117 130 return[ taskInstanceList: taskInstanceList, 118 taskInstanceTotal: taskInstanceTotal, 119 filterParams: filterParams ] 120 121 } // end search() 131 taskInstanceTotal: taskInstanceTotal, 132 filterParams: filterParams, 133 params: params ] 134 135 } // search 122 136 123 137 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) 124 138 def searchCalendar = { 125 139 126 if(session.taskSearchParamsMax) 127 params.max = session.taskSearchParamsMax 140 // No pagination for calendar. 141 params.offset = 0 142 143 // Restore params.max 144 if(session.taskSearchCalendarParamsMax) 145 params.max = session.taskSearchCalendarParamsMax 128 146 129 147 // Protect filterPane. 130 params.max = Math.min( params.max ? params.max.toInteger() : 10 , 100)131 132 // Set the month to show.133 def showMonth = new Date()134 if(session.taskSearchCalendarShowMonth)135 showMonth = session.taskSearchCalendarShowMonth136 137 if(params.nextMonth)138 showMonth = dateUtilService.getNextMonth(showMonth)139 else if(params.previousMonth)140 showMonth = dateUtilService.getPreviousMonth(showMonth)141 session.taskSearchCalendarShowMonth = showMonth142 143 // Quick Search:144 if(!FilterUtils.isFilterApplied(params)) {145 def taskInstanceList = []146 def personInstance = authService.currentUser147 148 if(params.quickSearch == "searchMyTodays") {149 taskInstanceList = taskSearchService.getMyTodays(params)150 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks for ${personInstance.firstName} ${personInstance.lastName}." }151 else { params.message = "No tasks found for today." }152 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }153 }154 else if(params.quickSearch == "searchInTheLastWeek") {155 taskInstanceList = taskSearchService.getInTheLastWeek(params)156 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." }157 else { params.message = "No tasks found for the last week." }158 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown"}159 }160 else if(params.quickSearch == "searchMyInTheLastWeek") {161 taskInstanceList = taskSearchService.getMyInTheLastWeek(params) 162 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." }163 else { params.message = "No tasks found for the last week." }164 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" } 165 }166 else {167 //Default:168 taskInstanceList = taskSearchService.getTodays(params)169 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks." }170 else { params.message = "No tasks found for today." }171 if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }172 params.quickSearch = "searchTodays"173 }174 return[taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount, showMonth: showMonth, filterParams: params]175 }176 // filterPane:177 def taskInstanceTotal = filterService.count( params, Task)178 if(taskInstanceTotal > params.max) { params.message = "Too many results, only the first ${params.max} shown" }179 return[ taskInstanceList: filterService.filter( params, Task ),180 taskInstanceTotal: taskInstanceTotal,181 filterParams : com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),182 showMonth: showMonth,183 params:params ]184 }185 186 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser'])187 def budget = { 188 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100 )189 190 // Quick Search: 191 if(!FilterUtils.isFilterApplied(params)) {192 def taskInstanceList = []193 def personInstance = authService.currentUser194 195 if(params.quickSearch == "budgetUnplanned") {196 taskInstanceList = taskSearchService.getBudgetUnplanned(params)197 if(taskInstanceList.totalCount > 0) { params.message = "Budget unplanned tasks in the last week." }198 else { params.message = "No tasks found." }199 }200 //else if(params.quickSearch == "budgetPlanned") { 201 else {202 //Default:203 taskInstanceList = taskSearchService.getBudgetPlanned(params)204 if(taskInstanceList.totalCount > 0) { params.message = "Budget planned Tasks in the last week." }205 else { params.message = "No tasks found.." }206 }207 // export plugin:208 if(params?.format && params.format != "html") {209 210 def dateFmt = { date ->211 formatDate(format: "EEE, dd-MMM-yyyy", date: date)212 } 213 response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]214 response.setHeader("Content-disposition", "attachment; filename=tasks.${params.extension}")215 List fields = ["id", "targetStartDate", "description", "leadPerson", "taskStatus", "taskType"] 216 Map labels = ["id": "ID", "targetStartDate": "Target Start Date", "description": "Description",217 "leadPerson": "Lead Person", "taskStatus": "Task Status", "taskType": "Task Type"]218 Map formatters = [ targetStartDate: dateFmt]219 String title = "${params.quickSearch} tasks in the last week." 220 Map parameters = [title: title, separator: ","]221 222 exportService.export(params.format, response.outputStream, taskInstanceList, fields, labels, formatters, parameters)223 }224 return[taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount, filterParams: params]225 }226 // filterPane:227 return[ taskInstanceList: filterService.filter( params, Task ),228 taskInstanceTotal: filterService.count( params, Task ),229 filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),230 params:params ] 231 } 148 params.max = Math.min( params.max ? params.max.toInteger() : 100, 1000 ) 149 150 def taskInstanceList = [] 151 def taskInstanceTotal 152 def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 153 def isFilterApplied = FilterUtils.isFilterApplied(params) 154 155 // Restore search unless a new search is being requested. 156 if(!params.quickSearch && !filterParams) { 157 if(session.taskSearchCalendarQuickSearch) 158 params.quickSearch = session.taskSearchCalendarQuickSearch 159 else if(session.taskSearchCalendarFilterParams) { 160 session.taskSearchCalendarFilterParams.each() { params[it.key] = it.value } 161 params.filter = session.taskSearchCalendarFilter 162 isFilterApplied = FilterUtils.isFilterApplied(params) 163 } 164 } 165 166 // The date the calendar will use to determine the month to show. 167 // Use session, if not specified in params, otherwise use today. 168 def showDate = new Date() 169 if(params.showMonth) { 170 if(params.showYear) 171 showDate = dateUtilService.makeDate(params.showYear, params.showMonth) 172 else 173 showDate = dateUtilService.makeDate(dateUtilService.getYearFromDate(showDate), params.showMonth) 174 // Remember the showDate. 175 session.taskSearchCalendarShowDate = showDate 176 } 177 else if(session.taskSearchCalendarShowDate) 178 showDate = session.taskSearchCalendarShowDate 179 180 // Get the dates for the calendar month controls. 181 def calendarMonthControls = getCalendarMonthControls(showDate) 182 183 if(isFilterApplied) { 184 // filterPane: 185 taskInstanceList = filterService.filter( params, Task ) 186 taskInstanceTotal = filterService.count( params, Task ) 187 filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) 188 // Remember search. 189 session.taskSearchCalendarFilterParams = new LinkedHashMap(filterParams) 190 session.taskSearchCalendarFilter = new LinkedHashMap(params.filter) 191 session.taskSearchCalendarQuickSearch = null 192 } 193 else { 194 // Quick Search: 195 def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request)) 196 taskInstanceList = result.taskInstanceList 197 taskInstanceTotal = result.taskInstanceList.totalCount 198 params.message = result.message 199 filterParams.quickSearch = result.quickSearch 200 // Remember search. 201 session.taskSearchCalendarFilterParams = null 202 session.taskSearchCalendarFilter = null 203 session.taskSearchCalendarQuickSearch = result.quickSearch 204 } 205 206 // export plugin: 207 if(params?.format && params.format != "html") { 208 209 def dateFmt = { date -> 210 formatDate(format: "EEE, dd-MMM-yyyy", date: date) 211 } 212 213 String title 214 if(params.quickSearch) 215 title = params.message 216 else 217 title = "Filtered tasks." 218 219 response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] 220 response.setHeader("Content-disposition", "attachment; filename=Tasks.${params.extension}") 221 List fields = ["id", "targetStartDate", "description", "leadPerson", "taskPriority", "taskType", "taskStatus"] 222 Map labels = ["id": "ID", "targetStartDate": "Target Start Date", "description": "Description", 223 "leadPerson": "Lead Person", "taskPriority": "Task Priority", 224 "taskType": "Task Type", "taskStatus": "Task Status"] 225 Map formatters = [ targetStartDate: dateFmt] 226 Map parameters = [title: title, separator: ","] 227 228 exportService.export(params.format, response.outputStream, taskInstanceList, fields, labels, formatters, parameters) 229 } 230 231 if(taskInstanceTotal > params.max) 232 params.errorMessage = g.message(code:"task.search.calendar.text.too.many.results", args:[params.max]) 233 234 // Add some basic params to filterParams. 235 filterParams.max = params.max 236 filterParams.offset = params.offset?.toInteger() ?: 0 237 238 return[taskInstanceList: taskInstanceList, 239 taskInstanceTotal: taskInstanceTotal, 240 filterParams: filterParams, 241 params: params, 242 showDate: showDate, 243 today: calendarMonthControls.today, 244 previousMonth: calendarMonthControls.previousMonth, 245 nextMonth: calendarMonthControls.nextMonth, 246 previousYear: calendarMonthControls.previousYear, 247 nextYear: calendarMonthControls.nextYear] 248 249 } // searchCalendar 232 250 233 251 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) … … 559 577 560 578 // Set the targetStartDate if specified, used by searchCalendar view. 561 if(params.year && params.month && params.day) 562 taskInstance.targetStartDate = dateUtilService.makeDate(params.year, params.month, params.day) 579 if(params.year && params.month && params.day) { 580 def date = dateUtilService.makeDate(params.year, params.month, params.day) 581 taskInstance.targetStartDate = date 582 taskInstance.targetCompletionDate = date 583 } 563 584 564 585 // Default leadPerson to current user, unless supplied in params. … … 712 733 } 713 734 735 /** 736 * Get some integers for use by the month control links. 737 */ 738 private getCalendarMonthControls(Date showDate) { 739 def result = [:] 740 result.today = [:] 741 result.today.date = new Date() 742 result.today.month = dateUtilService.getMonthFromDate(result.today.date) 743 result.today.year = dateUtilService.getYearFromDate(result.today.date) 744 result.nextMonth = [:] 745 result.nextMonth.date = dateUtilService.getNextMonth(showDate) 746 result.nextMonth.month = dateUtilService.getMonthFromDate(result.nextMonth.date) 747 result.nextMonth.year = dateUtilService.getYearFromDate(result.nextMonth.date) 748 result.previousMonth = [:] 749 result.previousMonth.date = dateUtilService.getPreviousMonth(showDate) 750 result.previousMonth.month = dateUtilService.getMonthFromDate(result.previousMonth.date) 751 result.previousMonth.year = dateUtilService.getYearFromDate(result.previousMonth.date) 752 result.nextYear = [:] 753 result.nextYear.date = dateUtilService.getNextYear(showDate) 754 result.nextYear.month = dateUtilService.getMonthFromDate(result.nextYear.date) 755 result.nextYear.year = dateUtilService.getYearFromDate(result.nextYear.date) 756 result.previousYear = [:] 757 result.previousYear.date = dateUtilService.getPreviousYear(showDate) 758 result.previousYear.month = dateUtilService.getMonthFromDate(result.previousYear.date) 759 result.previousYear.year = dateUtilService.getYearFromDate(result.previousYear.date) 760 return result 761 } 762 714 763 } // end of class. -
trunk/grails-app/i18n/messages.properties
r468 r476 161 161 assignedPerson.task.not.found=Please select a task and then ''Add Assigned Person''. 162 162 163 default.close.text=Close164 default.options.text=Options165 default.none.text=None166 167 163 default.list.failure=Could not generate list for class {0}. 168 164 default.not.found={0} {1} not found, it may have been deleted. … … 196 192 197 193 default.paginate.prev=Previous 194 default.paginate.prev.abbrev=Prev 198 195 default.paginate.next=Next 196 197 default.close.text=Close 198 default.options.text=Options 199 default.none.text=None 199 200 200 201 # Rich UI plugin - Calendar … … 259 260 260 261 fp.property.text.inventoryItemPurchaseType.name=Type 262 263 # TaskSearch Service 264 task.search.text.my.todays=Today''s tasks for {0}. 265 task.search.text.my.todays.none.found=No tasks found for {0} today. 266 task.search.text.my.yesterdays=Yesterday''s tasks for {0}. 267 task.search.text.my.yesterdays.none.found=No tasks found for {0} yesterday. 268 task.search.text.my.tomorrows=Tomorrow''s tasks for {0}. 269 task.search.text.my.tomorrows.none.found=No tasks found for {0} tomorrow. 270 task.search.text.todays=Today's tasks. 271 task.search.text.todays.none.found=No tasks found for today. 272 task.search.text.yesterdays=Yesterday's tasks. 273 task.search.text.yesterdays.none.found=No tasks found for yesterday. 274 task.search.text.tomorrows=Tomorrow's tasks. 275 task.search.text.tomorrows.none.found=No tasks found for tomorrow. 276 task.search.text.past.week=Tasks with 'Target Start Date' in the past week. 277 task.search.text.past.week.none.found=No tasks found with 'Target Start Date' in the past week. 278 task.search.text.my.past.week=Tasks with ''Target Start Date'' in the past week for {0}. 279 task.search.text.my.past.week.none.found=No tasks found with ''Target Start Date'' in the past week for {0}. 280 task.search.text.budget.unplanned=Tasks with budget status of 'unplanned', in the past week. 281 task.search.text.budget.unplanned.none.found=No tasks found with budget status of 'unplanned', in the past week. 282 task.search.text.budget.planned=Tasks with budget status of 'planned', in the past week. 283 task.search.text.budget.planned.none.found=No tasks found with budget status of 'planned', in the past week. 284 task.search.text.planners.range=Planners Range - Tasks in the past week and two weeks ahead. 285 task.search.text.planners.range.none.found=No tasks found in the past week or two weeks ahead. 286 task.search.calendar.text.too.many.results=Too many results, only {0} are shown. -
trunk/grails-app/services/DateUtilService.groovy
r474 r476 99 99 100 100 /** 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. 104 */ 105 public static Date getNextYear(Date date) { 106 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 119 } 120 } 121 122 /** 101 123 * Make a date object from supplied year, month, day values. 102 124 * The Calendar.getInstance() or Calendar.instance factory returns a new calendar instance, usually … … 104 126 * The time fields are set to zero and cal.getTime() or cal.time returns a java.util.Date object. 105 127 * @param year The year as a string or integer. 106 * @param month The month as a string or integer .107 * @param day The day as a string or integer .128 * @param month The month as a string or integer, defaults to 1 (i.e. January). 129 * @param day The day as a string or integer, defaults to 1. 108 130 * @returns A Date object having the given date and all time fields set to 0, so the very start of the given day. 109 131 */ 110 public static Date makeDate(year, month , day) {132 public static Date makeDate(year, month=1, day=1) { 111 133 Calendar cal = Calendar.instance 112 134 cal.clear() … … 116 138 } 117 139 140 /** 141 * Get the day of month from supplied date. 142 * @param date The date to extract the day of month from. 143 * @returns An integer representing the day of the month. 144 */ 145 public static Integer getDayFromDate(Date date) { 146 Calendar cal = Calendar.instance 147 cal.setTime(date) 148 cal.get(Calendar.DAY_OF_MONTH) 149 } 150 151 /** 152 * Get the month from supplied date. 153 * @param date The date to extract the month from. 154 * @returns An integer representing the month. 155 */ 156 public static Integer getMonthFromDate(Date date) { 157 Calendar cal = Calendar.instance 158 cal.setTime(date) 159 cal.get(Calendar.MONTH) + 1 // Stupid month is 0-based, grumble. 160 } 161 162 /** 163 * Get the year from supplied date. 164 * @param date The date to extract the year from. 165 * @returns An integer representing the year. 166 */ 167 public static Integer getYearFromDate(Date date) { 168 Calendar cal = Calendar.instance 169 cal.setTime(date) 170 cal.get(Calendar.YEAR) 171 } 172 118 173 } -
trunk/grails-app/services/TaskSearchService.groovy
r419 r476 1 /** 2 * Service class that encapsulates the business logic for Task searches. 3 */ 1 4 class TaskSearchService { 2 5 3 6 boolean transactional = false 4 7 8 def authService 5 9 def dateUtilService 6 def authenticateService 7 8 def paramsMax = 99999 9 10 def getTodays(params) { 11 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 12 params.offset = params?.offset?.toInteger() ?: 0 13 params.sort = params?.sort ?: "attentionFlag" 14 params.order = params?.order ?: "desc" 15 16 def taskInstanceList = Task.createCriteria().list( 17 max: params.max, 18 offset: params.offset, 19 sort: params.sort, 20 order: params.order) { 21 ge("targetStartDate", dateUtilService.today) 22 lt("targetStartDate", dateUtilService.getTomorrow()) 23 eq("trash", false) 24 } 25 } 26 27 def getMyTodays(params) { 28 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 29 params.offset = params?.offset?.toInteger() ?: 0 30 params.sort = params?.sort ?: "attentionFlag" 31 params.order = params?.order ?: "desc" 32 33 def taskInstanceList = Task.createCriteria().list( 34 max: params.max, 35 offset: params.offset, 36 sort: params.sort, 37 order: params.order) { 38 eq("leadPerson", Person.get(authenticateService.userDomain().id)) 39 ge("targetStartDate", dateUtilService.today) 40 lt("targetStartDate", dateUtilService.getTomorrow()) 41 eq("trash", false) 42 } 43 } 44 45 def getInTheLastWeek(params) { 46 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 47 params.offset = params?.offset?.toInteger() ?: 0 48 params.sort = params?.sort ?: "attentionFlag" 49 params.order = params?.order ?: "desc" 50 51 def taskInstanceList = Task.createCriteria().list( 52 max: params.max, 53 offset: params.offset, 54 sort: params.sort, 55 order: params.order) { 56 ge("targetStartDate", dateUtilService.oneWeekAgo) 57 lt("targetStartDate", dateUtilService.getTomorrow()) 58 eq("trash", false) 59 } 60 } 61 62 def getMyInTheLastWeek(params) { 63 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 64 params.offset = params?.offset?.toInteger() ?: 0 65 params.sort = params?.sort ?: "attentionFlag" 66 params.order = params?.order ?: "desc" 67 68 def taskInstanceList = Task.createCriteria().list( 69 max: params.max, 70 offset: params.offset, 71 sort: params.sort, 72 order: params.order) { 73 eq("leadPerson", Person.get(authenticateService.userDomain().id)) 74 ge("targetStartDate", dateUtilService.oneWeekAgo) 75 lt("targetStartDate", dateUtilService.getTomorrow()) 76 eq("trash", false) 77 } 78 } 10 def messageSource 11 12 def paramsMax = 100000 13 14 /** 15 * Selects and returns the correct search results based on the supplied quickSearch. 16 * @param params The request params, may contain params.quickSearch string to specify the search. 17 * @param locale The locale to use when generating result.message. 18 */ 19 def getQuickSearch(params, locale) { 20 def result = [:] 21 def currentUser = authService.currentUser 22 result.quickSearch = params.quickSearch ?: "searchPlannersRange" 23 24 def getMessage = { Map m -> 25 messageSource.getMessage(m.code, m.args == null ? null : m.args.toArray(), locale) 26 } 27 28 switch (result.quickSearch) { 29 case "myTodays": 30 result.taskInstanceList = getMyTodays(params) 31 if(result.taskInstanceList.totalCount > 0) 32 result.message = getMessage(code:"task.search.text.my.todays", args:[currentUser]) 33 else 34 result.message = getMessage(code:"task.search.text.my.todays.none.found", args:[currentUser]) 35 break 36 case "myYesterdays": 37 result.taskInstanceList = getMyTodays(params, -1) 38 if(result.taskInstanceList.totalCount > 0) 39 result.message = getMessage(code:"task.search.text.my.yesterdays", args:[currentUser]) 40 else 41 result.message = getMessage(code:"task.search.text.my.yesterdays.none.found", args:[currentUser]) 42 break 43 case "myTomorrows": 44 result.taskInstanceList = getMyTodays(params, 1) 45 if(result.taskInstanceList.totalCount > 0) 46 result.message = getMessage(code:"task.search.text.my.tomorrows", args:[currentUser]) 47 else 48 result.message = getMessage(code:"task.search.text.my.tomorrows.none.found", args:[currentUser]) 49 break 50 case "myPastWeek": 51 result.taskInstanceList = getMyPastWeek(params) 52 if(result.taskInstanceList.totalCount > 0) 53 result.message = getMessage(code:"task.search.text.my.past.week", args:[currentUser]) 54 else 55 result.message = getMessage(code:"task.search.text.my.past.week.none.found", args:[currentUser]) 56 break 57 case "todays": 58 result.taskInstanceList = getTodays(params) 59 if(result.taskInstanceList.totalCount > 0) 60 result.message = getMessage(code:"task.search.text.todays") 61 else 62 result.message = getMessage(code:"task.search.text.todays.none.found") 63 break 64 case "yesterdays": 65 result.taskInstanceList = getTodays(params, -1) 66 if(result.taskInstanceList.totalCount > 0) 67 result.message = getMessage(code:"task.search.text.yesterdays") 68 else 69 result.message = getMessage(code:"task.search.text.yesterdays.none.found") 70 break 71 case "tomorrows": 72 result.taskInstanceList = getTodays(params, 1) 73 if(result.taskInstanceList.totalCount > 0) 74 result.message = getMessage(code:"task.search.text.tomorrows") 75 else 76 result.message = getMessage(code:"task.search.text.tomorrows.none.found") 77 break 78 case "pastWeek": 79 result.taskInstanceList = getPastWeek(params) 80 if(result.taskInstanceList.totalCount > 0) 81 result.message = getMessage(code:"task.search.text.past.week") 82 else 83 result.message = getMessage(code:"task.search.text.past.week.none.found") 84 break 85 case "budgetUnplanned": 86 result.taskInstanceList = getBudgetUnplanned(params) 87 if(result.taskInstanceList.totalCount > 0) 88 result.message = getMessage(code:"task.search.text.budget.unplanned") 89 else 90 result.message = getMessage(code:"task.search.text.budget.unplanned.none.found") 91 break 92 case "budgetPlanned": 93 result.taskInstanceList = getBudgetPlanned(params) 94 if(result.taskInstanceList.totalCount > 0) 95 result.message = getMessage(code:"task.search.text.budget.planned") 96 else 97 result.message = getMessage(code:"task.search.text.budget.planned.none.found") 98 break 99 default: 100 result.taskInstanceList = getPlannersRange(params) 101 if(result.taskInstanceList.totalCount > 0) 102 result.message = getMessage(code:"task.search.text.planners.range") 103 else 104 result.message = getMessage(code:"task.search.text.planners.range.none.found") 105 break 106 } // switch. 107 108 // Success. 109 return result 110 111 } // getQuickSearch 112 113 def getTodays(params, dayAdjustment=0) { 114 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 115 params.offset = params?.offset?.toInteger() ?: 0 116 params.sort = params?.sort ?: "attentionFlag" 117 params.order = params?.order ?: "desc" 118 119 def taskInstanceList = Task.createCriteria().list( 120 max: params.max, 121 offset: params.offset, 122 sort: params.sort, 123 order: params.order) { 124 ge("targetStartDate", dateUtilService.today+dayAdjustment) 125 lt("targetStartDate", dateUtilService.tomorrow+dayAdjustment) 126 eq("trash", false) 127 } 128 } 129 130 def getMyTodays(params, dayAdjustment=0) { 131 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 132 params.offset = params?.offset?.toInteger() ?: 0 133 params.sort = params?.sort ?: "attentionFlag" 134 params.order = params?.order ?: "desc" 135 136 def currentUser = authService.currentUser 137 138 def taskInstanceList = Task.createCriteria().list( 139 max: params.max, 140 offset: params.offset, 141 sort: params.sort, 142 order: params.order) { 143 ge("targetStartDate", dateUtilService.today+dayAdjustment) 144 lt("targetStartDate", dateUtilService.tomorrow+dayAdjustment) 145 eq("trash", false) 146 eq("approved", true) 147 or { 148 eq("leadPerson", currentUser) 149 assignedPersons { 150 eq("person", currentUser) 151 } 152 assignedGroups { 153 currentUser.personGroups.each() { 154 eq("personGroup", it) 155 } 156 } // assignedGroups 157 } // or 158 } // criteria 159 } // getMyTodays 160 161 def getPastWeek(params) { 162 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 163 params.offset = params?.offset?.toInteger() ?: 0 164 params.sort = params?.sort ?: "attentionFlag" 165 params.order = params?.order ?: "desc" 166 167 def taskInstanceList = Task.createCriteria().list( 168 max: params.max, 169 offset: params.offset, 170 sort: params.sort, 171 order: params.order) { 172 ge("targetStartDate", dateUtilService.oneWeekAgo) 173 lt("targetStartDate", dateUtilService.tomorrow) 174 eq("trash", false) 175 } 176 } 177 178 def getMyPastWeek(params) { 179 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 180 params.offset = params?.offset?.toInteger() ?: 0 181 params.sort = params?.sort ?: "attentionFlag" 182 params.order = params?.order ?: "desc" 183 184 def currentUser = authService.currentUser 185 186 def taskInstanceList = Task.createCriteria().list( 187 max: params.max, 188 offset: params.offset, 189 sort: params.sort, 190 order: params.order) { 191 ge("targetStartDate", dateUtilService.oneWeekAgo) 192 lt("targetStartDate", dateUtilService.tomorrow) 193 eq("trash", false) 194 eq("approved", true) 195 or { 196 eq("leadPerson", currentUser) 197 assignedPersons { 198 eq("person", currentUser) 199 } 200 assignedGroups { 201 currentUser.personGroups.each() { 202 eq("personGroup", it) 203 } 204 } // assignedGroups 205 } // or 206 } // criteria 207 } // getMyPastWeek 79 208 80 209 def getBudgetPlanned(params) { 81 210 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 82 211 params.offset = params?.offset?.toInteger() ?: 0 83 params.sort = params?.sort ?: " attentionFlag"84 params.order = params?.order ?: " desc"212 params.sort = params?.sort ?: "targetStartDate" 213 params.order = params?.order ?: "asc" 85 214 86 215 def taskInstanceList = Task.createCriteria().list( … … 89 218 sort: params.sort, 90 219 order: params.order) { 91 eq("taskBudgetStatus", TaskBudgetStatus. get(2))220 eq("taskBudgetStatus", TaskBudgetStatus.read(2)) 92 221 ge("targetStartDate", dateUtilService.oneWeekAgo) 93 222 lt("targetStartDate", dateUtilService.tomorrow) … … 99 228 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 100 229 params.offset = params?.offset?.toInteger() ?: 0 101 params.sort = params?.sort ?: " attentionFlag"102 params.order = params?.order ?: " desc"230 params.sort = params?.sort ?: "targetStartDate" 231 params.order = params?.order ?: "asc" 103 232 104 233 def taskInstanceList = Task.createCriteria().list( … … 107 236 sort: params.sort, 108 237 order: params.order) { 109 eq("taskBudgetStatus", TaskBudgetStatus.get(1)) 110 ge("targetStartDate", dateUtilService.oneWeekAgo) 111 lt("targetStartDate", dateUtilService.getTomorrow()) 238 eq("taskBudgetStatus", TaskBudgetStatus.read(1)) 239 ge("targetStartDate", dateUtilService.oneWeekAgo) 240 lt("targetStartDate", dateUtilService.tomorrow) 241 eq("trash", false) 242 } 243 } 244 245 def getPlannersRange(params) { 246 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 247 params.offset = params?.offset?.toInteger() ?: 0 248 params.sort = params?.sort ?: "targetStartDate" 249 params.order = params?.order ?: "asc" 250 251 def taskInstanceList = Task.createCriteria().list( 252 max: params.max, 253 offset: params.offset, 254 sort: params.sort, 255 order: params.order) { 256 ge("targetStartDate", dateUtilService.oneWeekAgo) 257 lt("targetStartDate", dateUtilService.today + 15) 112 258 eq("trash", false) 113 259 } -
trunk/grails-app/views/appCore/manager.gsp
r165 r476 33 33 <td valign="top" class="value"> 34 34 <g:link controller="taskDetailed" 35 action=" budget"35 action="search" 36 36 params="[quickSearch: 'budgetPlanned']"> 37 37 Planned Tasks … … 39 39 <br /> 40 40 <g:link controller="taskDetailed" 41 action=" budget"41 action="search" 42 42 params="[quickSearch: 'budgetUnplanned']"> 43 43 Unplanned Tasks -
trunk/grails-app/views/appCore/start.gsp
r155 r476 47 47 <g:link controller="taskDetailed" 48 48 action="search" 49 params="[quickSearch: 'searchMyTodays']"> 50 Today's 51 </g:link> 52 <br /> 53 <g:link controller="taskDetailed" 54 action="search" 55 params="[quickSearch: 'searchMyInTheLastWeek']"> 56 In the last week 49 params="[quickSearch: 'myTodays']"> 50 Today 57 51 </g:link> 58 52 </td> … … 61 55 <tr class="prop"> 62 56 <td valign="top" class="name"> 63 <label> Tasks:</label>57 <label>All Tasks:</label> 64 58 </td> 65 59 <td valign="top" class="value"> 66 60 <g:link controller="taskDetailed" 61 action="search" 62 params="[quickSearch: 'pastWeek']"> 63 Past Week 64 </g:link> 65 <br /> 66 <g:link controller="taskDetailed" 67 67 action="searchCalendar" 68 params="[quickSearch: 'search InTheLastWeek']">68 params="[quickSearch: 'searchPlannersRange']"> 69 69 Calendar 70 70 </g:link> -
trunk/grails-app/views/taskDetailed/search.gsp
r467 r476 15 15 <div class="body"> 16 16 <g:render template="/shared/messages" /> 17 <g:if test="${params.message}">18 <div class="message">${params.message}</div>19 </g:if>20 17 <g:hasErrors bean="${appCore}"> 21 18 <div class="errors"> … … 142 139 </g:if> 143 140 <div class="paginateButtons"> 144 <g:paginate total="${taskInstanceTotal}" params="${filterParams}" />141 <g:paginate action="search" total="${taskInstanceTotal}" params="${filterParams}" /> 145 142 </div> 146 143 … … 169 166 targetStartDate:[years:2020..2000,precision:'day'] 170 167 ]}"/> 168 169 <g:render template="quickSearchPane" /> 170 171 171 </div> <!-- end body --> 172 173 <!-- Start Search Pane -->174 <div class="overlayPane" id="searchPane" style="display:none;">175 <h2>Quick Search</h2>176 <g:form method="post" id="searchForm" name="searchForm" >177 <table>178 <tbody>179 180 <tr class="prop">181 <td valign="top" class="name">182 <label>My Tasks:</label>183 </td>184 <td valign="top" class="value">185 <g:link controller="taskDetailed"186 action="search"187 params="[quickSearch: 'searchMyTodays']">188 Today's189 </g:link>190 <br />191 <g:link controller="taskDetailed"192 action="search"193 params="[quickSearch: 'searchMyInTheLastWeek']">194 In the last week195 </g:link>196 </td>197 </tr>198 199 <tr class="prop">200 <td valign="top" class="name">201 <label>Tasks:</label>202 </td>203 <td valign="top" class="value">204 <g:link controller="taskDetailed"205 action="search"206 params="[quickSearch: 'searchTodays']">207 Today's208 </g:link>209 <br />210 <g:link controller="taskDetailed"211 action="search"212 params="[quickSearch: 'searchInTheLastWeek']">213 In the last week214 </g:link>215 </td>216 </tr>217 218 </tbody>219 </table>220 <div class="buttons">221 <span class="button">222 <input type="button" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" />223 </span>224 </div>225 </g:form>226 </div> <!-- end search pane -->227 228 172 </body> 229 173 </html> -
trunk/grails-app/views/taskDetailed/searchCalendar.gsp
r474 r476 3 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 4 4 <meta name="layout" content="main" /> 5 <title>Task Search </title>5 <title>Task Search Calendar</title> 6 6 <filterpane:includes /> 7 7 <nav:resources override="true"/> 8 <resource:calendarMonthView /> 8 <resource:calendarMonthView skin="calendarmonthviewCustom"/> 9 <export:resource /> 9 10 </head> 10 11 <body> … … 14 15 15 16 <div class="body"> 16 <g:if test="${params.message}">17 <div class="message">${params.message}</div>18 </g:if>19 17 <g:render template="/shared/messages" /> 20 <g:hasErrors bean="${appCore}"> 21 <div class="errors"> 22 <g:renderErrors bean="${appCore}" as="list" /> 23 </div> 24 </g:hasErrors> 18 25 19 <filterpane:currentCriteria domainBean="Task" 26 20 action="searchCalendar" … … 41 35 </div> 42 36 43 <br /> 44 <g:link action="searchCalendar" params="[previousMonth:'true']"> 45 < Previous 46 </g:link> 47 <span style="font-size: 17px; font-weight: bold;"> 48 <g:formatDate date="${showMonth}" format="MMMM"/> 49 </span> 50 <g:link action="searchCalendar" params="[nextMonth:'true']"> 51 Next > 52 </g:link> 53 <br /> 37 <jsUtil:toggleControl toggleId="options" 38 imageId="optionsImg" 39 closedImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_right.png')}" 40 openImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_down.png')}" 41 text="${g.message(code: 'default.options.text')}" 42 /> 43 44 <div id="options" style="display:none;"> 45 <g:form method="post" > 46 <g:hiddenField name="params" value="${filterParams}" /> 47 <div class="dialog"> 48 <table> 49 <tbody> 50 51 <tr class="prop"> 52 <td valign="top" class="name"> 53 <label for="max">Results per page:</label> 54 </td> 55 <td valign="top" class="value"> 56 <input type="text" maxlength="4" id="description" name="newMax" value="${params.max}"/> 57 58 <span class="buttons"> 59 <g:actionSubmit action="setSearchCalendarParamsMax" class="go" value="Update" /> 60 </span> 61 </td> 62 </tr> 63 64 </tbody> 65 </table> 66 </div> 67 <export:formats params="${filterParams}" formats="['csv', 'excel', 'pdf', 'rtf']"/> 68 </g:form> 69 </div> 70 54 71 <br /> 55 72 56 73 <g:if test="${taskInstanceList.size() > 0}"> 74 <div class="paginateButtons"> 75 <g:link action="searchCalendar" 76 params="[showMonth: previousYear.month, showYear: previousYear.year]"> 77 << 78 </g:link> 79 <g:link action="searchCalendar" 80 params="[showMonth: previousMonth.month, showYear: previousMonth.year]"> 81 < 82 </g:link> 83 <span class="calendarMonthControlTitle"> 84 <g:formatDate date="${showDate}" format="MMMM, yyyy"/> 85 </span> 86 <g:link action="searchCalendar" 87 params="[showMonth: nextMonth.month, showYear: nextMonth.year]"> 88 > 89 </g:link> 90 <g:link action="searchCalendar" 91 params="[showMonth: nextYear.month, showYear: nextYear.year]"> 92 >> 93 </g:link> 94 </div> 95 <div> 96 <g:link action="searchCalendar" 97 params="[showMonth: today.month, showYear: today.year]"> 98 Today: <g:formatDate date="${today.date}" format="MMMM, yyyy"/> 99 </g:link> 100 </div> 101 <br /> 102 57 103 <richui:calendarMonthView items="${taskInstanceList}" 58 104 createLink="true" 59 105 constraintDateFields="['targetStartDate']" 60 month="${show Month}"106 month="${showDate}" 61 107 controller="taskDetailed" 62 108 action="show" … … 70 116 additionalProperties="id" 71 117 excludeProperties="trash, comment, targetCompletionDate" 72 associatedProperties="leadPerson.lastName, taskPriority.name"118 associatedProperties="leadPerson.lastName, leadPerson.firstName, taskPriority.name" 73 119 filterPropertyValues="${['taskPriority.name':[values:TaskPriority.list()], 74 120 'leadPerson.lastName':[values:Person.executeQuery('select t.lastName from Person t')], 121 'leadPerson.firstName':[values:Person.executeQuery('select distinct t.firstName from Person t')], 75 122 targetStartDate:[years:2020..2000,precision:'day']]}"/> 76 123 124 <g:render template="quickSearchPane" /> 125 77 126 </div> <!-- end body div --> 78 79 <!-- Start Search Pane -->80 <div class="overlayPane" id="searchPane" style="display:none;">81 <h2>Quick Search</h2>82 <g:form method="post" id="searchForm" name="searchForm" >83 <table>84 <tbody>85 86 <tr class="prop">87 <td valign="top" class="name">88 <label>My Tasks:</label>89 </td>90 <td valign="top" class="value">91 <g:link controller="taskDetailed"92 action="searchCalendar"93 params="[quickSearch: 'searchMyTodays']">94 Today's95 </g:link>96 <br />97 <g:link controller="taskDetailed"98 action="searchCalendar"99 params="[quickSearch: 'searchMyInTheLastWeek']">100 In the last week101 </g:link>102 </td>103 </tr>104 105 <tr class="prop">106 <td valign="top" class="name">107 <label>Tasks:</label>108 </td>109 <td valign="top" class="value">110 <g:link controller="taskDetailed"111 action="searchCalendar"112 params="[quickSearch: 'searchTodays']">113 Today's114 </g:link>115 <br />116 <g:link controller="taskDetailed"117 action="searchCalendar"118 params="[quickSearch: 'searchInTheLastWeek']">119 In the last week120 </g:link>121 </td>122 </tr>123 124 </tbody>125 </table>126 <div class="buttons">127 <span class="button">128 <input type="button" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" />129 </span>130 </div>131 </g:form>132 </div> <!-- end search pane -->133 134 127 </body> 135 128 </html>
Note: See TracChangeset
for help on using the changeset viewer.