Sha256: 6f9e5f62656423766ad316624be477eb9f9f692cd0ea43723242754fa47676e6

Contents?: true

Size: 1000 Bytes

Versions: 46

Compression:

Stored size: 1000 Bytes

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.amendable_fields.to_sentence)
        end
      end

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

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-core-0.23.3 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.23.2 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.23.1 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.23.1.rc1 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.23.0 app/cells/decidim/amendable/amend_button_card_cell.rb
decidim-core-0.22.0 app/cells/decidim/amendable/amend_button_card_cell.rb