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?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, phase_method, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file

Instance Method Details

#current_rev_nrObject



119
120
121
122
123
124
125
126
127
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 119

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



135
136
137
138
139
140
141
142
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 135

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



367
368
369
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 367

def diff_args
  { format: :text }
end

#has_edits?Boolean

Returns:

  • (Boolean)


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

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



129
130
131
132
133
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 129

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



144
145
146
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 144

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



113
114
115
116
117
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 113

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



106
107
108
109
110
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 106

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)


82
83
84
85
# File 'tmpsets/set/mod002-01_history/all/history.rb', line 82

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