Ignore:
Timestamp:
Feb 20, 2010, 9:41:04 PM (15 years ago)
Author:
gav
Message:

Added a create breakin task feature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r394 r395  
    586586    }
    587587
     588    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser'])
     589    def createBreakin = {
     590        def taskInstance = new Task()
     591
     592        def entryFaultInstance = new Entry(entryType: EntryType.get(1))  // Fault.
     593        def entryWorkDoneInstance = new Entry(entryType: EntryType.get(2))  // Work Done.
     594
     595        return ['taskInstance': taskInstance,
     596                        'entryFaultInstance': entryFaultInstance,
     597                        'entryWorkDoneInstance': entryWorkDoneInstance]
     598    }
     599
     600    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser'])
     601    def saveBreakin = {
     602        def result = taskService.saveBreakin(params)
     603
     604        if(!result.error) {
     605            flash.message = "Task ${result.taskInstance.id} created."
     606            redirect(action: 'show', id: result.taskInstance.id)
     607            return
     608        }
     609
     610        if(result.error.code == "task.modifications.failedToSave")
     611            flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     612
     613        render(view:'createBreakin',
     614                    model: ['taskInstance': result.taskInstance,
     615                                'entryFaultInstance': result.entryFaultInstance,
     616                                'entryWorkDoneInstance': result.entryWorkDoneInstance])
     617
     618    }
     619
    588620} // end of class.
Note: See TracChangeset for help on using the changeset viewer.