Improve exports and GUI
This commit is contained in:
parent
0a48759576
commit
fa1d5b8bce
13 changed files with 195 additions and 50 deletions
|
|
@ -32,4 +32,35 @@ module ApplicationHelper
|
|||
def turbo_stream_toast(content, alert)
|
||||
turbo_stream.append("toasts", partial: "layouts/toast", locals: { content:, alert: })
|
||||
end
|
||||
|
||||
|
||||
def dropdown_menu(items, klass: "")
|
||||
tag.details(class: "details-dropdown #{klass}") do
|
||||
tag.summary do
|
||||
tag.div(class: "details-dropdown-trigger") do
|
||||
tag.div(tag.i(class: "bi bi-three-dots-vertical"), class: "btn btn-outline-secondary")
|
||||
end
|
||||
end +
|
||||
tag.div(class: "details-dropdown-content bg-secondary") do
|
||||
tag.ul(class: "list-group") do
|
||||
safe_join(items.map do |item|
|
||||
tag.li(class: "list-group-item list-group-item-action#{ item[:color] ? " list-group-item-#{item[:color]}" : ""}") do
|
||||
text = item[:icon] ? tag.i(class: "bi bi-#{item[:icon]} me-2") + " #{item[:text]}".html_safe : item[:text]
|
||||
case item[:method]
|
||||
when nil, :get
|
||||
link_to(text, item[:href], class: "text-decoration-none text-body")
|
||||
else
|
||||
button_to(text,
|
||||
item[:href],
|
||||
method: item[:method],
|
||||
form_class: "no-padding",
|
||||
class: "btn btn-link text-decoration-none text-#{item[:color] ? "#{item[:color]}-emphasis" : "body"}",
|
||||
data: { turbo_confirm: item[:confirm] })
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,8 +25,22 @@ module SuccessCriteriaHelper
|
|||
end
|
||||
end
|
||||
|
||||
def success_criterion_menu(success_criterion, show_mode = true)
|
||||
dropdown_menu([
|
||||
{ text: show_mode ? "Bearbeiten" : "Bearbeiten abbrechen",
|
||||
icon: "pencil",
|
||||
href: show_mode ? edit_success_criterion_path(success_criterion) : success_criterion_path(success_criterion)},
|
||||
{ text: "Löschen",
|
||||
icon: "trash",
|
||||
href: success_criterion_path(success_criterion),
|
||||
color: :danger,
|
||||
method: :delete,
|
||||
confirm: "Bist du sicher?"}],
|
||||
klass: "mt-3 ms-auto")
|
||||
end
|
||||
|
||||
def success_criterion_edit_button(success_criterion, edit_mode)
|
||||
|
||||
def success_criterion_edit_button(success_criterion, edit_mode)
|
||||
path = if success_criterion.persisted?
|
||||
if edit_mode
|
||||
success_criterion
|
||||
|
|
@ -37,9 +51,9 @@ module SuccessCriteriaHelper
|
|||
else
|
||||
success_criterion.element
|
||||
end
|
||||
link_to tag.i(class: "bi bi-pencil"),
|
||||
link_to tag.i(class: "bi bi-pencil") + " Bearbeiten".html_safe,
|
||||
path,
|
||||
class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-body'}"
|
||||
class: "text-decoration-none xbtn xbtn-#{edit_mode ? 'link text-warning' : 'link text-body'}"
|
||||
end
|
||||
|
||||
def success_criterion_badge(content, extra_classes: "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue