Sha256: b24a0a11c7382ad7a735bbe9eed31db38419970b03d41aaf5beabe1349b2c040

Contents?: true

Size: 1.23 KB

Versions: 46

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Decidim
  module Amendable
    # This cell renders the button to amend the given resource.
    class PromoteButtonCardCell < Decidim::ViewModel
      delegate :current_user, to: :controller, prefix: false

      def emendation
        @emendation ||= model
      end

      def model_name
        model.model_name.human
      end

      def current_component
        model.component
      end

      def promote_amend_path
        decidim.promote_amend_path(model.amendment)
      end

      def promote_amend_button_label
        t("promote_button", scope: "decidim.amendments.amendable", model_name: model_name)
      end

      def promote_confirm_text
        t("promote_confirm_text", scope: "decidim.amendments.amendable")
      end

      def promote_amend_help_text
        content_tag :small do
          t("promote_help_text",
            scope: "decidim.amendments.amendable",
            model_name: model_name.downcase,
            amendable_fields: model.amendable_fields.to_sentence)
        end
      end

      def decidim
        Decidim::Core::Engine.routes.url_helpers
      end

      def button_classes
        "amend_button_card_cell button expanded button--icon button--sc"
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.8 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.7 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.6 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.10 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.9 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.5 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.8 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.4 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.3 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.7 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.5 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.2 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.1 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.4 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.0 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.3 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.0.rc2 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.27.0.rc1 app/cells/decidim/amendable/promote_button_card_cell.rb
decidim-core-0.26.2 app/cells/decidim/amendable/promote_button_card_cell.rb