Sha256: 8e8da7592336809e65c2175fd80f5160bf2fda1eba1ff5f6dac4ab07e05ff338

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    # This cell renders the button to join a conference.
    class JoinConferenceButtonCell < Decidim::ViewModel
      include Decidim::LayoutHelper
      include Decidim::SanitizeHelper
      include Decidim::Conferences::Engine.routes.url_helpers

      def show
        render
      end

      private

      delegate :current_user, to: :controller, prefix: false

      def allowed?
        options[:allowed]
      end

      def shows_remaining_slots?
        options[:show_remaining_slots] && model.available_slots.positive?
      end

      def button_classes
        return "button expanded button--sc" if big_button?
        "button card__button button--sc small"
      end

      def big_button?
        options[:big_button]
      end

      def i18n_join_text
        return I18n.t("join", scope: "decidim.conferences.conference.show") if model.has_available_slots?
        I18n.t("no_slots_available", scope: "decidim.conferences.conference.show")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-conferences-0.15.2 app/cells/decidim/conferences/join_conference_button_cell.rb
decidim-conferences-0.15.1 app/cells/decidim/conferences/join_conference_button_cell.rb