Changeset 482 for trunk/grails-app
- Timestamp:
- Apr 13, 2010, 11:02:59 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r394 r482 93 93 94 94 def create = { 95 try { 96 def taskInstance = Task.get(params.taskInstance.id) 97 def entryInstance = new Entry() 98 entryInstance.task = taskInstance 99 entryInstance.entryType = EntryType.get(params.entryType.id) 100 return ['entryInstance':entryInstance] 95 if(!params.taskInstance?.id || !params.entryType?.id) { 96 flash.message = g.message(code:"entry.create.no.params") 97 redirect(controller:"taskDetailed", action:"search") 98 return 101 99 } 102 catch(Exception e) { 103 flash.message = "Please select a task, then 'Add Entry'." 100 101 def taskInstance = Task.read(params.taskInstance.id) 102 103 if(!taskInstance) { 104 flash.message = g.message(code:"task.notFound") 104 105 redirect(controller:"taskDetailed", action:"search") 106 return 105 107 } 106 } 108 109 // Check for Complete task. 110 if(taskInstance.taskStatus.id == 3) { 111 flash.errorMessage = g.message(code:"task.operationNotPermittedOnCompleteTask") 112 redirect(controller:"taskDetailed", action:"show", id: taskInstance.id) 113 return 114 } 115 116 def entryInstance = new Entry() 117 entryInstance.task = taskInstance 118 entryInstance.entryType = EntryType.read(params.entryType.id) 119 return ['entryInstance': entryInstance] 120 } // create 107 121 108 122 def save = { … … 112 126 flash.message = "Entry created." 113 127 redirect(controller: "taskDetailed", action: "show", id: result.taskId) 128 return 114 129 } 115 else {116 if(result.entryInstance) {117 render(view:'create',model:[entryInstance: result.entryInstance])118 }119 else {120 flash.message = "Could not create entry."121 redirect(controller: "taskDetailed", action:"search")122 }123 130 131 if(result.error.code != "default.create.failure") { 132 params.errorMessage = g.message(code: result.error.code) 124 133 } 125 }126 134 127 } 135 render(view:'create',model:[entryInstance: result.entryInstance]) 136 } // save 137 138 } // end class -
trunk/grails-app/i18n/messages.properties
r481 r482 94 94 task.targetCompletionDate.before.targetStartDate=The target completion date must be equal to or greater than \ 95 95 the target start date. 96 97 entry.create.no.params=Please select a task, then add an entry. 96 98 97 99 taskRecurringSchedule.notFound=Could not complete operation, recurring schedule not found. -
trunk/grails-app/services/TaskService.groovy
r478 r482 273 273 } 274 274 275 if(result.entryInstance.hasErrors() || !result.entryInstance.save()) 276 return fail(field:"task", code:"default.create.failure") 277 278 // Success. 279 return result 280 281 } //end withTransaction 275 // Success. 276 return result 277 278 } // end withTransaction 282 279 } // end saveEntry() 283 280 -
trunk/grails-app/views/entryDetailed/create.gsp
r432 r482 14 14 </div> 15 15 <div class="body"> 16 <g:if test="${flash.message}"> 17 <div class="message">${flash.message}</div> 18 </g:if> 16 <g:render template="/shared/messages" /> 19 17 <g:hasErrors bean="${entryInstance}"> 20 18 <div class="errors"> -
trunk/grails-app/views/taskDetailed/create.gsp
r433 r482 12 12 </div> 13 13 <div class="body"> 14 <g:if test="${flash.message}"> 15 <div class="message">${flash.message}</div> 16 </g:if> 14 <g:render template="/shared/messages" /> 17 15 <g:hasErrors bean="${taskInstance}"> 18 16 <div class="errors">
Note: See TracChangeset
for help on using the changeset viewer.