Changeset 180
- Timestamp:
- Nov 4, 2009, 2:47:47 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskDetailedController.groovy
r179 r180 6 6 def authenticateService 7 7 def dateUtilService 8 def taskService 8 9 def taskSearchService 9 10 def filterService … … 186 187 187 188 def inventoryMovementList = InventoryMovement.findAllByTask(taskInstance, [max:100, sort:"id", order:"desc", offset:0]) 189 190 def taskModificationList = TaskModification.findAllByTask(taskInstance, [max:100, sort:"id", order:"asc", offset:0]) 188 191 189 192 def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id) … … 215 218 taskRecurringScheduleInstance: taskRecurringScheduleInstance, 216 219 taskRecurringScheduleExits: taskRecurringScheduleExits, 217 inventoryMovementList: inventoryMovementList] 220 inventoryMovementList: inventoryMovementList, 221 taskModificationList: taskModificationList] 218 222 } 219 223 } … … 263 267 264 268 def update = { 265 def taskInstance = Task.get( params.id ) 266 if(taskInstance) { 267 if(params.version) { 268 def version = params.version.toLong() 269 if(taskInstance.version > version) { 270 271 taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 272 render(view:'edit',model:[taskInstance:taskInstance]) 273 return 274 } 275 } 276 taskInstance.properties = params 277 if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 269 270 if(!Task.exists(params.id)) { 271 flash.message = "Task not found with id ${params.id}" 272 redirect(action:'search') 273 } 274 275 def result = taskService.update(params) 276 277 if(!result.error) { 278 278 flash.message = "Task ${params.id} updated" 279 redirect(action:show,id:taskInstance.id) 280 } 281 else { 282 render(view:'edit',model:[taskInstance:taskInstance]) 283 } 284 } 285 else { 286 flash.message = "Task not found with id ${params.id}" 287 redirect(action:edit,id:params.id) 288 } 289 } 279 redirect(action:show,id:result.taskInstance.id) 280 } 281 else { 282 if(result.taskInstance) { 283 render(view:'edit',model:[taskInstance:result.taskInstance]) 284 } 285 else { 286 flash.message = "Task could not be updated." 287 redirect(action:'search') 288 } 289 } 290 291 } 292 293 // def update = { 294 // def taskInstance = Task.get( params.id ) 295 // if(taskInstance) { 296 // if(params.version) { 297 // def version = params.version.toLong() 298 // if(taskInstance.version > version) { 299 // 300 // taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 301 // render(view:'edit',model:[taskInstance:taskInstance]) 302 // return 303 // } 304 // } 305 // taskInstance.properties = params 306 // if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 307 // flash.message = "Task ${params.id} updated" 308 // redirect(action:show,id:taskInstance.id) 309 // } 310 // else { 311 // render(view:'edit',model:[taskInstance:taskInstance]) 312 // } 313 // } 314 // else { 315 // flash.message = "Task not found with id ${params.id}" 316 // redirect(action:edit,id:params.id) 317 // } 318 // } 290 319 291 320 def create = { … … 296 325 297 326 def save = { 298 def taskInstance = new Task(params) 299 if(!taskInstance.hasErrors() && taskInstance.save(flush: true)) { 300 flash.message = "Task ${taskInstance.id} created" 301 redirect(action:show,id:taskInstance.id) 302 } 303 else { 304 render(view:'create',model:[taskInstance:taskInstance]) 327 def result = taskService.create(params) 328 329 if(!result.error) { 330 flash.message = "Task ${result.taskInstance.id} created." 331 redirect(action: show,id: result.taskInstance.id) 332 } 333 else { 334 if(result.taskInstance) { 335 render(view:'create',model:[taskInstance:result.taskInstance]) 336 } 337 else { 338 flash.message = "Could not create task." 339 redirect(action:"search") 340 } 341 305 342 } 306 343 } -
trunk/grails-app/domain/Asset.groovy
r161 r180 15 15 16 16 static constraints = { 17 name(unique:true )17 name(unique:true, blank:false) 18 18 } 19 19 -
trunk/grails-app/domain/TaskModification.groovy
r93 r180 1 import java.text.SimpleDateFormat 2 1 3 class TaskModification { 2 4 Person person … … 4 6 Task task 5 7 Date date = new Date() 6 String comment 8 String comment = "" 7 9 8 10 static belongsTo = [Person, TaskModificationType, Task] … … 16 18 } 17 19 18 static optionals = ["comment"] 20 String toString() { 21 def date = new SimpleDateFormat("EEE, dd-MMM-yyyy").format(this.date) 22 "${taskModificationType} by ${person} on ${date}." 23 } 19 24 } -
trunk/grails-app/i18n/messages.properties
r177 r180 24 24 assignedPerson.estimatedDuration=Estimated Duration 25 25 assignedPerson.estimatedDuration.help=The estimated amount of time (hh:mm) that you would like to assign this person to the task. 26 27 task.modifications.failedToSave=Could not complete operation, as task modification record failed to save. 26 28 27 29 task.assignedPersons=Assigned Persons -
trunk/grails-app/services/CreateDataService.groovy
r177 r180 1 1 /** 2 2 * Provides a data service to create base and demo data. 3 * Beware that most, if not all, base data is referenced by "Id" throughout the program. 4 * This allows changing the text of the 'name' property to something of the same meaning. 5 * But be sure to maintain the correct Id during creation, indicated by #1, #2 etc. 3 6 */ 4 7 class CreateDataService { 5 8 9 boolean transactional = false 10 6 11 def authenticateService 7 boolean transactional = false12 def taskService 8 13 9 14 /******************************************* … … 40 45 createBaseManufacturerType() 41 46 // Tasks 47 createBaseTaskGroups() 42 48 createBaseTaskStatus() 43 49 createBaseTaskPriorities() 44 50 createBaseTaskTypes() 51 createBaseTaskModificationTypes() 45 52 createBaseEntryTypes() 46 createBaseModificationTypes()47 53 // Inventory 48 54 createBaseInventoryTypes() … … 66 72 createDemoManufacturers() 67 73 // Tasks 68 createDemoTaskGroups() /// @todo: Perhaps this should be BaseData?69 74 createDemoTasks() 70 75 createDemoEntries() … … 383 388 *********************/ 384 389 385 def create DemoTaskGroups() {390 def createBaseTaskGroups() { 386 391 //TaskGroup 387 392 def taskGroupInstance … … 454 459 } 455 460 461 def createBaseTaskModificationTypes() { 462 463 //ModificationType 464 def taskModificationTypeInstance 465 taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 466 taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 467 taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 468 taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 469 taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 470 taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 471 taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 472 taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 473 taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 474 } 475 456 476 def createDemoTasks() { 457 477 458 //Task459 def taskInstance478 def taskResult 479 def p = [:] 460 480 461 481 //Task #1 462 taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), 463 taskStatus:TaskStatus.findByName("Not Started"), 464 taskPriority:TaskPriority.get(2), 465 taskType:TaskType.get(1), 466 leadPerson:Person.get(2), 467 description:"Check specific level sensor", 468 comment:"Has been noted as problematic, try recalibrating.", 469 targetStartDate:new Date()) 470 saveAndTest(taskInstance) 482 p = [taskGroup:TaskGroup.findByName("Engineering Activites"), 483 taskStatus:TaskStatus.findByName("Not Started"), 484 taskPriority:TaskPriority.get(2), 485 taskType:TaskType.get(1), 486 leadPerson:Person.get(2), 487 description:"Check specific level sensor", 488 comment:"Has been noted as problematic, try recalibrating.", 489 targetStartDate:new Date()] 490 491 taskResult = taskService.create(p) 471 492 472 493 //Task #2 473 taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),494 p = [taskGroup:TaskGroup.findByName("Engineering Activites"), 474 495 taskStatus:TaskStatus.findByName("Not Started"), 475 496 taskPriority:TaskPriority.get(2), … … 479 500 comment:"Some help required", 480 501 targetStartDate:new Date()+1, 481 parentTask: Task.get(1)) 482 saveAndTest(taskInstance) 502 parentTask: Task.get(1)] 503 504 taskResult = taskService.create(p) 483 505 484 506 //Task #3 485 taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),507 p = [taskGroup:TaskGroup.findByName("Engineering Activites"), 486 508 taskStatus:TaskStatus.findByName("Not Started"), 487 509 taskPriority:TaskPriority.get(2), … … 491 513 comment:"Some help required", 492 514 targetStartDate:new Date()-1, 493 parentTask: Task.get(1)) 494 saveAndTest(taskInstance) 515 parentTask: Task.get(1)] 516 517 taskResult = taskService.create(p) 495 518 496 519 //Task #4 497 taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),520 p = [taskGroup:TaskGroup.findByName("Engineering Activites"), 498 521 taskStatus:TaskStatus.findByName("Not Started"), 499 522 taskPriority:TaskPriority.get(2), … … 503 526 comment:"Nothing else has worked.", 504 527 targetStartDate:new Date()+7, 505 parentTask: Task.get(1)) 506 saveAndTest(taskInstance) 528 parentTask: Task.get(1)] 529 530 taskResult = taskService.create(p) 507 531 508 532 //Task #5 509 taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"),533 p = [taskGroup:TaskGroup.findByName("Production Activites"), 510 534 taskStatus:TaskStatus.findByName("Not Started"), 511 535 taskPriority:TaskPriority.get(2), … … 514 538 description:"Production Report", 515 539 comment:"Production report for specific production run or shift", 516 targetStartDate:new Date()-7) 517 saveAndTest(taskInstance) 540 targetStartDate:new Date()-7] 541 542 taskResult = taskService.create(p) 518 543 519 544 //Task #6 520 taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"),545 p = [taskGroup:TaskGroup.findByName("New Projects"), 521 546 taskStatus:TaskStatus.findByName("Not Started"), 522 547 taskPriority:TaskPriority.get(2), … … 525 550 description:"Make killer CMMS app", 526 551 comment:"Use Grails and get a move on!", 527 targetStartDate:new Date()-6) 528 saveAndTest(taskInstance) 552 targetStartDate:new Date()-6] 553 554 taskResult = taskService.create(p) 529 555 } 530 556 … … 575 601 durationMinute: 20) 576 602 saveAndTest(entryInstance) 577 }578 579 def createBaseModificationTypes() {580 581 //ModificationType582 def taskModificationTypeInstance583 taskModificationTypeInstance = new TaskModificationType(name:"Created").save()584 taskModificationTypeInstance = new TaskModificationType(name:"Completed").save()585 taskModificationTypeInstance = new TaskModificationType(name:"Closed").save()586 taskModificationTypeInstance = new TaskModificationType(name:"Altered").save()587 taskModificationTypeInstance = new TaskModificationType(name:"TargetDateModified").save()588 taskModificationTypeInstance = new TaskModificationType(name:"ScheduledDateModified").save()589 taskModificationTypeInstance = new TaskModificationType(name:"DescriptionModified").save()590 taskModificationTypeInstance = new TaskModificationType(name:"AssignedToModified").save()591 taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save()592 603 } 593 604 -
trunk/grails-app/services/DateUtilService.groovy
r137 r180 2 2 3 3 boolean transactional = false 4 static scope = "request"5 6 4 //static scope = "request" 5 6 public static Date getToday() { 7 7 return setMidnight(new Date()) 8 8 } -
trunk/grails-app/services/TaskSearchService.groovy
r165 r180 2 2 3 3 boolean transactional = false 4 static scope = "request"5 4 6 5 def dateUtilService -
trunk/grails-app/services/TaskService.groovy
r143 r180 1 1 class TaskService { 2 2 3 boolean transactional = true 4 static scope = "request" 3 boolean transactional = false 5 4 6 5 def dateUtilService 6 def authenticateService 7 7 8 def taskDates(taskInstance, params) { 9 println "yes" 10 } 11 } 8 def create(params) { 9 Task.withTransaction { status -> 10 def result = [:] 11 def taskInstance = new Task(params) 12 result.taskInstance = taskInstance 13 14 // Get person in a safe way to avoid a null userDomain during bootstrap. 15 def userDomain = authenticateService.userDomain() 16 def person = userDomain ? Person.get(userDomain.id) : Person.get(1) 17 18 if(taskInstance.save()) { 19 def taskModification = new TaskModification(person:person, 20 taskModificationType: TaskModificationType.get(1), 21 task: taskInstance) 22 23 if(!taskModification.save()) { 24 status.setRollbackOnly() 25 taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 26 result.error = true 27 return result 28 } 29 30 return result 31 } 32 else { 33 result.error = true 34 return result 35 } 36 37 } //end withTransaction 38 } // end create() 39 40 def start() { 41 //TaskModificationType.get(2) 42 } // end start() 43 44 def update(params) { 45 Task.withTransaction { status -> 46 def result = [:] 47 result.taskInstance = Task.get(params.id) 48 if(result.taskInstance) { 49 50 // Optimistic locking check. 51 if(params.version) { 52 def version = params.version.toLong() 53 if(result.taskInstance.version > version) { 54 status.setRollbackOnly() 55 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 56 result.error = true 57 return result 58 } 59 } 60 61 62 result.taskInstance.properties = params 63 64 if(result.taskInstance.save()) { 65 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 66 taskModificationType: TaskModificationType.get(3), 67 task: result.taskInstance) 68 if(taskModification.save()) { 69 // All went well. 70 return result 71 } 72 else { 73 status.setRollbackOnly() 74 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 75 result.error = true 76 return result 77 } 78 } 79 } 80 // Something failed. 81 status.setRollbackOnly() 82 result.error = true 83 return result 84 85 } //end withTransaction 86 } // end update() 87 88 def complete() { 89 //TaskModificationType.get(4) 90 } // end complete() 91 92 def reopen() { 93 //TaskModificationType.get(5) 94 } // end reopen() 95 96 def trash() { 97 //TaskModificationType.get(6) 98 } // end trash() 99 100 def restore() { 101 //TaskModificationType.get(7) 102 } // end restore() 103 104 def approve() { 105 //TaskModificationType.get(8) 106 } // end approve() 107 108 def renegeApproval() { 109 //TaskModificationType.get(9) 110 } // end renegeApproval() 111 112 } // end TaskService -
trunk/grails-app/views/taskDetailed/create.gsp
r168 r180 21 21 </g:hasErrors> 22 22 23 <g:form id='createTaskForm' name='createTaskForm'action="save" method="post" >23 <g:form action="save" method="post" > 24 24 <div class="dialog"> 25 25 <table> -
trunk/grails-app/views/taskDetailed/show.gsp
r175 r180 4 4 <meta name="layout" content="main" /> 5 5 <title>Show Task</title> 6 <g:javascript src="overlayPane.js" /> 6 7 <nav:resources override="true"/> 7 8 <resource:tabView skin="tabviewCustom" /> … … 15 16 <div class="message">${flash.message}</div> 16 17 </g:if> 17 <g:hasErrors bean="${task ProcedureInstance}">18 <g:hasErrors bean="${taskInstance}"> 18 19 <div class="errors"> 19 <g:renderErrors bean="${task ProcedureInstance}" as="list" />20 <g:renderErrors bean="${taskInstance}" as="list" /> 20 21 </div> 21 22 </g:hasErrors> … … 41 42 42 43 <tr class="prop"> 43 <td valign="top" class="name">Id:</td>44 45 <td valign="top" class="value">${fieldValue(bean:taskInstance, field:'id')}</td>46 47 </tr>48 49 <tr class="prop">50 44 <td valign="top" class="name">Description:</td> 51 45 … … 62 56 63 57 <tr class="prop"> 64 <td valign="top" class="name">Target Start Date:</td>58 <td valign="top" class="name">Target Start:</td> 65 59 66 60 <td valign="top" class="value"><g:formatDate date="${taskInstance.targetStartDate}" format="EEE, dd-MMM-yyyy"/></td> … … 69 63 70 64 <tr class="prop"> 71 <td valign="top" class="name">Target Completion Date:</td>65 <td valign="top" class="name">Target Completion:</td> 72 66 73 67 <td valign="top" class="value"><g:formatDate date="${taskInstance.targetCompletionDate}" format="EEE, dd-MMM-yyyy"/></td> 74 68 75 69 </tr> 70 71 <tr class="prop"> 72 <td valign="top" class="name"> 73 <div id="modControlClosed"> 74 <a href='' onclick="showElement('modifications'); 75 showElement('modControlOpened'); 76 hideElement('modControlClosed'); return false;"> 77 Modifications <img src="${resource(dir:'images/skin',file:'sorted_asc.gif')}" alt="Show" /> 78 </a> 79 </div> 80 <div id="modControlOpened" style="display:none;"> 81 <a href='' onclick="hideElement('modifications'); 82 hideElement('modControlOpened'); 83 showElement('modControlClosed'); 84 return false;"> 85 Modifications <img src="${resource(dir:'images/skin',file:'sorted_desc.gif')}" alt="Show" /> 86 </a> 87 </div> 88 </td> 89 90 <td valign="top" style="text-align:left;" class="value"> 91 <div id="modifications" style="display:none;"> 92 <ul> 93 <g:each var="a" in="${taskModificationList}"> 94 <li>${a?.encodeAsHTML()}</li> 95 </g:each> 96 </ul> 97 </div> 98 </td> 99 </tr> 100 76 101 77 102 <tr class="prop"> … … 103 128 104 129 <tr class="prop"> 105 <td valign="top" class="name"> TaskPriority:</td>130 <td valign="top" class="name">Priority:</td> 106 131 107 132 <td valign="top" class="value">${taskInstance?.taskPriority?.encodeAsHTML()}</td> … … 110 135 111 136 <tr class="prop"> 112 <td valign="top" class="name"> TaskStatus:</td>137 <td valign="top" class="name">Status:</td> 113 138 114 139 <td valign="top" class="value">${taskInstance?.taskStatus?.encodeAsHTML()}</td> … … 117 142 118 143 <tr class="prop"> 119 <td valign="top" class="name"> IsActive:</td>144 <td valign="top" class="name">Active:</td> 120 145 121 146 <td valign="top" class="value">${fieldValue(bean:taskInstance, field:'isActive')}</td> … … 124 149 125 150 <tr class="prop"> 126 <td valign="top" class="name"> IsApproved:</td>151 <td valign="top" class="name">Approved:</td> 127 152 128 153 <td valign="top" class="value">${fieldValue(bean:taskInstance, field:'isApproved')}</td> … … 131 156 132 157 <tr class="prop"> 133 <td valign="top" class="name"> IsScheduled:</td>158 <td valign="top" class="name">Scheduled:</td> 134 159 135 160 <td valign="top" class="value">${fieldValue(bean:taskInstance, field:'isScheduled')}</td> … … 145 170 146 171 <tr class="prop"> 147 <td valign="top" class="name"> TaskGroup:</td>172 <td valign="top" class="name">Group:</td> 148 173 149 174 <td valign="top" class="value">${taskInstance?.taskGroup?.encodeAsHTML()}</td> … … 152 177 153 178 <tr class="prop"> 154 <td valign="top" class="name">T ask Type:</td>179 <td valign="top" class="name">Type:</td> 155 180 156 181 <td valign="top" class="value">${taskInstance?.taskType?.encodeAsHTML()}</td>
Note: See TracChangeset
for help on using the changeset viewer.