Class: RePlanWorkflowRulesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

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

#destroyObject



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

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

  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
  
end

#editObject



68
69
70
71
72
73
74
75
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 68

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

#errorObject



31
32
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 31

def error
end

#helpObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 21

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
  else
    @rule = @rule_class.new  
  end
end

#move_downObject



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 129

def move_down
  @re_rule.move_lower
  flash[:success] = 'Rule Moved Down.'      
  
  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
end

#move_upObject



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

def move_up
  @re_rule.move_higher
  flash[:success] = 'Rule Moved Up.'      
  
  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
end

#newObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 34

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/controllers/re_plan_workflow_rules_controller.rb', line 77

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