Module: Card::Set::All::Html::Menu::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb

Instance Method Summary collapse

Instance Method Details

#board_iconObject



208
209
210
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 208

def board_icon
  icon_tag :board
end

Generates a link to a board with optional parameters.

Examples:

board_link(text: "Advanced", in_modal: true, confirm: true)

Parameters:

  • text (String) (defaults to: "")

    The text displayed on the link.

  • in_modal (Boolean) (defaults to: true)

    (true) Indicates whether the board link should open in a modal.

  • confirm (Boolean) (defaults to: false)

    (false) Indicates whether to show a confirmation for potential data loss.

Returns:

  • (String)

    The HTML code for the board link.



92
93
94
95
96
97
98
99
100
101
102
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 92

def board_link text: "", in_modal: true, confirm: false
  opts = {
    class: "board-link",
    title: "Advanced",
    "data-bs-toggle": "tooltip",
    "data-bs-placement": "bottom"
  }
  opts["data-slotter-mode"] = "modal-replace" if in_modal
  confirm_edit_loss opts if confirm
  link_to_view :board, "#{board_icon} #{text}", opts
end

#confirm_edit_loss(opts) ⇒ Object



212
213
214
215
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 212

def confirm_edit_loss opts
  add_class opts, "_confirm"
  opts["data-confirm-msg"] = t(:format_confirm_edit_loss)
end


154
155
156
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 154

def edit_in_board_link opts={}
  edit_link :board, *opts
end


158
159
160
161
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 158

def edit_link view=:edit, link_text: nil, text: "", modal: nil
  link_to_view view, link_text || "#{menu_icon} #{text}",
               edit_link_opts(modal: modal || :lg)
end

Generates options hash for an edit link with optional parameters.

Examples:

edit_link_opts(modal: "custom-modal")
#=> { class: 'edit-link', title: 'Edit', 'data-bs-toggle': 'tooltip',
      'data-bs-placement': 'bottom', 'data-slotter-mode': 'modal',
      'data-modal-class': 'modal-custom-modal' }

Parameters:

  • modal (Symbol) (defaults to: nil)

    (nil) The modal class to use for the edit link.

Returns:

  • (Hash)

    The options hash for the edit link.



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 174

def edit_link_opts modal: nil
  opts = {
    class: classy("edit-link"),
    title: "Edit",
    "data-bs-toggle": "tooltip",
    "data-bs-placement": "bottom"
  }
  if modal
    opts[:"data-slotter-mode"] = "modal"
    opts[:"data-modal-class"] = "modal-#{modal}"
  end
  opts
end


76
77
78
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 76

def edit_link_view
  :edit
end

#edit_viewObject



65
66
67
68
69
70
71
72
73
74
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 65

def edit_view
  case voo.edit
  when :inline
    :edit_inline
  when :full
    :edit
  else # :standard
    edit_link
  end
end

#full_page_cardObject



146
147
148
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 146

def full_page_card
  card
end

#full_page_iconObject



196
197
198
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 196

def full_page_icon
  icon_tag :full_page
end


126
127
128
129
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 126

def full_page_link text: ""
  link_to_card full_page_card, "#{full_page_icon} #{text}",
               class: classy("full-page-link")
end


104
105
106
107
108
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 104

def help_link text=nil, title=nil
  opts = help_popover_opts text, title
  add_class opts, "_card-menu-popover"
  link_to icon_tag(:help), opts
end

#help_popover_opts(text = nil, title = nil) ⇒ Object



110
111
112
113
114
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 110

def help_popover_opts text=nil, title=nil
  text ||= render_help_text
  opts = { "data-bs-placement": :left, class: "help-link" }
  popover_opts text, title, opts
end

#help_titleObject



116
117
118
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 116

def help_title
  "#{name_parts_links} (#{render_type}) #{full_page_link unless card.simple?}"
end


57
58
59
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 57

def menu_board_link
  voo.show?(:board_link) ? board_link(in_modal: false) : nil
end


46
47
48
49
50
51
52
53
54
55
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 46

def menu_edit_link
  case voo.edit
  when :inline
    edit_inline_link
  when :full
    edit_in_board_link
  else # :standard
    edit_link
  end
end


192
193
194
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 192

def menu_icon
  icon_tag "edit"
end


61
62
63
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 61

def menu_items
  [render_help_link, menu_edit_link, menu_board_link]
end


188
189
190
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 188

def menu_link_classes
  "nodblclick#{show_view?(:hover_link) ? ' _show-on-hover' : ''}"
end


204
205
206
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 204

def modal_icon
  icon_tag :modal
end


137
138
139
140
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 137

def modal_page_link text: ""
  modal_link "#{modal_icon} #{text}",
             path: { mark: card }, size: modal_page_size, class: "_modal-page-link"
end


142
143
144
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 142

def modal_page_size
  :xl
end


120
121
122
123
124
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 120

def name_parts_links
  card.name.parts.map do |part|
    link_to_card part
  end.join Card::Name.joint
end

#new_window_cardObject



150
151
152
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 150

def new_window_card
  full_page_card
end

#new_window_iconObject



200
201
202
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 200

def new_window_icon
  icon_tag :new_window
end


131
132
133
134
135
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 131

def new_window_link text: ""
  link_to_card new_window_card, "#{new_window_icon} #{text}",
               class: classy("new-window-link"),
               target: "window_#{rand 999}"
end


36
37
38
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 36

view :board_link, unknown: true do
  board_link
end

#view: edit_buttonObject



27
28
29
30
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 27

view :edit_button do
  view = voo.edit == :inline ? :edit_inline : :edit
  link_to_view view, "Edit", class: "btn btn-sm btn-outline-primary me-2"
end


23
24
25
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 23

view :edit_link, unknown: true, denial: :blank do
  edit_link edit_link_view
end


32
33
34
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 32

view :full_page_link do
  full_page_link
end

no caching because help_text view doesn’t cache, and we can’t have a stub in the data-content attribute or it will get html escaped.



42
43
44
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 42

view :help_link, cache: :never, unknown: true do
  help_link render_help_text, help_title
end


15
16
17
18
19
20
21
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 15

view :menu, denial: :blank, unknown: true do
  return "" unless card.known?

  # would be preferable to do this with unknown: :blank, but that fails with view
  # caching on, because voo always thinks it's the root.
  wrap_with(:div, class: "card-menu #{menu_link_classes}") { menu_items }
end


9
10
11
12
13
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/menu.rb', line 9

view :menu_block do
  wrap_with :div, class: "menu-block position-relative py-2" do
    [render_menu, " "]
  end
end