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

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

Constant Summary collapse

ACTS_PER_PAGE =

~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/history/set/all/history.rb ~~

Card.config.acts_per_page

Constants included from Format

Format::TEMPLATE_DIR

Constants included from Event::DelayedEvent

Event::DelayedEvent::DELAY_STAGES

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

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer

Methods included from Event

#event

Instance Method Details

#act_card?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'tmpsets/set/mod003-history/all/history.rb', line 67

def act_card?
  self == DirectorRegister.act_card
end

#actionable?Boolean

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

Returns:

  • (Boolean)


13
14
15
# File 'tmpsets/set/mod003-history/all/history.rb', line 13

def actionable?
  history? || respond_to?(:attachment)
end

#current_rev_nrObject



115
116
117
118
119
120
121
122
123
# File 'tmpsets/set/mod003-history/all/history.rb', line 115

def current_rev_nr
  @current_rev_nr ||= begin
    if intrusive_acts.first.actions.last.draft
      @intrusive_acts.size - 1
    else
      @intrusive_acts.size
    end
  end
end

#descendant_card_ids(parent_ids = [id]) ⇒ Object



132
133
134
135
136
# File 'tmpsets/set/mod003-history/all/history.rb', line 132

def descendant_card_ids parent_ids=[id]
  more_ids = Card.where("left_id IN (?)", parent_ids).pluck("id")
  more_ids += descendant_card_ids more_ids unless more_ids.empty?
  more_ids
end

#diff_argsObject



398
399
400
# File 'tmpsets/set/mod003-history/all/history.rb', line 398

def diff_args
  { format: :text }
end

#finalize_action?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'tmpsets/set/mod003-history/all/history.rb', line 30

def finalize_action?
  actionable? && current_action
end

#has_edits?Boolean

Returns:

  • (Boolean)


402
403
404
# File 'tmpsets/set/mod003-history/all/history.rb', line 402

def has_edits?
  Card::Act.where(actor_id: id).where("card_id IS NOT NULL").present?
end

#history?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'tmpsets/set/mod003-history/all/history.rb', line 6

def history?
  true
end

#included_card_idsObject



125
126
127
128
129
130
# File 'tmpsets/set/mod003-history/all/history.rb', line 125

def included_card_ids
  @included_card_ids ||=
    Card::Reference.select(:referee_id).where(
      ref_type: "I", referer_id: id
    ).pluck("referee_id").compact.uniq
end

#included_descendant_card_idsObject



138
139
140
# File 'tmpsets/set/mod003-history/all/history.rb', line 138

def included_descendant_card_ids
  included_card_ids & descendant_card_ids
end

#intrusive_acts(args = { with_drafts: true }) ⇒ Object

all acts with actions on self and on cards included in self



109
110
111
112
113
# File 'tmpsets/set/mod003-history/all/history.rb', line 109

def intrusive_acts args={ with_drafts: true }
  @intrusive_acts ||= begin
    Act.find_all_with_actions_on((included_card_ids << id), args)
  end
end

#intrusive_family_acts(args = {}) ⇒ Object

all acts with actions on self and on cards that are descendants of self and included in self



102
103
104
105
106
# File 'tmpsets/set/mod003-history/all/history.rb', line 102

def intrusive_family_acts args={}
  @intrusive_family_acts ||= begin
    Act.find_all_with_actions_on((included_descendant_card_ids << id), args)
  end
end

#rollback_request?Boolean

Returns:

  • (Boolean)


95
96
97
98
# File 'tmpsets/set/mod003-history/all/history.rb', line 95

def rollback_request?
  history? && Env && Env.params["action_ids"] &&
    Env.params["action_ids"].class == Array
end