Changeset 196 for trunk/grails-app
- Timestamp:
- Nov 24, 2009, 7:57:30 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r190 r196 14 14 static allowedMethods = [save:'POST', update:'POST', restore:'POST', trash:'POST', approve:'POST', renegeApproval:'POST', complete:'POST', reopen:'POST'] 15 15 16 def index = { redirect(action: search,params:params) }16 def index = { redirect(action: 'search', params: params) } 17 17 18 18 def list = { … … 163 163 if(!taskInstance) { 164 164 flash.message = "Task not found with id ${params.id}" 165 redirect(action: search)165 redirect(action: 'search') 166 166 } 167 167 else { … … 180 180 } 181 181 182 def subTaskInstanceList = Task.findAllByParentTask (taskInstance, params)183 def subTaskInstanceTotal = Task.countByParentTask (taskInstance)182 def subTaskInstanceList = Task.findAllByParentTaskAndTrash(taskInstance, false, params) 183 def subTaskInstanceTotal = Task.countByParentTaskAndTrash(taskInstance, false) 184 184 def showTaskTab = new String("true") 185 185 … … 225 225 if(!Task.exists(params.id)) { 226 226 flash.message = "Task not found with id ${params.id}" 227 redirect(action: 'search')227 redirect(action: 'search') 228 228 } 229 229 … … 232 232 if(!result.error) { 233 233 flash.message = "Task ${params.id} has been restored." 234 redirect(action: show,id:result.taskInstance.id)235 } 236 else { 237 if(result.taskInstance) { 238 render(view:'edit',model:[taskInstance:result.taskInstance]) 239 } 240 else { 241 flash.message = "Task could not be updated." 242 redirect(action: 'search')234 redirect(action: 'show', id: result.taskInstance.id) 235 } 236 else { 237 if(result.taskInstance) { 238 render(view:'edit',model:[taskInstance:result.taskInstance]) 239 } 240 else { 241 flash.message = "Task could not be updated." 242 redirect(action: 'search') 243 243 } 244 244 } … … 250 250 if(!Task.exists(params.id)) { 251 251 flash.message = "Task not found with id ${params.id}." 252 redirect(action: 'search')252 redirect(action: 'search') 253 253 } 254 254 … … 257 257 if(!result.error) { 258 258 flash.message = "Task ${params.id} has been moved to trash." 259 redirect(action: 'search')260 } 261 else { 262 if(result.taskInstance) { 263 render(view:'edit',model:[taskInstance:result.taskInstance]) 264 } 265 else { 266 flash.message = "Task could not be updated." 267 redirect(action: 'search')259 redirect(action: 'search') 260 } 261 else { 262 if(result.taskInstance) { 263 render(view:'edit',model:[taskInstance:result.taskInstance]) 264 } 265 else { 266 flash.message = "Task could not be updated." 267 redirect(action: 'search') 268 268 } 269 269 } … … 275 275 if(!Task.exists(params.id)) { 276 276 flash.message = "Task not found with id ${params.id}." 277 redirect(action: 'search')277 redirect(action: 'search') 278 278 } 279 279 … … 282 282 if(!result.error) { 283 283 flash.message = "Task ${params.id} has been approved." 284 redirect(action: show,id:result.taskInstance.id)285 } 286 else { 287 if(result.taskInstance) { 288 render(view:'edit',model:[taskInstance:result.taskInstance]) 289 } 290 else { 291 flash.message = "Task could not be updated." 292 redirect(action: 'search')284 redirect(action: 'show', id: result.taskInstance.id) 285 } 286 else { 287 if(result.taskInstance) { 288 render(view:'edit',model:[taskInstance:result.taskInstance]) 289 } 290 else { 291 flash.message = "Task could not be updated." 292 redirect(action: 'search') 293 293 } 294 294 } … … 300 300 if(!Task.exists(params.id)) { 301 301 flash.message = "Task not found with id ${params.id}." 302 redirect(action: 'search')302 redirect(action: 'search') 303 303 } 304 304 … … 307 307 if(!result.error) { 308 308 flash.message = "Task ${params.id} has had approval removed." 309 redirect(action: show,id:result.taskInstance.id)310 } 311 else { 312 if(result.taskInstance) { 313 render(view:'edit',model:[taskInstance:result.taskInstance]) 314 } 315 else { 316 flash.message = "Task could not be updated." 317 redirect(action: 'search')309 redirect(action: 'show', id: result.taskInstance.id) 310 } 311 else { 312 if(result.taskInstance) { 313 render(view:'edit',model:[taskInstance:result.taskInstance]) 314 } 315 else { 316 flash.message = "Task could not be updated." 317 redirect(action: 'search') 318 318 } 319 319 } … … 325 325 if(!Task.exists(params.id)) { 326 326 flash.message = "Task not found with id ${params.id}." 327 redirect(action: 'search')327 redirect(action: 'search') 328 328 } 329 329 … … 332 332 if(!result.error) { 333 333 flash.message = "Task ${params.id} has been completed." 334 redirect(action: show,id:result.taskInstance.id)335 } 336 else { 337 if(result.taskInstance) { 338 render(view:'edit',model:[taskInstance:result.taskInstance]) 339 } 340 else { 341 flash.message = "Task could not be updated." 342 redirect(action: 'search')334 redirect(action: 'show', id: result.taskInstance.id) 335 } 336 else { 337 if(result.taskInstance) { 338 render(view:'edit',model:[taskInstance:result.taskInstance]) 339 } 340 else { 341 flash.message = "Task could not be updated." 342 redirect(action: 'search') 343 343 } 344 344 } … … 350 350 if(!Task.exists(params.id)) { 351 351 flash.message = "Task not found with id ${params.id}." 352 redirect(action: 'search')352 redirect(action: 'search') 353 353 } 354 354 … … 357 357 if(!result.error) { 358 358 flash.message = "Task ${params.id} has been reopened." 359 redirect(action: show,id:result.taskInstance.id)360 } 361 else { 362 if(result.taskInstance) { 363 render(view:'edit',model:[taskInstance:result.taskInstance]) 364 } 365 else { 366 flash.message = "Task could not be updated." 367 redirect(action: 'search')359 redirect(action: 'show', id: result.taskInstance.id) 360 } 361 else { 362 if(result.taskInstance) { 363 render(view:'edit',model:[taskInstance:result.taskInstance]) 364 } 365 else { 366 flash.message = "Task could not be updated." 367 redirect(action: 'search') 368 368 } 369 369 } … … 381 381 if(!taskInstance) { 382 382 flash.message = "Task not found with id ${params.id}" 383 redirect(action: search)383 redirect(action: 'search') 384 384 } 385 385 else { 386 386 if(taskInstance.trash) { 387 flash.message = "You may not edit items in the trash." 388 redirect(action:show,id:taskInstance.id) 389 } 390 def criteria = taskInstance.createCriteria() 391 def possibleParentList = criteria { 392 and { 393 notEqual('id', taskInstance.id) 394 taskInstance.subTasks.each() { notEqual('id', it.id) } 395 } 396 } 387 flash.message = "You may not edit tasks that are in the trash." 388 redirect(action: 'show', id: taskInstance.id) 389 return 390 } 391 def possibleParentList = taskService.possibleParentList(taskInstance) 397 392 return [ taskInstance : taskInstance, possibleParentList: possibleParentList ] 398 393 } … … 403 398 if(!Task.exists(params.id)) { 404 399 flash.message = "Task not found with id ${params.id}" 405 redirect(action: 'search')400 redirect(action: 'search') 406 401 } 407 402 … … 410 405 if(!result.error) { 411 406 flash.message = "Task ${params.id} updated" 412 redirect(action: show,id:result.taskInstance.id)413 } 414 else { 415 if(result.taskInstance) { 416 render(view:'edit',model:[taskInstance:result.taskInstance]) 417 } 418 else { 419 flash.message = "Task could not be updated." 420 redirect(action: 'search')407 redirect(action: 'show', id: result.taskInstance.id) 408 } 409 else { 410 if(result.taskInstance) { 411 render(view:'edit',model:[taskInstance:result.taskInstance]) 412 } 413 else { 414 flash.message = "Task could not be updated." 415 redirect(action: 'search') 421 416 } 422 417 } … … 453 448 def create = { 454 449 def taskInstance = new Task() 455 // Default leadPerson to current user .450 // Default leadPerson to current user, unless supplied in params. 456 451 taskInstance.leadPerson = personService.currentUser() 457 452 taskInstance.properties = params 458 return ['taskInstance': taskInstance]453 return ['taskInstance': taskInstance] 459 454 } 460 455 … … 464 459 if(!result.error) { 465 460 flash.message = "Task ${result.taskInstance.id} created." 466 redirect(action: show,id: result.taskInstance.id)467 } 468 else { 469 if(result.taskInstance) { 470 render(view:'create', model:[taskInstance:result.taskInstance])461 redirect(action: 'show', id: result.taskInstance.id) 462 } 463 else { 464 if(result.taskInstance) { 465 render(view:'create', model:[taskInstance:result.taskInstance]) 471 466 } 472 467 else { 473 468 flash.message = "Could not create task." 474 redirect(action: "search")469 redirect(action: 'search') 475 470 } 476 471 … … 483 478 if(!parentTaskInstance) { 484 479 flash.message = "Task not found with id ${params.id}" 485 redirect(action: search)480 redirect(action: 'search') 486 481 } 487 482 else { 488 483 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 489 def subTaskInstanceList = Task.findAllByParentTask (parentTaskInstance, params)490 def subTaskInstanceTotal = Task.countByParentTask (parentTaskInstance)484 def subTaskInstanceList = Task.findAllByParentTaskAndTrash(parentTaskInstance, false, params) 485 def subTaskInstanceTotal = Task.countByParentTaskAndTrash(parentTaskInstance, false) 491 486 492 487 [ taskInstanceList: subTaskInstanceList, … … 496 491 } 497 492 498 } 493 def createSubTask = { 494 def parentTaskInstance = Task.get(params.id) 495 496 if(parentTaskInstance) { 497 498 def result = taskService.createSubTask(parentTaskInstance) 499 if(!result.error) { 500 flash.message = "Sub Task ${result.taskInstance.id} created, please edit and update to your requirements." 501 redirect(action: 'edit', id: result.taskInstance.id) 502 } 503 else { 504 if(result.taskInstance.errors.hasFieldErrors("parentTask")) { 505 flash.message = g.message(code:"task.operationNotPermittedOnTaskInTrash") 506 redirect(action: 'show', id: parentTaskInstance.id) 507 } 508 else { 509 render(view: 'create', model:[taskInstance: result.taskInstance]) 510 } 511 } 512 } 513 514 else { 515 flash.message = "Task not found with id ${params.id}" 516 redirect(action: 'search') 517 } 518 } 519 520 } // end of class. -
trunk/grails-app/i18n/messages.properties
r191 r196 27 27 task.modifications.failedToSave=Could not complete operation, as task modification record failed to save. 28 28 task.operationNotPermittedOnCompleteTask=This operation is not permitted on a complete task. 29 task.operationNotPermittedOnTaskInTrash=This operation is not permitted on a task that is in the trash. 29 30 30 31 task.assignedPersons=Assigned Persons -
trunk/grails-app/services/TaskService.groovy
r191 r196 1 /* 2 * Provides a service for the Task domain class. 3 * 4 */ 1 5 class TaskService { 2 6 … … 6 10 def personService 7 11 12 /* 13 * Determines and returns a possible parent list 14 * @taskInstance The task to use when determining the possible parent list. 15 * @returns A list of the possible parents. 16 */ 17 def possibleParentList(taskInstance) { 18 def criteria = taskInstance.createCriteria() 19 def possibleParentList = criteria { 20 and { 21 notEqual('trash', true) 22 notEqual('id', taskInstance.id) 23 taskInstance.subTasks.each() { notEqual('id', it.id) } 24 } 25 } 26 } 27 28 /* 29 * Creates a new task with the given params. 30 * @params The params to use when creating the new task. 31 * @returns A map containing result.error=true (if any error) and result.taskInstance. 32 */ 8 33 def create(params) { 9 34 Task.withTransaction { status -> … … 13 38 def taskInstance = new Task(params) 14 39 result.taskInstance = taskInstance 40 41 if(result.taskInstance.parentTask?.trash) { 42 status.setRollbackOnly() 43 result.taskInstance.errors.rejectValue("parentTask", "task.operationNotPermittedOnTaskInTrash") 44 result.error = true 45 return result 46 } 15 47 16 48 if(taskInstance.save()) { … … 26 58 } 27 59 60 // If we get here all went well. 28 61 return result 29 62 } … … 36 69 } // end create() 37 70 71 /* 72 * Creates a subTask copying attributes from the parentTask unless otherwise specified. 73 * @param parentTask The parent task to get attributes from, also set as the parent. 74 * @param params Overrides the parent task values if specified. 75 * @returns A map containing result.error=true (if any error) and result.taskInstance. 76 */ 77 def createSubTask(parentTask, params = [:]) { 78 79 def result = [:] 80 81 //Make our new Task a subTask and set the required properites. 82 def p = [:] 83 p.parentTask = parentTask 84 p.description = params.description ?: parentTask.description 85 p.comment = params.comment ?: parentTask.comment 86 87 p.taskGroup = params.taskGroup ?: parentTask.taskGroup 88 p.taskStatus = TaskStatus.get(1) // A new subTask must always be "Not Started". 89 p.taskPriority = parentTask.taskPriority 90 p.taskType = params.taskType ?: parentTask.taskType 91 p.leadPerson = params.leadPerson ?: parentTask.leadPerson 92 p.primaryAsset = params.primaryAsset ?: parentTask.primaryAsset 93 94 p.targetStartDate = params.targetStartDate ?: parentTask.targetStartDate 95 p.targetCompletionDate = params.targetCompletionDate ?: parentTask.targetCompletionDate 96 97 //Set the assignedPersons 98 // taskInstance.assignedPersons.each() { 99 // 100 // def assignedPerson = new AssignedPerson(person: it.person, 101 // task: subTaskInstance, 102 // estimatedHour: it.estimatedHour, 103 // estimatedMinute: it.estimatedMinute).save() 104 // } 105 106 result = create(p) 107 108 } // end createSubTask() 109 110 /* 111 * Creates a new task entry. 112 * @params The params to use when creating the new entry. 113 * @returns A map containing result.error=true (if any error), result.entryInstance and result.taskId. 114 */ 38 115 def createEntry(params) { 39 116 Task.withTransaction { status -> -
trunk/grails-app/views/taskDetailed/create.gsp
r181 r196 122 122 </td> 123 123 <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'parentTask','errors')}"> 124 <g:select optionKey="id" from="${Task. list()}" name="parentTask.id" value="${taskInstance?.parentTask?.id}" noSelection="['null':'--None--']"></g:select>124 <g:select optionKey="id" from="${Task.findAllByTrash(false)}" name="parentTask.id" value="${taskInstance?.parentTask?.id}" noSelection="['null':'--None--']"></g:select> 125 125 </td> 126 126 </tr> -
trunk/grails-app/views/taskDetailed/edit.gsp
r181 r196 5 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 6 6 <meta name="layout" content="main" /> 7 <title>Edit Task </title>7 <title>Edit Task #${taskInstance.id}</title> 8 8 <nav:resources override="true"/> 9 9 <resource:dateChooser /> -
trunk/grails-app/views/taskDetailed/listSubTasks.gsp
r151 r196 11 11 </div> 12 12 <div class="body"> 13 <h1>Task #${parentTaskInstance.id} sub tasks</h1> 13 <g:link action="show" id="${parentTaskInstance.id}"> 14 <h1>Task #${parentTaskInstance.id} sub tasks.</h1> 15 </g:link> 14 16 <g:if test="${flash.message}"> 15 17 <div class="message">${flash.message}</div> 16 18 </g:if> 19 20 <div class="paginateButtons"> 21 Results:${taskInstanceTotal} 22 </div> 17 23 <div class="list"> 18 24 <input type="hidden" name="parentTaskId" value="${parentTaskInstance?.id}" /> -
trunk/grails-app/views/taskDetailed/show.gsp
r191 r196 3 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 4 4 <meta name="layout" content="main" /> 5 <title>Show Task </title>5 <title>Show Task #${taskInstance.id}</title> 6 6 <g:javascript src="overlayPane.js" /> 7 7 <nav:resources override="true"/> … … 677 677 <div class="buttons"> 678 678 <g:form> 679 < input type="hidden"name="id" value="${taskInstance?.id}" />679 <g:hiddenField name="id" value="${taskInstance?.id}" /> 680 680 <g:if test="${subTaskInstanceTotal > subTaskInstanceMax}"> 681 681 Showing ${subTaskInstanceMax} of ${subTaskInstanceTotal} … … 686 686 <br /> 687 687 </g:else> 688 <span class="button"><g:actionSubmit action="listSubTasks" class="table" value="Sortable List" /></span> 688 <span class="button"><g:actionSubmit action="listSubTasks" class="table" value="List" /></span> 689 <span class="button"><g:actionSubmit action="createSubTask" class="add" value="Add" /></span> 689 690 </g:form> 690 691 </div> … … 694 695 <br /> 695 696 No Sub Tasks. 697 <br /> 698 <br /> 699 700 <div class="buttons"> 701 <g:form> 702 <g:hiddenField name="id" value="${taskInstance?.id}" /> 703 <span class="button"><g:actionSubmit action="createSubTask" class="add" value="Add" /></span> 704 </g:form> 705 </div> 696 706 </g:else> 697 707
Note: See TracChangeset
for help on using the changeset viewer.