Sha256: f97d3f83fc76ee30a4372ae9863bbdf6c35cd5322415fa599716043ca4afc7fe

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Workarea
  module Admin
    class ReleaseViewModel < ApplicationViewModel
      include CommentableViewModel

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

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

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

      def show_changeset_summary?
        changeset_count > Workarea.config.per_page
      end

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

      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

      def calendar_at
        model.publish_at || model.published_at
      end

      def calendar_on
        calendar_at&.to_date
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/view_models/workarea/admin/release_view_model.rb
workarea-admin-3.5.26 app/view_models/workarea/admin/release_view_model.rb
workarea-admin-3.5.25 app/view_models/workarea/admin/release_view_model.rb