mod/01_history/set/all/history.rb in card-1.17.4 vs mod/01_history/set/all/history.rb in card-1.18.0

- old
+ new

@@ -4,20 +4,24 @@ 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? || 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 +# event :assign_act, +# after: :identify_action, +# when: proc { |c| c.history? || c.respond_to?(:attachment) } do +# @current_act = (@supercard && @supercard.current_act) || +# Card::Act.create(ip_address: Env.ip) +# assign_action +# end +# +event :assign_action, :initialize, + when: proc { |c| c.history? || c.respond_to?(:attachment) } do + @current_act = director.need_act @current_action = Card::Action.create( - card_act_id: @current_act.id, action_type: @action, + card_act_id: @current_act.id, + action_type: @action, draft: (Env.params['draft'] == 'true') ) if @supercard && @supercard != self @current_action.super_action = @supercard.current_action end @@ -27,11 +31,12 @@ (history? || respond_to?(:attachment)) && current_action 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.finalize_action? } do +event :finalize_action, :finalize, + when: proc { |c| c.finalize_action? } do @changed_fields = Card::TRACKED_FIELDS.select do |f| changed_attributes.member? f end if @changed_fields.present? @changed_fields.each do |f| @@ -55,12 +60,12 @@ else @current_act.update_attributes! card_id: id end end -event :rollback_actions, - before: :approve, on: :update, +event :rollback_actions, :prepare_to_validate, + on: :update, when: proc { |c| c.rollback_request? } do revision = { subcards: {} } rollback_actions = Env.params['action_ids'].map do |a_id| Action.fetch(a_id) || nil end @@ -134,13 +139,11 @@ end def descendant_card_ids parent_ids=[id] more_ids = Card.where('left_id IN (?)', parent_ids).pluck('id') - if !more_ids.empty? - more_ids += descendant_card_ids more_ids - end + more_ids += descendant_card_ids more_ids unless more_ids.empty? more_ids end def included_descendant_card_ids included_card_ids & descendant_card_ids @@ -300,14 +303,14 @@ ) end def wrap_diff field, content return '' unless content.present? - %{ + %( <span class="#{field}-diff"> #{content} </span> - } + ) end def name_changes action, hide_diff=false old_name = (name = action.old_values[:name]) && showname(name).to_s if action.new_name?