mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 15:35:22 +02:00
Test fixes
This commit is contained in:
parent
49501be724
commit
a61a752341
11 changed files with 36 additions and 34 deletions
|
@ -35,4 +35,4 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</turbo-frame>
|
||||
</turbo-frame>
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
class DialogComponent < ViewComponent::Base
|
||||
renders_one :header, ->(title: nil, subtitle: nil, hide_close_icon: false, **opts, &block) do
|
||||
content_tag(:header, class: "px-4 flex flex-col gap-2", **opts) do
|
||||
title_div = content_tag(:div, class: "flex items-center justify-between gap-2") do
|
||||
renders_one :header, ->(title: nil, subtitle: nil, hide_close_icon: false, **opts, &block) do
|
||||
content_tag(:header, class: "px-4 flex flex-col gap-2", **opts) do
|
||||
title_div = content_tag(:div, class: "flex items-center justify-between gap-2") do
|
||||
title = content_tag(:h2, title, class: class_names("font-medium text-primary", drawer? ? "text-lg" : "")) if title
|
||||
close_icon = render ButtonComponent.new(variant: "icon", class: "ml-auto", icon: "x", tabindex: "-1", data: { action: "dialog#close" }) unless hide_close_icon
|
||||
safe_join([title, close_icon].compact)
|
||||
safe_join([ title, close_icon ].compact)
|
||||
end
|
||||
|
||||
subtitle = content_tag(:p, subtitle, class: "text-sm text-secondary") if subtitle
|
||||
|
||||
block_content = capture(&block) if block
|
||||
|
||||
safe_join([title_div, subtitle, block_content].compact)
|
||||
safe_join([ title_div, subtitle, block_content ].compact)
|
||||
end
|
||||
end
|
||||
|
||||
renders_one :body
|
||||
|
||||
renders_many :actions, ->(cancel_action: false, **button_opts) do
|
||||
|
||||
renders_many :actions, ->(cancel_action: false, **button_opts) do
|
||||
merged_opts = if cancel_action
|
||||
button_opts.merge(type: "button", data: { action: "modal#close" })
|
||||
else
|
||||
button_opts
|
||||
end
|
||||
|
||||
render ButtonComponent.new(**merged_opts)
|
||||
|
||||
render ButtonComponent.new(**merged_opts)
|
||||
end
|
||||
|
||||
renders_many :sections, ->(title:, **disclosure_opts, &block) do
|
||||
render DisclosureComponent.new(title: title, align: :right, **disclosure_opts) do
|
||||
renders_many :sections, ->(title:, **disclosure_opts, &block) do
|
||||
render DisclosureComponent.new(title: title, align: :right, **disclosure_opts) do
|
||||
block.call
|
||||
end
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ class DialogComponent < ViewComponent::Base
|
|||
else
|
||||
"items-center justify-center"
|
||||
end
|
||||
|
||||
|
||||
class_names(
|
||||
"flex h-full w-full",
|
||||
variant_classes
|
||||
|
@ -75,14 +75,14 @@ class DialogComponent < ViewComponent::Base
|
|||
)
|
||||
end
|
||||
|
||||
def merged_opts
|
||||
def merged_opts
|
||||
merged_opts = opts.dup
|
||||
data = merged_opts.delete(:data) || {}
|
||||
|
||||
data[:controller] = ["dialog", "hotkey", data[:controller]].compact.join(" ")
|
||||
data[:controller] = [ "dialog", "hotkey", data[:controller] ].compact.join(" ")
|
||||
data[:dialog_auto_open_value] = auto_open
|
||||
data[:dialog_reload_on_close_value] = reload_on_close
|
||||
data[:action] = ["mousedown->dialog#clickOutside", data[:action]].compact.join(" ")
|
||||
data[:action] = [ "mousedown->dialog#clickOutside", data[:action] ].compact.join(" ")
|
||||
data[:hotkey] = "esc:dialog#close"
|
||||
merged_opts[:data] = data
|
||||
|
||||
|
@ -92,4 +92,4 @@ class DialogComponent < ViewComponent::Base
|
|||
def drawer?
|
||||
variant == :drawer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%= render DialogComponent.new do |dialog| %>
|
||||
<% dialog.with_header(title: t(".title")) %>
|
||||
<% dialog.with_body do %>
|
||||
<%= render "form", family_merchant: @family_merchant %>
|
||||
<%= render "form", family_merchant: @merchant %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<%= styled_form_with model: @entry, url: transactions_path, class: "space-y-4 text-subdued", data: { controller: "transaction-form" } do |f| %>
|
||||
<%# locals: (entry:, income_categories:, expense_categories:) %>
|
||||
|
||||
<%= styled_form_with model: entry, url: transactions_path, class: "space-y-4 text-subdued", data: { controller: "transaction-form" } do |f| %>
|
||||
<% if entry.errors.any? %>
|
||||
<%= render "shared/form_errors", model: entry %>
|
||||
<% end %>
|
||||
|
@ -21,7 +23,7 @@
|
|||
|
||||
<%= f.money_field :amount, label: t(".amount"), required: true %>
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
<% categories = params[:nature] == "inflow" ? @income_categories : @expense_categories %>
|
||||
<% categories = params[:nature] == "inflow" ? income_categories : expense_categories %>
|
||||
<%= ef.collection_select :category_id, categories, :id, :name, { prompt: t(".category_prompt"), label: t(".category") } %>
|
||||
<% end %>
|
||||
<%= f.date_field :date, label: t(".date"), required: true, min: Entry.min_supported_date, max: Date.current, value: Date.current %>
|
||||
|
|
|
@ -22,4 +22,4 @@
|
|||
|
||||
<% dialog.with_action(cancel_action: true, text: "Cancel", variant: "ghost") %>
|
||||
<% dialog.with_action(text: "Save", data: { bulk_select_scope_param: "bulk_update", action: "bulk-select#submitBulkRequest" }) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%= render DialogComponent.new do |dialog| %>
|
||||
<% dialog.with_header(title: "New transaction") %>
|
||||
<% dialog.with_body do %>
|
||||
<%= render "form", transaction: @transaction %>
|
||||
<%= render "form", entry: @entry, income_categories: @income_categories, expense_categories: @expense_categories %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -145,4 +145,4 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -101,4 +101,4 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -63,4 +63,4 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -4,7 +4,7 @@ class DialogComponentPreview < ViewComponent::Preview
|
|||
render DialogComponent.new(variant: "modal") do |dialog|
|
||||
dialog.with_header(title: "Sample modal title")
|
||||
|
||||
dialog.with_body do
|
||||
dialog.with_body do
|
||||
"Welcome to Maybe! This is some test modal content."
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ class DialogComponentPreview < ViewComponent::Preview
|
|||
dialog.with_action(text: "Submit")
|
||||
|
||||
if show_overflow
|
||||
content_tag(:div, class: "p-4 font-semibold h-[800px] bg-surface-inset") do
|
||||
content_tag(:div, class: "p-4 font-semibold h-[800px] bg-surface-inset") do
|
||||
"Example of overflow content"
|
||||
end
|
||||
end
|
||||
|
@ -21,15 +21,15 @@ class DialogComponentPreview < ViewComponent::Preview
|
|||
|
||||
# @param show_overflow toggle
|
||||
def drawer(show_overflow: false)
|
||||
render DialogComponent.new(variant: "drawer") do |dialog|
|
||||
render DialogComponent.new(variant: "drawer") do |dialog|
|
||||
dialog.with_header(title: "Drawer title")
|
||||
|
||||
dialog.with_body do
|
||||
dialog.with_section(title: "Section 1", open: true) do
|
||||
dialog.with_body do
|
||||
dialog.with_section(title: "Section 1", open: true) do
|
||||
content_tag(:div, "Section 1 content", class: "p-2")
|
||||
end
|
||||
|
||||
dialog.with_section(title: "Section 2", open: true) do
|
||||
dialog.with_section(title: "Section 2", open: true) do
|
||||
content_tag(:div, "Section 2 content", class: "p-2")
|
||||
end
|
||||
end
|
||||
|
@ -37,10 +37,10 @@ class DialogComponentPreview < ViewComponent::Preview
|
|||
dialog.with_action(text: "Example action")
|
||||
|
||||
if show_overflow
|
||||
content_tag(:div, class: "p-4 font-semibold h-[800px] bg-surface-inset") do
|
||||
content_tag(:div, class: "p-4 font-semibold h-[800px] bg-surface-inset") do
|
||||
"Example of overflow content"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue