Sha256: cb84547b02a9a69b1d93aeea957c4a077dfc4fbed480039f7b6673490bdb3cba

Contents?: true

Size: 739 Bytes

Versions: 6

Compression:

Stored size: 739 Bytes

Contents

# -*- coding: utf-8 -*-
module TrophyHelper
  def display_trophy_link(user, id, args = {}, &_block)
    trophy = user.trophies.where(generic_file_id: id).first
    trophyclass = trophy ? "trophy-on" : "trophy-off"

    args[:add_text] ||= "Highlight File on Profile"
    args[:remove_text] ||= "Unhighlight File"
    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] = sufia.trophy_profile_path(user, file_id: id)
    link_to '#', class: args[:class], data: args[:data] do
      yield(text)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 app/helpers/trophy_helper.rb
sufia-6.6.1 app/helpers/trophy_helper.rb
sufia-6.6.0 app/helpers/trophy_helper.rb
sufia-6.5.0 app/helpers/trophy_helper.rb
sufia-6.4.0 app/helpers/trophy_helper.rb
sufia-6.3.0 app/helpers/trophy_helper.rb