Sha256: 36b6162df2057729c628f8525cce548054349367601ad13aa6d53975822f4205

Contents?: true

Size: 913 Bytes

Versions: 12

Compression:

Stored size: 913 Bytes

Contents

# -*- coding: utf-8 -*-
module Hyrax
  module TrophyHelper
    # rubocop:disable Metrics/MethodLength
    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

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.rc3 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.rc2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.rc1 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.beta5 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.beta4 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.beta3 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.beta2 app/helpers/hyrax/trophy_helper.rb
hyrax-2.0.0.beta1 app/helpers/hyrax/trophy_helper.rb