Sha256: 44754d3b0f5181e8d8020c63b1cb16b3850cdecf1dc2598a73ce74ce6ff6aefe

Contents?: true

Size: 846 Bytes

Versions: 35

Compression:

Stored size: 846 Bytes

Contents

module Hyrax
  module TrophyHelper
    def display_trophy_link(user, id, args = {}, &_block)
      return unless user
      trophy = user.trophies.where(work_id: id).exists?
      trophyclass = trophy ? "trophy-on" : "trophy-off"

      args[:add_text] ||= t("hyrax.dashboard.my.action.highlight")
      args[:remove_text] ||= t("hyrax.dashboard.my.action.unhighlight")
      text = trophy ? args[:remove_text] : args[:add_text]
      args[:class] = [args[:class], "trophy-class #{trophyclass}"].compact.join(' ')
      args[:data] ||= {}
      args[:data]['add-text'] = args[:add_text]
      args[:data]['remove-text'] = args[:remove_text]

      args[:data][:url] = hyrax.trophy_work_path(id)
      link_to '#', class: args[:class], data: args[:data] do
        yield(text)
      end
    end
    # rubocop:enable Metrics/MethodLength
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.5 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.4 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.3 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.9.0 app/helpers/hyrax/trophy_helper.rb
hyrax-2.8.0 app/helpers/hyrax/trophy_helper.rb
hyrax-2.7.2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.7.1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.7.0 app/helpers/hyrax/trophy_helper.rb
hyrax-2.6.0 app/helpers/hyrax/trophy_helper.rb
hyrax-3.0.0.pre.rc1 app/helpers/hyrax/trophy_helper.rb
hyrax-3.0.0.pre.beta3 app/helpers/hyrax/trophy_helper.rb
hyrax-2.5.1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.5.0 app/helpers/hyrax/trophy_helper.rb
hyrax-3.0.0.pre.beta2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.4.1 app/helpers/hyrax/trophy_helper.rb
hyrax-3.0.0.pre.beta1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.4.0 app/helpers/hyrax/trophy_helper.rb