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

Extended by:
AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



36
37
38
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 36

def self.link_options perms
  { denial: :blank, cache: :never, perms: perms }
end

Instance Method Details



85
86
87
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 85

def  purpose
  voo.title || t("account_#{purpose}")
end

#can_disable_roles?Boolean

Returns:

  • (Boolean)


80
81
82
83
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 80

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

#enabled_roles_cardObject



72
73
74
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 72

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

#interactive_roles_dropdownObject



67
68
69
70
# File 'platypus/tmp/set/gem-defaults/mod031-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


89
90
91
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 89

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


32
33
34
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 32

def navbar_item_views
  %i[my_card sign_out sign_up sign_in]
end


24
25
26
27
28
29
30
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 24

def navbar_items
  # removed invite for now
  navbar_item_views.map do |link_view|
    rendered = render link_view
    wrap_with_nav_item rendered if rendered.present?
  end.compact
end

#not_signed_in?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 93

def not_signed_in?
  !Auth.signed_in?
end

#role_listObject



76
77
78
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 76

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

#show_invite_link?Boolean

Returns:

  • (Boolean)


101
102
103
104
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 101

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)


97
98
99
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 97

def 
  not_signed_in? && Card.new(type: :signup).ok?(:create)
end

#view: coreObject



17
18
19
20
21
22
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 17

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 'platypus/tmp/set/gem-defaults/mod031-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 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 63

view :my_card, link_options(:signed_in?) do
  can_disable_roles? ? interactive_roles_dropdown : 
end

#view: sign_inObject



46
47
48
49
# File 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 46

view :sign_in, link_options(:not_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 'platypus/tmp/set/gem-defaults/mod031-layout/self/account_links.rb', line 51

view :sign_out, link_options(: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 'platypus/tmp/set/gem-defaults/mod031-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