Extract methods in draft version form component

This way we don't get lines with 150+ characters.
This commit is contained in:
Javi Martín
2025-07-09 17:29:41 +02:00
parent 0f54e220ba
commit cb57b0c0c1
2 changed files with 20 additions and 8 deletions

View File

@@ -1,12 +1,6 @@
<%= render "shared/globalize_locales", resource: draft_version %> <%= render "shared/globalize_locales", resource: draft_version %>
<%= translatable_form_for [:admin, process, draft_version], url: url, <%= translatable_form_for [:admin, process, draft_version], form_attributes do |f| %>
html: {
data: {
markdown_changes_message: I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message")
},
class: "legislation-draft-versions-form"
} do |f| %>
<%= render "shared/errors", resource: draft_version %> <%= render "shared/errors", resource: draft_version %>
<div class="row"> <div class="row">
@@ -81,7 +75,7 @@
</div> </div>
<div class="small-12 medium-3 column clear end margin-top"> <div class="small-12 medium-3 column clear end margin-top">
<%= f.submit(class: "button success expanded", value: t("admin.legislation.draft_versions.#{admin_submit_action(draft_version)}.submit_button")) %> <%= f.submit(class: "button success expanded", value: submit_button_text) %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -14,4 +14,22 @@ class Admin::Legislation::DraftVersions::FormComponent < ApplicationComponent
def process def process
draft_version.process draft_version.process
end end
def form_attributes
{
url: url,
html: {
data: { markdown_changes_message: markdown_changes_message },
class: "legislation-draft-versions-form"
}
}
end
def markdown_changes_message
I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message")
end
def submit_button_text
t("admin.legislation.draft_versions.#{admin_submit_action(draft_version)}.submit_button")
end
end end