mod/01_history/set/all/history.rb in card-1.16.4 vs mod/01_history/set/all/history.rb in card-1.16.5

- old
+ new

@@ -3,11 +3,11 @@ def history? true end # must be called on all actions and before :set_name, :process_subcards and :validate_delete_children -event :assign_act, :before=>:prepare, :when=>proc {|c| c.history?} do +event :assign_act, :before=>:prepare, :when=>proc {|c| c.history? || c.respond_to?(:attachment) } do @current_act = (@supercard && @supercard.current_act) || Card::Act.create(:ip_address=>Env.ip) end event :assign_action, :after=>:assign_act do @current_action = Card::Action.create(:card_act_id=>@current_act.id, :action_type=>@action, :draft=>(Env.params['draft'] == 'true') ) @@ -17,21 +17,21 @@ end # stores changes in the changes table and assigns them to the current action # removes the action if there are no changes -event :finalize_action, :after =>:stored, :when=>proc {|c| c.history? && c.current_action} do +event :finalize_action, :after =>:stored, :when=>proc {|c| (c.history? || c.respond_to?(:attachment)) && c.current_action} do @changed_fields = Card::TRACKED_FIELDS.select{ |f| changed_attributes.member? f } if @changed_fields.present? @changed_fields.each{ |f| Card::Change.create :field => f, :value => self[f], :card_action_id=>@current_action.id } @current_action.update_attributes! :card_id => id elsif @current_action.card_changes(true).empty? @current_action.delete @current_action = nil end end -event :finalize_act, :after=>:finalize_action, :when=>proc {|c| c.history? && !c.supercard } do +event :finalize_act, :after=>:finalize_action, :when=>proc {|c| !c.supercard } do if @current_act.actions(true).empty? @current_act.delete @current_act = nil else @current_act.update_attributes! :card_id=>id