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

Extended by:
Card::Set
Defined in:
tmpsets/set/mod002-01_history/all/history.rb

Constant Summary collapse

REVISIONS_PER_PAGE =

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

Card.config.revisions_per_page

Instance Method Summary collapse

Methods included from Card::Set

abstract_set?, all_set?, clean_empty_module_from_hash, clean_empty_modules, define_on_format, each_format, ensure_set, extended, format, include_set, include_set_formats, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, stage_method, view, write_tmp_file

Methods included from Trait

#card_accessor, #card_reader, #card_writer

Methods included from Event

#define_event, #event

Instance Method Details

#current_rev_nrObject



123
124
125
126
127
128
129
130
131
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 123

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



139
140
141
142
143
144
145
146
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 139

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
end

#diff_argsObject



372
373
374
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 372

def diff_args
  { format: :text }
end

#finalize_action?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 29

def finalize_action?
  (history? || respond_to?(:attachment)) && current_action
end

#has_edits?Boolean

Returns:

  • (Boolean)


376
377
378
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 376

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/mod002-01_history/all/history.rb', line 6

def history?
  true
end

#included_card_idsObject



133
134
135
136
137
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 133

def 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



148
149
150
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 148

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



117
118
119
120
121
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 117

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



110
111
112
113
114
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 110

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)


86
87
88
89
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 86

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