Sha256: 18d808afff1d32393fa7b1a82e3b119087b954281b1ca72c7e7ae4805c50f6a2

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

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

      def model_name
        model.model_name.human
      end

      def current_component
        model.component
      end

      def new_amend_path
        decidim.new_amend_path(amendable_gid: model.to_sgid.to_s)
      end

      def new_amend_button_label
        t("button", scope: "decidim.amendments.amendable", model_name: model_name)
      end

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.17.2 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.17.1 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.16.1 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.17.0 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.16.0 app/cells/decidim/amendable/amend_button_card_cell.rb