Changeset 147 for trunk/grails-app/controllers
- Timestamp:
- Oct 8, 2009, 7:58:38 PM (15 years ago)
- Location:
- trunk/grails-app/controllers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssignedPersonDetailedController.groovy
r134 r147 2 2 3 3 class AssignedPersonDetailedController extends BaseController { 4 4 5 5 def index = { redirect(action:list,params:params) } 6 6 … … 27 27 if(assignedPersonInstance) { 28 28 try { 29 def taskId = assignedPersonInstance.task.id 29 30 assignedPersonInstance.delete() 30 31 flash.message = "AssignedPerson ${params.id} deleted" 31 redirect( action:list)32 redirect(controller:"taskDetailed", action:"show", id: taskId) 32 33 } 33 34 catch(org.springframework.dao.DataIntegrityViolationException e) { … … 60 61 def version = params.version.toLong() 61 62 if(assignedPersonInstance.version > version) { 62 63 63 64 assignedPersonInstance.errors.rejectValue("version", "assignedPerson.optimistic.locking.failure", "Another user has updated this AssignedPerson while you were editing.") 64 65 render(view:'edit',model:[assignedPersonInstance:assignedPersonInstance]) … … 82 83 83 84 def create = { 84 85 86 87 88 89 def assignedPersonInstance = new AssignedPerson()90 assignedPersonInstance.properties = params91 return ['assignedPersonInstance':assignedPersonInstance]92 85 if(!params.task?.id) { 86 flash.message = "Please select a task and then 'Add Assigned Person'" 87 redirect(controller: "taskDetailed", action: list) 88 } 89 else { 90 def assignedPersonInstance = new AssignedPerson() 91 assignedPersonInstance.properties = params 92 return ['assignedPersonInstance':assignedPersonInstance] 93 } 93 94 } 94 95 95 96 def save = { 96 97 def assignedPersonInstance = new AssignedPerson(params) 98 97 99 if(!assignedPersonInstance.hasErrors() && assignedPersonInstance.save()) { 98 100 flash.message = "AssignedPerson ${assignedPersonInstance.id} created" 99 redirect( action:show,id:assignedPersonInstance.id)101 redirect(controller:"taskDetailed", action:"show", id: params.task.id) 100 102 } 101 103 else { -
trunk/grails-app/controllers/EntryDetailedController.groovy
r98 r147 4 4 5 5 def authenticateService 6 6 7 7 def index = { redirect(action:list,params:params) } 8 8 -
trunk/grails-app/controllers/PersonController.groovy
r136 r147 4 4 class PersonController extends BaseAppAdminController { 5 5 6 def authenticateService 6 def authenticateService 7 def filterService 7 8 8 9 // the delete, save and update actions only accept POST requests … … 13 14 } 14 15 15 def list = { 16 if (!params.max) { 17 params.max = 10 18 } 19 [personList: Person.list(params)] 20 } 16 def list = { 17 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100 ) 18 19 if(!params.filter) 20 { return [personList: Person.list(params), personTotal: Person.count()] } 21 22 // filterPane: 23 return[ personList: filterService.filter( params, Person ), 24 personTotal: filterService.count( params, Person ), 25 filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params), 26 params:params ] 27 } 21 28 22 29 def show = { 30 31 // In the case of an actionSubmit button, rewrite action name from 'index'. 32 if(params._action_Show) 33 { params.action='show' } 34 23 35 def person = Person.get(params.id) 24 36 if (!person) { … … 46 58 if (person) { 47 59 def authPrincipal = authenticateService.principal() 48 // avoid self-delete if the logged-in user is an admin60 // Avoid self-delete. 49 61 if (!(authPrincipal instanceof String) && authPrincipal.username == person.loginName) { 50 flash.message = "You can not delete yourself, please login as another admin and try again" 62 flash.message = "You cannot delete yourself, please login as another manager and try again." 63 redirect(action:show,id:params.id) 51 64 } 52 65 else { 53 66 //first, delete this person from Persons_Authorities table. 54 67 Authority.findAll().each { it.removeFromPersons(person) } 55 68 person.isActive = false 69 person.save(flush: true) 70 56 71 try { 57 person.delete( )72 person.delete(flush: true) 58 73 flash.message = "Person $params.id deleted." 59 74 redirect(action:list) … … 72 87 def edit = { 73 88 89 // In the case of an actionSubmit button, rewrite action name from 'index'. 90 if(params._action_Edit) 91 { params.action='edit' } 92 74 93 def person = Person.get(params.id) 75 94 if (!person) { … … 78 97 return 79 98 } 80 99 flash.message = "To allow login at least the 'ROLE_AppUser' authority must be given." 81 100 return buildPersonModel(person) 82 101 } … … 126 145 127 146 def create = { 147 flash.message = "To allow login at least the 'ROLE_AppUser' authority must be given." 128 148 [person: new Person(params), authorityList: Authority.list()] 129 149 } -
trunk/grails-app/controllers/TaskDetailedController.groovy
r144 r147 202 202 203 203 def show = { 204 204 205 205 // In the case of an actionSubmit button, rewrite action name from 'index'. 206 206 if(params._action_Show) … … 286 286 287 287 def edit = { 288 288 289 289 // In the case of an actionSubmit button, rewrite action name from 'index'. 290 290 if(params._action_Edit) -
trunk/grails-app/controllers/TaskProcedureDetailedController.groovy
r134 r147 2 2 3 3 class TaskProcedureDetailedController extends BaseController { 4 4 5 5 def index = { redirect(action:list,params:params) } 6 6 … … 10 10 def list = { 11 11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ taskProcedureInstanceList: TaskProcedure.list( params ), taskProcedureInstanceTotal: TaskProcedure.count() ] 12 13 if(!params.filter) 14 { return [taskProcedureInstanceList: TaskProcedure.list(params), taskProcedureInstanceTotal: TaskProcedure.count()] } 15 16 // filterPane: 17 return[ taskProcedureInstanceList: filterService.filter( params, TaskProcedure ), 18 taskProcedureInstanceTotal: filterService.count( params, TaskProcedure ), 19 filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params), 20 params:params ] 13 21 } 14 22 15 23 def search = { 16 24 redirect(action:list) … … 18 26 19 27 def show = { 28 29 // In the case of an actionSubmit button, rewrite action name from 'index'. 30 if(params._action_Show) 31 { params.action='show' } 32 20 33 def taskProcedureInstance = TaskProcedure.get( params.id ) 21 34 … … 47 60 48 61 def edit = { 62 63 // In the case of an actionSubmit button, rewrite action name from 'index'. 64 if(params._action_Edit) 65 { params.action='edit' } 66 49 67 def taskProcedureInstance = TaskProcedure.get( params.id ) 50 68 … … 64 82 def version = params.version.toLong() 65 83 if(taskProcedureInstance.version > version) { 66 84 67 85 taskProcedureInstance.errors.rejectValue("version", "taskProcedure.optimistic.locking.failure", "Another user has updated this TaskProcedure while you were editing.") 68 86 render(view:'edit',model:[taskProcedureInstance:taskProcedureInstance]) … … 86 104 87 105 def create = { 88 def taskInstance = Task.get(params.taskInstance?.id) 89 90 def taskProcedureInstance = new TaskProcedure() 91 taskProcedureInstance.properties = params 92 return ['taskProcedureInstance':taskProcedureInstance, 93 taskInstance: taskInstance] 106 if(params.taskInstance?.id) { 107 def taskInstance = Task.get(params.taskInstance.id) 108 109 def taskProcedureInstance = new TaskProcedure() 110 taskProcedureInstance.properties = params 111 return ['taskProcedureInstance':taskProcedureInstance, 112 taskInstance: taskInstance] 113 } else { 114 flash.message = "Please select a task, then the Procedure tab.'" 115 redirect(controller:"taskDetailed", action:"list") 116 } 94 117 } 95 118 96 119 def save = { 97 120 def taskProcedureInstance = new TaskProcedure(params) 98 99 121 def taskInstance = Task.get(params.taskInstance.id) 122 100 123 if(!taskProcedureInstance.hasErrors() && taskProcedureInstance.save()) { 101 102 flash.message = "TaskProcedure ${taskProcedureInstance.id} created "124 taskProcedureInstance.addToTasks(taskInstance) 125 flash.message = "TaskProcedure ${taskProcedureInstance.id} created." 103 126 redirect(action:show,id:taskProcedureInstance.id) 104 127 } 105 128 else { 106 render(view:'create',model:[taskProcedureInstance:taskProcedureInstance ])129 render(view:'create',model:[taskProcedureInstance:taskProcedureInstance, taskInstance: taskInstance]) 107 130 } 108 131 }
Note: See TracChangeset
for help on using the changeset viewer.