Class: ReWorkflowsController

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

Instance Method Summary collapse

Instance Method Details

#addObject



93
94
95
# File 'app/controllers/re_workflows_controller.rb', line 93

def add
  @re_workflows = ReWorkflow.order_title.find(:all)
end

#changeObject



79
80
81
# File 'app/controllers/re_workflows_controller.rb', line 79

def change
  RulesEngine::Discovery.discover!
end

#copyObject



97
98
99
# File 'app/controllers/re_workflows_controller.rb', line 97

def copy
  @re_workflow_copy = ReWorkflow.new
end

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/re_workflows_controller.rb', line 24

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

#destroyObject



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/re_workflows_controller.rb', line 65

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

#duplicateObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/controllers/re_workflows_controller.rb', line 101

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    
    flash[:success] = 'Workflow Duplicated.'
    respond_to do |format|
      format.html do
        redirect_to(change_re_workflow_path(@re_workflow_copy))
      end  
      format.js do
        render :inline => "window.location.href = '#{change_re_workflow_path(@re_workflow_copy)}';"
      end
    end
  else
     render :action => "copy"  
  end  
end

#editObject



43
44
# File 'app/controllers/re_workflows_controller.rb', line 43

def edit    
end

#indexObject



13
14
15
# File 'app/controllers/re_workflows_controller.rb', line 13

def index
  @re_workflows = ReWorkflow.order_title.find(:all)
end

#newObject



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

def new
  @re_workflow = ReWorkflow.new
end

#planObject



86
87
88
89
90
91
# File 'app/controllers/re_workflows_controller.rb', line 86

def plan
  klass = RePlanWorkflow
  klass = klass.order_plan_title
  klass = klass.by_workflow_id(@re_workflow.id)
  @re_plan_workflows = klass.paginate(:include => :re_plan, :page => params[:page] || 1, :per_page => 10)
end

#previewObject



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

def preview
end

#showObject



17
18
# File 'app/controllers/re_workflows_controller.rb', line 17

def show
end

#updateObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/re_workflows_controller.rb', line 46

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_workflow_path(@re_workflow))
      end  
      format.js do
        render :action => "update"
      end
    end
  else
    render :action => "edit"
  end    
end