Features:
- Custom workflow creation per project/tracker
- Step-by-step workflow definition
- Assignees per step (user, role group, department)
- Next/Previous step navigation
- Reject to first step
- Skip step (admin only)
- Step deadline settings
- Workflow dashboard
- Group member selection when proceeding
🤖 Generated with Claude Code
98 lines
2.5 KiB
Ruby
98 lines
2.5 KiB
Ruby
class WorkflowsController < ApplicationController
|
|
layout 'admin'
|
|
before_action :require_admin
|
|
before_action :find_workflow, only: [:show, :edit, :update, :destroy]
|
|
|
|
def index
|
|
@workflows = CustomWorkflow.includes(:tracker, :project, :workflow_steps).order(:name)
|
|
end
|
|
|
|
def show
|
|
@steps = @workflow.workflow_steps.includes(:workflow_step_assignees).ordered
|
|
end
|
|
|
|
def new
|
|
@workflow = CustomWorkflow.new
|
|
end
|
|
|
|
def create
|
|
@workflow = CustomWorkflow.new(workflow_params)
|
|
if @workflow.save
|
|
flash[:notice] = '워크플로우가 생성되었습니다.'
|
|
redirect_to custom_workflow_path(@workflow)
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
if @workflow.update(workflow_params)
|
|
flash[:notice] = '워크플로우가 수정되었습니다.'
|
|
redirect_to '/custom_workflows'
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@workflow.destroy
|
|
flash[:notice] = '워크플로우가 삭제되었습니다.'
|
|
redirect_to '/custom_workflows'
|
|
end
|
|
|
|
# 사용자 검색
|
|
def search_users
|
|
query = params[:q].to_s.strip
|
|
if query.length < 2
|
|
render json: []
|
|
return
|
|
end
|
|
|
|
users = User.active
|
|
.where('LOWER(login) LIKE :q OR LOWER(firstname) LIKE :q OR LOWER(lastname) LIKE :q',
|
|
q: "%#{query.downcase}%")
|
|
.limit(20)
|
|
|
|
render json: users.map { |u| { id: u.id, name: u.name, login: u.login } }
|
|
end
|
|
|
|
# 역할 그룹 검색
|
|
def search_role_groups
|
|
query = params[:q].to_s.strip
|
|
groups = if query.length >= 2
|
|
RoleGroup.where('LOWER(name) LIKE ?', "%#{query.downcase}%").limit(20)
|
|
else
|
|
RoleGroup.sorted.limit(20)
|
|
end
|
|
|
|
render json: groups.map { |g| { id: g.id, name: g.name, count: g.member_count } }
|
|
end
|
|
|
|
# 부서 검색
|
|
def search_departments
|
|
query = params[:q].to_s.strip
|
|
depts = if query.length >= 2
|
|
Department.where('LOWER(name) LIKE ?', "%#{query.downcase}%").limit(20)
|
|
else
|
|
Department.sorted.limit(20)
|
|
end
|
|
|
|
render json: depts.map { |d| { id: d.id, name: d.name, type: d.type_name, count: d.member_count } }
|
|
end
|
|
|
|
private
|
|
|
|
def find_workflow
|
|
@workflow = CustomWorkflow.find(params[:id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
def workflow_params
|
|
params.require(:custom_workflow).permit(:name, :description, :tracker_id, :project_id, :is_default, :active)
|
|
end
|
|
end
|