Class: Wf::WorkitemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Wf::WorkitemsController
- Defined in:
- app/controllers/wf/workitems_controller.rb
Instance Method Summary collapse
- #check_finish ⇒ Object
- #check_start ⇒ Object
- #find_workitem ⇒ Object
- #finish ⇒ Object
- #finish_and_redirect ⇒ Object
- #index ⇒ Object
- #pre_finish ⇒ Object
- #show ⇒ Object
- #start ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#check_finish ⇒ Object
77 78 79 80 81 |
# File 'app/controllers/wf/workitems_controller.rb', line 77 def check_finish unless @workitem.finished_by?(wf_current_user) redirect_to workitem_path(@workitem), notice: "You can not the holding use of this workitem, Please assign to youself && start it first." end end |
#check_start ⇒ Object
71 72 73 74 75 |
# File 'app/controllers/wf/workitems_controller.rb', line 71 def check_start unless @workitem.started_by?(wf_current_user) redirect_to workitem_path(@workitem), notice: "You can not start this workitem, Please assign to youself first." end end |
#find_workitem ⇒ Object
67 68 69 |
# File 'app/controllers/wf/workitems_controller.rb', line 67 def find_workitem @workitem = Wf::Workitem.find(params[:id]) end |
#finish ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/wf/workitems_controller.rb', line 39 def finish if @workitem.transition.form && params[:workitem][:entry] form = @workitem.transition.form cmd = Wf::CaseCommand::CreateEntry.call(form, @workitem, wf_current_user, params[:workitem][:entry].permit!) if cmd.success? Wf::CaseCommand::FinishWorkitem.call(@workitem) finish_and_redirect else redirect_to pre_finish_workitem_path(@workitem), notice: "Your input no OK." end else Wf::CaseCommand::FinishWorkitem.call(@workitem) finish_and_redirect end end |
#finish_and_redirect ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/wf/workitems_controller.rb', line 55 def finish_and_redirect if @workitem.case.finished? if started_by = @workitem.case.started_by_workitem redirect_to workflow_case_path(started_by.workflow, started_by.case), notice: "workitem is done, and goto parent case." else redirect_to workflow_case_path(@workitem.workflow, @workitem.case), notice: "workitem is done, and the case is finished." end else redirect_to workitem_path(@workitem.case.workitems.enabled.first), notice: "workitem is done, and goto next fireable workitem." end end |
#index ⇒ Object
13 14 15 16 17 18 |
# File 'app/controllers/wf/workitems_controller.rb', line 13 def index @workitems = Wf::Workitem.todo(wf_current_user) @workitems = @workitems.where(state: params[:state].intern) if params[:state] @workitems = @workitems.where(state: params[:state].intern) if params[:state].present? @workitems = @workitems.distinct.order("id desc").page(params[:page]) end |
#pre_finish ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/wf/workitems_controller.rb', line 33 def pre_finish @workitem.workflow.name, workflow_path(@workitem.workflow) @workitem.case.name, workflow_case_path(@workitem.workflow, @workitem.case) @workitem.name, workitem_path(@workitem) end |
#show ⇒ Object
20 21 22 23 |
# File 'app/controllers/wf/workitems_controller.rb', line 20 def show @workitem.workflow.name, workflow_path(@workitem.workflow) @workitem.case.name, workflow_case_path(@workitem.workflow, @workitem.case) end |
#start ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/controllers/wf/workitems_controller.rb', line 25 def start Wf::CaseCommand::StartWorkitem.call(@workitem, wf_current_user) @workitem.workflow.name, workflow_path(@workitem.workflow) @workitem.case.name, workflow_case_path(@workitem.workflow, @workitem.case) @workitem.name, workitem_path(@workitem) render :pre_finish end |