Changeset 802


Ignore:
Timestamp:
Feb 10, 2011, 12:17:55 PM (8 years ago)
Author:
gav
Message:

Task trash improvements.
Allow trashed parentTask to break subTask links (only with auth).
Prevent trashing of tasks linked to taskProcedure or Parent PM type tasks.

Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/i18n/messages.properties

    r738 r802  
    144144task.delete.failure.production=Tasks may not be deleted in production mode, \
    145145    set the trash flag instead.
     146task.trash.confirm=Trash, are you sure? \
     147    If authorised, recurrence will be disabled and Sub Task links will be forever removed!
    146148task.notFound=Could not complete operation, task not found.
    147149task.operationNotPermittedOnCompleteTask=This operation is not permitted on a complete task.
    148150task.operationNotPermittedOnTaskInTrash=This operation is not permitted on a task that is in the trash.
    149 task.operationNotPermittedOnRecurringTaskWithoutAuth=This operation is not permitted on a recurring task without authorisation.
     151task.operationNotPermittedOnRecurringTaskWithoutAuth=This operation is not permitted \
     152    on a recurring task without authorisation.
     153task.operationNotPermittedOnTaskHavingSubTasksWithoutAuth=This operation is not permitted \
     154    on a task that has sub tasks without authorisation.
     155task.operationNotPermittedOnTaskLinkedToProcedure=This operation is not permitted \
     156    on a task that is linked to a procedure.
     157task.operationNotPermittedOnParentPmTask=This operation is not permitted \
     158    on a Parent PM task.
    150159task.failedToSave=Could not complete operation, task failed to save.
    151160task.modifications.failedToSave=Could not complete operation, as task modification record failed to save.
  • trunk/grails-app/services/TaskService.groovy

    r749 r802  
    685685            }
    686686
     687            // Check for authorisation on tasks having subTasks.
     688            if(result.taskInstance.subTasks) {
     689                if(!authenticateService.ifAnyGranted('ROLE_AppAdmin,ROLE_Manager,ROLE_TaskManager'))
     690                    return fail(field:"subTasks", code:"task.operationNotPermittedOnTaskHavingSubTasksWithoutAuth")
     691            }
     692
     693            // Check for taskProcedure using this task as linkedTask.
     694            if(result.taskInstance.taskProcedure?.linkedTask?.id == result.taskInstance.id)
     695                return fail(field:"taskProcedure", code:"task.operationNotPermittedOnTaskLinkedToProcedure")
     696
     697            // Check for Parent PM task type.
     698            if(result.taskInstance.taskType.id == 6)
     699                return fail(field:"taskProcedure", code:"task.operationNotPermittedOnParentPmTask")
     700
    687701            result.taskInstance.trash = true
    688702            result.taskInstance.attentionFlag = false
    689703            result.taskInstance.taskRecurringSchedule?.enabled = false
     704            result.taskInstance.subTasks.each {
     705                it.parentTask = null
     706            }
    690707
    691708            if(result.taskInstance.hasErrors() || !result.taskInstance.save())
  • trunk/grails-app/views/taskDetailed/show.gsp

    r799 r802  
    282282
    283283                                        <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
    284                                         <span class="button"><g:actionSubmit class="trash" onclick="return confirm('Are you sure?');" value="Trash" /></span>
     284                                        <span class="button">
     285                                            <g:actionSubmit class="trash"
     286                                                                        onclick="return confirm('${message(code:'task.trash.confirm')}');"
     287                                                                        value="Trash" />
     288                                        </span>
    285289
    286290                                    </g:if>
Note: See TracChangeset for help on using the changeset viewer.