mod/01_history/set/all/history.rb in card-1.15.2 vs mod/01_history/set/all/history.rb in card-1.15.3
- old
+ new
@@ -1,7 +1,11 @@
REVISIONS_PER_PAGE = Card.config.revisions_per_page
+def history?
+ true
+end
+
# must be called on all actions and before :set_name, :process_subcards and :validate_delete_children
def create_act_and_action
@current_act = if @supercard
@supercard.current_act || @supercard.acts.build(:ip_address=>Env.ip)
else
@@ -16,15 +20,15 @@
end
end
-event(:create_act_and_action_for_save, :before=>:process_subcards, :on=>:save) { create_act_and_action }
-event(:create_act_and_action_for_delete, :before =>:validate_delete_children, :on=>:delete) { create_act_and_action }
+event(:create_act_and_action_for_save, :before=>:process_subcards, :on=>:save, :when=>proc {|c| c.history?} ) { create_act_and_action }
+event(:create_act_and_action_for_delete, :before =>:validate_delete_children, :on=>:delete, :when=>proc {|c| c.history? }) { create_act_and_action }
-event :remove_empty_act, :after=>:extend do
+event :remove_empty_act, :after=>:extend, :when=>proc {|c| c.history? } do
# if not @supercard and not @current_act.actions.empty?
# @current_act.save
# end
@current_act.reload
if not @supercard and @current_act.actions.empty?
@@ -33,10 +37,10 @@
end
end
-event :rollback_actions, :before=>:approve, :on=>:update, :when=>proc{ |c| Env and Env.params['action_ids'] and Env.params['action_ids'].class == Array} do
+event :rollback_actions, :before=>:approve, :on=>:update, :when=>proc{ |c| c.history? && Env && Env.params['action_ids'] && Env.params['action_ids'].class == Array} do
revision = { :subcards => {}}
rollback_actions = Env.params['action_ids'].map do |a_id|
Action.fetch(a_id) || nil
end
rollback_actions.each do |action|