Skip to content

Commit

Permalink
refactor dialog to have form and footer divided correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 5, 2024
1 parent cec6cb7 commit cd57025
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<%= render(Primer::Alpha::Dialog.new(title: 'Log Time', size: :large, id: MODAL_ID, data: { "controller" => "time-entry", "application-target" => "dynamic" })) do |d| %>
<% d.with_header(variant: :large, mb: 3) %>
<% d.with_body do %>
<%= render(TimeEntries::TimeEntryFormComponent.new(time_entry: time_entry)) %>
<% end %>
<% d.with_footer(variant: :large) do %>
<%= render(Primer::ButtonComponent.new(data: { 'close-dialog-id': "time-entry-dialog" })) { I18n.t("button_cancel") } %>
<%= render(Primer::ButtonComponent.new(scheme: :primary, type: :submit, test_selector: "create-time-entry-button", form: 'time-entry-form')) { "Create Time Entry" } %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions modules/costs/app/components/time_entries/time_entry_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ class TimeEntryForm < ApplicationForm
f.work_package_autocompleter name: :work_package_id,
label: "Work package",
autocomplete_options: {
focusDirectly: false,
append_to: "#time-entry-dialog",
filters: [{ name: "project_id", operator: "=", values: [model.project_id] }]

}
end

f.text_field name: :activity, label: "Activity"
f.text_field name: :activity_id, label: "Activity"

f.text_field name: :comments, label: "Comments"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%=
component_wrapper do
primer_form_with(**form_options) do |form|
component_collection do |collection|
collection.with_component(Primer::Alpha::Dialog::Body.new) do
component_collection do |coll|
# coll.with_component content_tag(:pre, time_entry.pretty_inspect)
coll.with_component render(TimeEntries::TimeEntryForm.new(form))
end
end

collection.with_component(Primer::Alpha::Dialog::Footer.new) do
component_collection do |footer|
footer.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "time-entry-dialog" })) do
I18n.t("button_cancel")
end

footer.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit, test_selector: "create-api-token-button")) do
I18n.t("my.access_token.new_access_token_dialog_submit_button_text")
end
end
render(TimeEntries::TimeEntryForm.new(form))
end
end
end
end
%>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def initialize(time_entry:)
def form_options
base = {
model: time_entry,
data: { turbo: true }
data: { turbo: true },
id: "time-entry-form"
}

if time_entry.persisted?
Expand Down

0 comments on commit cd57025

Please sign in to comment.