Module: Card::Set::All::History::Events

Extended by:
Card::Set
Defined in:
tmpsets/set/mod005-history/all/history/events.rb

Overview

Set: All cards (History, Events)

must be called on all actions and before :set_name, :process_subcards and

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



8
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 8

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/history/set/all/history/events.rb"; end

Instance Method Details

#actionable?Boolean

can we store an action? (can be overridden, eg in files)

Returns:

  • (Boolean)


23
24
25
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 23

def actionable?
  history?
end

#edit_conflict?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 31

def edit_conflict?
  last_action_id_before_edit &&
    last_action_id_before_edit.to_i != last_action_id &&
    (la = last_action) &&
    la.act.actor_id != Auth.current_id
end

#finalize_action?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 83

def finalize_action?
  actionable? && current_action
end

#remove_empty_act?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 104

def remove_empty_act?
  act_card? && ActManager.act&.ar_actions&.reload&.empty?
end

#store_card_changesObject



62
63
64
65
66
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 62

def store_card_changes
  store_each_history_field @current_action.id, changed_fields do |field|
    self[field]
  end
end

#store_card_changes_for_create_actionObject

changes for the create action are stored after the first update



56
57
58
59
60
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 56

def store_card_changes_for_create_action
  store_each_history_field create_action.id do |field|
    attribute_before_act field
  end
end

#store_each_history_field(action_id, fields = nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'tmpsets/set/mod005-history/all/history/events.rb', line 68

def store_each_history_field action_id, fields=nil
  fields ||= Card::Change::TRACKED_FIELDS
  if false # Card::Change.supports_import?
    # attach.feature fails with this
    values = fields.map.with_index { |field, index| [index, yield(field), action_id] }
    Card::Change.import [:field, :value, :card_action_id], values #, validate: false
  else
    fields.each do |field|
      Card::Change.create field: field,
                          value: yield(field),
                          card_action_id: action_id
    end
  end
end