Class: RePlanWorkflowsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/re_plan_workflows_controller.rb

Instance Method Summary collapse

Instance Method Details

#addObject



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/controllers/re_plan_workflows_controller.rb', line 100

def add
  @re_plan.add_workflow(@re_workflow)    
  flash[:success] = 'Workflow Added.'

  respond_to do |format|
    format.html do
      redirect_to(change_re_plan_path(@re_plan))
    end  
    format.js do
      render :template => "re_plans/update"
    end
  end
end

#changeObject



82
83
84
# File 'app/controllers/re_plan_workflows_controller.rb', line 82

def change
  RulesEngine::Discovery.discover!
end

#copyObject



128
129
130
# File 'app/controllers/re_plan_workflows_controller.rb', line 128

def copy
  @re_workflow_copy = ReWorkflow.new
end

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/re_plan_workflows_controller.rb', line 27

def create
  @re_workflow = ReWorkflow.new(params[:re_workflow])    
  if @re_workflow.save
    @re_plan.add_workflow(@re_workflow)
    flash[:success] = 'Workflow Created.'
    
    respond_to do |format|
      format.html do
        redirect_to(change_re_plan_path(@re_plan))
      end  
      format.js do
        render :template => "re_plans/update"
      end
    end
  else
    render :action => "new"
  end    
end

#defaultObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/controllers/re_plan_workflows_controller.rb', line 86

def default
  @re_plan.default_workflow = @re_workflow
  
  flash[:success] = 'Workflow Default Set.'
  respond_to do |format|
    format.html do
      redirect_to(change_re_plan_path(@re_plan))
    end  
    format.js do
      render :template => "re_plans/update"
    end
  end
end

#destroyObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/re_plan_workflows_controller.rb', line 68

def destroy
  @re_workflow.destroy
  flash[:success] = 'Workflow Deleted.'
  
  respond_to do |format|
    format.html do
      redirect_to(change_re_plan_path(@re_plan))
    end  
    format.js do
      render :inline => "window.location.href = '#{change_re_plan_path(@re_plan)}';"
    end
  end
end

#duplicateObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'app/controllers/re_plan_workflows_controller.rb', line 132

def duplicate
  @re_workflow_copy = ReWorkflow.new
  @re_workflow_copy.revert!(@re_workflow.publish)
  @re_workflow_copy.attributes = params[:re_workflow]

  if @re_workflow_copy.save   
    @re_plan.add_workflow(@re_workflow_copy) 
    flash[:success] = 'Workflow Duplicated.'
    respond_to do |format|
      format.html do
        redirect_to(change_re_plan_workflow_path(@re_plan, @re_workflow_copy))
      end  
      format.js do
        render :inline => "window.location.href = '#{change_re_plan_workflow_path(@re_plan, @re_workflow_copy)}';"
      end
    end
  else
     render :action => "copy"  
  end  
end

#editObject



46
47
# File 'app/controllers/re_plan_workflows_controller.rb', line 46

def edit    
end

#newObject



23
24
25
# File 'app/controllers/re_plan_workflows_controller.rb', line 23

def new
  @re_workflow = ReWorkflow.new()
end

#removeObject



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'app/controllers/re_plan_workflows_controller.rb', line 114

def remove    
  @re_plan.remove_workflow(@re_workflow)
  flash[:success] = 'Workflow Removed.'

  respond_to do |format|
    format.html do
      redirect_to(change_re_plan_path(@re_plan))
    end  
    format.js do
      render :template => "re_plans/update"
    end
  end
end

#showObject



20
21
# File 'app/controllers/re_plan_workflows_controller.rb', line 20

def show
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/re_plan_workflows_controller.rb', line 49

def update
  update_params = params[:re_workflow] || {}
  @re_workflow.attributes = update_params.except(:code)
  if @re_workflow.save
    flash[:success] = 'Workflow Updated.'
    
    respond_to do |format|
      format.html do          
        redirect_to(change_re_plan_workflow_path(@re_plan, @re_workflow))
      end  
      format.js do
        render :action => "update"
      end
    end
  else
    render :action => "edit"
  end    
end