Sha256: 7878e08c927c13800d13d216f3bdde05fb07a5c7e2322e3f43d78b586365ba17

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

format :html do
  def item_links args
    [
      optional_render(:my_card, args),
      optional_render(:invite, args),
      optional_render(:sign_out, args),
      optional_render(:sign_up, args),
      optional_render(:sign_in, args)
    ]
  end

  view :sign_up, perms: ->(r) { r.show_signup_link? },
                 denial: :blank do |_args|
    # 'Sign up'
    link_to(I18n.t(:sign_up, scope: "mod.standard.set.self.account_links"),
            card_path("account/signup"), id: "signup-link")
  end

  view :sign_in, perms: ->(_r) { !Auth.signed_in? },
                 denial: :blank do |_args|
    # 'Sign in'
    link_to(I18n.t(:sign_in, scope: "mod.standard.set.self.account_links"),
            card_path(":signin"), id: "signin-link")
  end

  view :invite, perms: ->(r) { r.show_invite_link? },
                denial: :blank do |_args|
    # 'Invite'
    link_to(I18n.t(:invite, scope: "mod.standard.set.self.account_links"),
            card_path("account/signup"), id: "invite-a-friend-link")
  end

  view :sign_out, perms: ->(_r) { Auth.signed_in? },
                  denial: :blank do |_args|
    # 'Sign out'
    link_to(I18n.t(:sign_out, scope: "mod.standard.set.self.account_links"),
            card_path("delete/:signin"), id: "signout-link")
  end

  view :my_card, perms: ->(_r) { Auth.signed_in? },
                 denial: :blank do |_args|
    card_link(Auth.current.cardname, id: "my-card-link")
  end

  view :raw do |args|
    item_links(args).join " "
  end

  view :core do |args|
    content_tag :span, id: "logging" do
      render_raw args
    end
  end

  def show_signup_link?
    !Auth.signed_in? && Card.new(type_id: Card::SignupID).ok?(:create)
  end

  def show_invite_link?
    Auth.signed_in? &&
      Card.new(type_id: Card.default_accounted_type_id).ok?(:create)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.19.4 mod/account/set/self/account_links.rb
card-1.19.3 mod/account/set/self/account_links.rb
card-1.19.2 mod/account/set/self/account_links.rb
card-1.19.1 mod/account/set/self/account_links.rb
card-1.19.0 mod/account/set/self/account_links.rb