Model menus, modal edit and layout improvements
This commit is contained in:
parent
7b0f05a448
commit
70500c49a1
35 changed files with 1079 additions and 148 deletions
|
|
@ -35,10 +35,10 @@ module ApplicationHelper
|
|||
|
||||
|
||||
def dropdown_menu(items, klass: "")
|
||||
tag.details(class: "details-dropdown #{klass}") do
|
||||
tag.details(class: "details-dropdown #{klass}", data: { controller: "dropdown-menu" }) 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")
|
||||
tag.div(tag.i(class: "bi bi-three-dots"), class: "btn btn-outline-body")
|
||||
end
|
||||
end +
|
||||
tag.div(class: "details-dropdown-content bg-secondary") do
|
||||
|
|
@ -48,7 +48,7 @@ module ApplicationHelper
|
|||
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: "#{c}")
|
||||
link_to(text, item[:href], class: "#{c}", data: { turbo_frame: item[:turbo_frame], action: item[:action] })
|
||||
else
|
||||
button_to(text,
|
||||
item[:href],
|
||||
|
|
@ -61,4 +61,8 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def modal?
|
||||
turbo_frame_request_id == "modal"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ElementsHelper
|
||||
def element_menu(element)
|
||||
dropdown_menu([
|
||||
{ text: "Bearbeiten",
|
||||
icon: "pencil",
|
||||
href: edit_element_path(element),
|
||||
turbo_frame: "modal",
|
||||
color: "body" },
|
||||
{ text: "Löschen",
|
||||
icon: "trash",
|
||||
href: element_path(element),
|
||||
color: :danger,
|
||||
method: :delete,
|
||||
confirm: "Bist du sicher?" } ],
|
||||
klass: "ms-auto")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,2 +1,27 @@
|
|||
module PagesHelper
|
||||
def page_menu(page)
|
||||
dropdown_menu([
|
||||
{
|
||||
text: "Alle zu [s]",
|
||||
href: "#",
|
||||
action: "click->details-list#closeAll"
|
||||
},
|
||||
{
|
||||
text: "Alle auf [a]",
|
||||
href: "#",
|
||||
action: "click->details-list#openAll"
|
||||
},
|
||||
{ text: "Bearbeiten",
|
||||
icon: "pencil",
|
||||
href: edit_page_path(page),
|
||||
turbo_frame: "modal",
|
||||
color: "body" },
|
||||
{ text: "Löschen",
|
||||
icon: "trash",
|
||||
href: page_path(page),
|
||||
color: :danger,
|
||||
method: :delete,
|
||||
confirm: "Bist du sicher?" } ],
|
||||
klass: "ms-auto")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,19 +27,20 @@ module SuccessCriteriaHelper
|
|||
|
||||
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")
|
||||
{ text: "Bearbeiten",
|
||||
icon: "pencil",
|
||||
href: edit_success_criterion_path(success_criterion),
|
||||
turbo_frame: "modal",
|
||||
color: "body" },
|
||||
{ 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)
|
||||
path = if success_criterion.persisted?
|
||||
if edit_mode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue