Changeset 134 for trunk/grails-app/controllers
- Timestamp:
- May 13, 2009, 12:51:15 PM (16 years ago)
- Location:
- trunk/grails-app/controllers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AppCoreController.groovy
r127 r134 23 23 24 24 def options = { 25 } 26 27 def acknowledgements = { 25 28 } 26 29 -
trunk/grails-app/controllers/AssignedPersonDetailedController.groovy
r97 r134 82 82 83 83 def create = { 84 if(!params.task?.id) { 85 flash.message = "Please select a task and then 'Add Assigned Person'" 86 redirect(controller: "taskDetailed", action: list) 87 } 88 else { 84 89 def assignedPersonInstance = new AssignedPerson() 85 90 assignedPersonInstance.properties = params 86 91 return ['assignedPersonInstance':assignedPersonInstance] 92 } 87 93 } 88 94 -
trunk/grails-app/controllers/TaskDetailedController.groovy
r133 r134 20 20 } 21 21 22 // def show = {23 // def taskInstance = Task.get( params.id )24 //25 // if(!taskInstance) {26 // flash.message = "Task not found with id ${params.id}"27 // redirect(action:list)28 // }29 // else {30 // def taskProcedureInstance = TaskProcedure.get(taskInstance?.taskProcedure?.id)31 // return [ taskInstance : taskInstance, taskProcedureInstance: taskProcedureInstance]32 //33 // }34 // }35 36 22 def show = { 37 23 def taskInstance = Task.get( params.id ) … … 42 28 } 43 29 else { 30 params.max = 10 31 params.order = "desc" 32 params.sort = "id" 33 34 def subTaskInstanceList = Task.findAllByParentTask(taskInstance, params) 35 def subTaskInstanceTotal = Task.countByParentTask(taskInstance) 36 def showTaskTab = new String("true") 37 44 38 def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id) 45 39 def taskProcedureExits = new Boolean("true") 46 def showTaskTab = new String("true")47 48 40 if(!taskProcedureInstance) { 49 41 taskProcedureExits = false 50 42 } 43 // else { 44 params.order = "asc" 45 params.sort = "procedureStepNumber" 46 def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, params) 47 // } 48 49 def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id) 50 def taskRecurringScheduleExits= new Boolean("true") 51 if(!taskRecurringScheduleInstance) { 52 taskRecurringScheduleExits = false 53 } 54 51 55 return [ taskInstance : taskInstance, 52 56 taskProcedureInstance: taskProcedureInstance, 53 57 taskProcedureExits: taskProcedureExits, 54 showTaskTab: showTaskTab] 58 showTaskTab: showTaskTab, 59 subTaskInstanceList: subTaskInstanceList, 60 subTaskInstanceTotal: subTaskInstanceTotal, 61 subTaskInstanceMax: params.max, 62 maintenanceActionList: maintenanceActionList, 63 taskRecurringScheduleInstance: taskRecurringScheduleInstance, 64 taskRecurringScheduleExits: taskRecurringScheduleExits] 55 65 } 56 66 } … … 136 146 } 137 147 } 138 139 //Generate a new TaskProcedure for a taskInstance. 140 def generateProcedure = { 141 def taskProcedureInstance = new TaskProcedure() 142 taskProcedureInstance.properties = params 143 144 def taskInstance = Task.get(params.taskInstance.id) 145 def taskProcedureExits = new Boolean("true") 146 def showProcedureTab = new String("true") 147 148 if(!taskProcedureInstance.hasErrors() && taskProcedureInstance.save()) { 149 taskProcedureInstance.addToTasks(taskInstance) 150 flash.message = "Procedure created, you can now add steps to the procedure" 151 // redirect(action:show, id:params.taskInstance.id) 148 149 def listSubTasks = { 150 def parentTaskInstance = Task.get(params.id) 151 152 if(!parentTaskInstance) { 153 flash.message = "Task not found with id ${params.id}" 154 redirect(action:list) 152 155 } 153 156 else { 154 taskProcedureExits = false 155 } 156 157 render(view:'show',model:[ taskInstance : taskInstance, 158 taskProcedureInstance: taskProcedureInstance, 159 taskProcedureExits: taskProcedureExits, 160 showProcedureTab: showProcedureTab]) 161 } 162 163 def findProcedure = { 164 redirect(controller:"taskProcedureDetailed", action:"list", id:params.taskInstance.id) 165 } 157 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 158 def subTaskInstanceList = Task.findAllByParentTask(parentTaskInstance, params) 159 def subTaskInstanceTotal = Task.countByParentTask(parentTaskInstance) 160 161 [ taskInstanceList: subTaskInstanceList, 162 taskInstanceTotal: subTaskInstanceTotal, 163 parentTaskInstance: parentTaskInstance] 164 } 165 } 166 166 167 167 } -
trunk/grails-app/controllers/TaskProcedureDetailedController.groovy
r133 r134 11 11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 12 [ taskProcedureInstanceList: TaskProcedure.list( params ), taskProcedureInstanceTotal: TaskProcedure.count() ] 13 } 14 15 def search = { 16 redirect(action:list) 13 17 } 14 18 … … 82 86 83 87 def create = { 88 def taskInstance = Task.get(params.taskInstance?.id) 89 84 90 def taskProcedureInstance = new TaskProcedure() 85 91 taskProcedureInstance.properties = params 86 return ['taskProcedureInstance':taskProcedureInstance] 92 return ['taskProcedureInstance':taskProcedureInstance, 93 taskInstance: taskInstance] 87 94 } 88 95 89 96 def save = { 90 97 def taskProcedureInstance = new TaskProcedure(params) 98 def taskInstance = Task.get(params.taskInstance.id) 99 91 100 if(!taskProcedureInstance.hasErrors() && taskProcedureInstance.save()) { 101 taskProcedureInstance.addToTasks(taskInstance) 92 102 flash.message = "TaskProcedure ${taskProcedureInstance.id} created" 93 103 redirect(action:show,id:taskProcedureInstance.id) -
trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy
r131 r134 80 80 } 81 81 } 82 82 83 83 def create = { 84 def taskRecurringScheduleInstance = new TaskRecurringSchedule() 85 taskRecurringScheduleInstance.properties = params 86 return ['taskRecurringScheduleInstance':taskRecurringScheduleInstance] 84 try { 85 def taskInstance = Task.get(params.taskInstance.id) 86 def taskRecurringScheduleInstance = new TaskRecurringSchedule() 87 taskRecurringScheduleInstance.task = taskInstance 88 return [taskRecurringScheduleInstance: taskRecurringScheduleInstance] 89 } 90 catch(Exception e) { 91 flash.message = "Please select a task, then Create a Recurring Schedule for it.'" 92 redirect(controller:"taskDetailed", action:"list") 93 } 87 94 } 88 95 89 96 def save = { 90 97 def taskRecurringScheduleInstance = new TaskRecurringSchedule(params) 91 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 92 flash.message = "TaskRecurringSchedule ${taskRecurringScheduleInstance.id} created" 93 redirect(action:show,id:taskRecurringScheduleInstance.id) 94 } 95 else { 96 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 97 } 98 def taskInstance = Task.get(params.task.id) 99 100 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 101 102 taskInstance.taskRecurringSchedule = taskRecurringScheduleInstance 103 104 if(taskInstance.save()) { 105 flash.message = "TaskRecurringSchedule ${taskRecurringScheduleInstance.id} created" 106 redirect(action:show,id:taskRecurringScheduleInstance.id) 107 } 108 else { 109 flash.message = "Task could not be saved and therefore the Recurring Schedule has been disgarded, cause unknown." 110 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 111 } 112 } 113 else { 114 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 115 } 116 98 117 } 118 99 119 }
Note: See TracChangeset
for help on using the changeset viewer.