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



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

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.



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

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



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

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


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

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


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

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.



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

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


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

def edit_link_view
  :edit
end

#edit_viewObject



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

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

#full_page_cardObject



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

def full_page_card
  card
end

#full_page_iconObject



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

def full_page_icon
  icon_tag :full_page
end


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

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


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

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



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

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



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

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


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

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


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

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


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

def menu_icon
  icon_tag "edit"
end


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

def menu_items
  [render_help_link, menu_edit_link, menu_board_link]
end


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

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


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

def modal_icon
  icon_tag :modal
end


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

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


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

def modal_page_size
  :xl
end


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

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

#new_window_cardObject



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

def new_window_card
  full_page_card
end

#new_window_iconObject



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

def new_window_icon
  icon_tag :new_window
end


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

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


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

view :board_link, unknown: true do
  board_link
end

#view: edit_buttonObject



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

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


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

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


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

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.



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

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


15
16
17
18
19
20
# 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