Class: Wf::GuardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wf/guards_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#wf_current_user

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/wf/guards_controller.rb', line 15

def create
  @arc = Wf::Arc.find(params[:arc_id])
  gp = guard_params.merge(fieldable: GlobalID::Locator.locate(guard_params[:fieldable]))
  @guard = @arc.guards.new(gp.merge(workflow: @arc.workflow))
  redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "only out direction arc can set guard!" unless @arc.out?
  if @guard.save
    redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "guard was successfully created."
  else
    render :new
  end
end

#destroyObject



27
28
29
30
31
32
# File 'app/controllers/wf/guards_controller.rb', line 27

def destroy
  @arc = Wf::Arc.find(params[:arc_id])
  @guard = @arc.guards.find(params[:id])
  @guard.destroy
  render js: "window.location.reload()"
end

#editObject



34
35
36
37
38
39
# File 'app/controllers/wf/guards_controller.rb', line 34

def edit
  @arc = Wf::Arc.find(params[:arc_id])
  @guard = @arc.guards.find(params[:id])
  breadcrumb @arc.workflow.name, workflow_path(@arc.workflow)
  breadcrumb @arc.name, workflow_arc_path(@arc.workflow, @arc)
end

#newObject



8
9
10
11
12
13
# File 'app/controllers/wf/guards_controller.rb', line 8

def new
  @arc = Wf::Arc.find(params[:arc_id])
  @guard = @arc.guards.new
  breadcrumb @arc.workflow.name, workflow_path(@arc.workflow)
  breadcrumb @arc.name, workflow_arc_path(@arc.workflow, @arc)
end

#updateObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/wf/guards_controller.rb', line 41

def update
  @arc = Wf::Arc.find(params[:arc_id])
  gp = guard_params.merge(fieldable: GlobalID::Locator.locate(guard_params[:fieldable]))
  @guard = @arc.guards.find(params[:id])
  if @guard.update(gp)
    redirect_to workflow_arc_path(@arc.workflow, @arc), notice: "guard was successfully created."
  else
    render :edit
  end
end