Class: Workarea::Admin::ReleaseViewModel

Inherits:
ApplicationViewModel
  • Object
show all
Includes:
CommentableViewModel
Defined in:
app/view_models/workarea/admin/release_view_model.rb

Instance Method Summary collapse

Methods included from CommentableViewModel

#comment_count, #comments, #has_comments?, #new_comments_for?, #subscribed_users

Instance Method Details

#additional_changesets_countObject



14
15
16
# File 'app/view_models/workarea/admin/release_view_model.rb', line 14

def additional_changesets_count
  [changeset_count - Workarea.config.per_page, 0].max
end

#calendar_atObject



38
39
40
# File 'app/view_models/workarea/admin/release_view_model.rb', line 38

def calendar_at
  model.publish_at || model.published_at
end

#calendar_onObject



42
43
44
# File 'app/view_models/workarea/admin/release_view_model.rb', line 42

def calendar_on
  calendar_at&.to_date
end

#changeset_countObject



10
11
12
# File 'app/view_models/workarea/admin/release_view_model.rb', line 10

def changeset_count
  @changeset_count ||= model.changesets.count
end

#changeset_summaryObject



22
23
24
25
26
27
# File 'app/view_models/workarea/admin/release_view_model.rb', line 22

def changeset_summary
  @changeset_summary ||=
    Release::Changeset.summary(model.id).map do |type|
      ChangesetSummaryViewModel.new(type)
    end
end

#changesets_with_releasableObject



29
30
31
32
33
34
35
36
# File 'app/view_models/workarea/admin/release_view_model.rb', line 29

def changesets_with_releasable
  @changesets_with_releasable ||= model
                    .changesets
                    .latest
                    .map { |c| ChangesetViewModel.wrap(c) }
                    .select { |changeset| changeset.root.present? }
                    .reject { |changeset| changeset.releasable.blank? }
end

#show_changeset_summary?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/view_models/workarea/admin/release_view_model.rb', line 18

def show_changeset_summary?
  changeset_count > Workarea.config.per_page
end

#timelineObject



6
7
8
# File 'app/view_models/workarea/admin/release_view_model.rb', line 6

def timeline
  @timeline ||= TimelineViewModel.new(model)
end

#undoesObject



50
51
52
53
# File 'app/view_models/workarea/admin/release_view_model.rb', line 50

def undoes
  return unless undoes?
  @undoes ||= ReleaseViewModel.wrap(model.undoes, options)
end

#undosObject



46
47
48
# File 'app/view_models/workarea/admin/release_view_model.rb', line 46

def undos
  @undos ||= ReleaseViewModel.wrap(model.undos, options)
end