Search in sources :

Example 1 with TimerProjectTaskService

use of com.axelor.apps.project.service.TimerProjectTaskService in project axelor-open-suite by axelor.

the class ProjectTaskController method manageTimerButtons.

public void manageTimerButtons(ActionRequest request, ActionResponse response) {
    try {
        ProjectTask task = request.getContext().asType(ProjectTask.class);
        TimerProjectTaskService service = Beans.get(TimerProjectTaskService.class);
        if (task.getId() == null) {
            return;
        }
        Timer timer = service.find(task);
        boolean hideStart = false;
        boolean hideCancel = true;
        if (timer != null) {
            hideStart = timer.getStatusSelect() == TimerRepository.TIMER_STARTED;
            hideCancel = timer.getTimerHistoryList().isEmpty();
        }
        response.setAttr("startTimerBtn", HIDDEN_ATTR, hideStart);
        response.setAttr("stopTimerBtn", HIDDEN_ATTR, !hideStart);
        response.setAttr("cancelTimerBtn", HIDDEN_ATTR, hideCancel);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TimerProjectTaskService(com.axelor.apps.project.service.TimerProjectTaskService) Timer(com.axelor.apps.base.db.Timer) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Aggregations

Timer (com.axelor.apps.base.db.Timer)1 ProjectTask (com.axelor.apps.project.db.ProjectTask)1 TimerProjectTaskService (com.axelor.apps.project.service.TimerProjectTaskService)1