Module: Card::Set::Self::AccountLinks::HtmlFormat

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb,
card/tmpsets/set/mod031-card-mod-layout/self/account_links.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



34
35
36
37
38
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 34

def self.link_options opts={}
  options = { denial: :blank, cache: :never }.merge opts
  options[:perms] = ->(r) { yield r } if block_given?
  options.clone
end

Instance Method Details



89
90
91
92
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 89

def  purpose
  voo.title ||
    I18n.t(purpose, scope: "mod.card-mod-account.set.self.account_links")
end

#can_disable_roles?Boolean

Returns:

  • (Boolean)


84
85
86
87
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 84

def can_disable_roles?
  Auth.current_roles.size > 1 &&
    Card::Codename.exists?(:enabled_roles) # workaround for broken migrations
end

#enabled_roles_cardObject



76
77
78
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 76

def enabled_roles_card
  Auth.current.fetch :enabled_roles, new: { type_id: SessionID }
end

#interactive_roles_dropdownObject



67
68
69
70
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 67

def interactive_roles_dropdown
  nest(enabled_roles_card,
       view: :edit_inline, hide: %i[edit_inline_buttons name_formgroup])
end


94
95
96
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 94

def nav_link_class type
  "nav-link #{classy(type)}"
end


22
23
24
25
26
27
28
29
30
31
32
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 22

def navbar_items
  # removed invite for now
  links =
    %i[my_card sign_out sign_up sign_in].map do |link_view|
      render(link_view)
    end.compact

  links.map do |link|
    wrap_with_nav_item link
  end
end

#role_listObject



80
81
82
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 80

def role_list
  Auth.current_roles.map(&method(:link_to_card))
end

#show_invite_link?Boolean

Returns:

  • (Boolean)


102
103
104
105
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 102

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

#show_signup_link?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 98

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

#simple_roles_dropdownObject



72
73
74
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 72

def simple_roles_dropdown
  (&method(:link_to_card))
end

#view: coreObject



15
16
17
18
19
20
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 15

view :core, cache: :never do
  status_class = Auth.signed_in? ? "logged-in" : "logged-out"
  wrap_with :div, id: "logging", class: status_class do
    navbar_items.join "\n"
  end
end

#view: inviteObject



57
58
59
60
61
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 57

view :invite, link_options(&:show_invite_link?) do
  link_to_card :signup, (:invite),
               class: nav_link_class("invite-link"),
               path: { action: :new, mark: :signup }
end

#view: my_cardObject



63
64
65
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 63

view(:my_card, link_options { Auth.signed_in? }) do
  can_disable_roles? ? interactive_roles_dropdown : simple_roles_dropdown
end

#view: sign_inObject



46
47
48
49
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 46

view(:sign_in, link_options { !Auth.signed_in? }) do
  link_to_card :signin, (:sign_in),
               class: nav_link_class("signin-link")
end

#view: sign_outObject



51
52
53
54
55
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 51

view(:sign_out, link_options { Auth.signed_in? }) do
  link_to_card :signin, (:sign_out),
               class: nav_link_class("signout-link"),
               path: { action: :delete }
end

#view: sign_upObject



40
41
42
43
44
# File 'card/tmpsets/set/mod030-card-mod-layout/self/account_links.rb', line 40

view :sign_up, link_options(&:show_signup_link?) do
  link_to_card :signup, (:sign_up),
               class: nav_link_class("signup-link"),
               path: { action: :new, mark: :signup }
end