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
82 83 84 85 86 |
# File 'app/controllers/wf/workitems_controller.rb', line 82 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
76 77 78 79 80 |
# File 'app/controllers/wf/workitems_controller.rb', line 76 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
72 73 74 |
# File 'app/controllers/wf/workitems_controller.rb', line 72 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 54 55 56 57 58 |
# File 'app/controllers/wf/workitems_controller.rb', line 39 def finish if dynamic_assignments = params.dig(:workitem, :dynamic_assignments) dynamic_assignments.permit!.each do |t_id, party_id| Wf::CaseCommand::AddManualAssignment.call(@workitem.case, @workitem.workflow.transitions.find(t_id), Wf::Party.find(party_id)) end end 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
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/wf/workitems_controller.rb', line 60 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 |