Class: ReWorkflowRulesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/re_workflow_rules_controller.rb', line 39

def create
  @re_rule = ReRule.new(:re_workflow_id => @re_workflow.id, :rule_class_name => params[:rule_class_name])
  if @re_rule.rule.nil?       
    render :action => "error"
    return      
  end
  
  @re_rule.rule_attributes = params
  if @re_rule.valid? && @re_rule.save
    flash[:success] = 'Rule Created.'      
  
    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 => "new"
  end
end

#destroyObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/controllers/re_workflow_rules_controller.rb', line 95

def destroy
  @re_rule.destroy
  flash[:success] = 'Rule Deleted.'

  respond_to do |format|
    format.html do
      redirect_to(change_re_workflow_path(@re_workflow))
    end  
    format.js do
      render :action => "update"
    end
  end
  
end

#editObject



63
64
65
66
67
68
69
70
# File 'app/controllers/re_workflow_rules_controller.rb', line 63

def edit
  if @re_rule.rule.nil? 
    render :action => "error"
    return
  end
  
  render :action => "edit"      
end

#errorObject



26
27
# File 'app/controllers/re_workflow_rules_controller.rb', line 26

def error
end

#helpObject



17
18
19
20
21
22
23
24
# File 'app/controllers/re_workflow_rules_controller.rb', line 17

def help
  @rule_class = RulesEngine::Discovery.rule_class(params[:rule_class_name])
  
  if @rule_class.nil?
    flash[:error] = "#{params[:rule_class]} : class not found."
    render :error
  end
end

#move_downObject



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/controllers/re_workflow_rules_controller.rb', line 124

def move_down
  @re_rule.move_lower
  flash[:success] = 'Rule Moved Down.'      
  
  respond_to do |format|
    format.html do          
      redirect_to(change_re_workflow_path(@re_workflow))
    end  
    format.js do
      render :action => "update"
    end
  end
end

#move_upObject



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'app/controllers/re_workflow_rules_controller.rb', line 110

def move_up
  @re_rule.move_higher
  flash[:success] = 'Rule Moved Up.'      
  
  respond_to do |format|
    format.html do          
      redirect_to(change_re_workflow_path(@re_workflow))
    end  
    format.js do
      render :action => "update"
    end
  end
end

#newObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/re_workflow_rules_controller.rb', line 29

def new
  @re_rule = ReRule.new(:re_workflow_id => @re_workflow.id, :rule_class_name => params[:rule_class_name])
  if @re_rule.rule.nil? 
    render :action => "error"
    return
  end
  
  render :action => "new"      
end

#updateObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/re_workflow_rules_controller.rb', line 72

def update
  if @re_rule.rule.nil? 
    render :action => "error"
    return
  end
  
  @re_rule.rule_attributes = params
  if @re_rule.valid? && @re_rule.save
    flash[:success] = 'Rule 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