Sha256: 4412575fdf71b959010b4de39cbcac5ffd0156aa3baca527e91c18e751b61a77

Contents?: true

Size: 736 Bytes

Versions: 13

Compression:

Stored size: 736 Bytes

Contents

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sufia-7.4.1 app/helpers/trophy_helper.rb
sufia-7.4.0 app/helpers/trophy_helper.rb
sufia-7.3.1 app/helpers/trophy_helper.rb
sufia-7.3.0 app/helpers/trophy_helper.rb
sufia-7.3.0.rc3 app/helpers/trophy_helper.rb
sufia-7.3.0.rc2 app/helpers/trophy_helper.rb
sufia-7.3.0.rc1 app/helpers/trophy_helper.rb
sufia-7.2.0 app/helpers/trophy_helper.rb
sufia-7.1.0 app/helpers/trophy_helper.rb
sufia-7.0.0 app/helpers/trophy_helper.rb
sufia-7.0.0.rc2 app/helpers/trophy_helper.rb
sufia-7.0.0.rc1 app/helpers/trophy_helper.rb
sufia-7.0.0.beta4 app/helpers/trophy_helper.rb