Extract to help method to fill in the data for the suggestions

This commit is contained in:
taitus
2021-03-31 15:20:06 +02:00
parent 5f642f9ecb
commit 56d3840c40
4 changed files with 12 additions and 9 deletions

View File

@@ -0,0 +1,9 @@
module SuggestionsHelper
def suggest_data(record)
{
js_suggest_result: "js_suggest_result",
js_suggest: ".js-suggest",
js_url: polymorphic_path(record.class, action: :suggest)
}
end
end

View File

@@ -16,9 +16,7 @@
<div class="small-12 column">
<%= translations_form.text_field :title,
maxlength: Budget::Investment.title_max_length,
data: { js_suggest_result: "js_suggest_result",
js_suggest: ".js-suggest",
js_url: suggest_budget_investments_path(@budget) } %>
data: suggest_data(@investment) %>
</div>
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>

View File

@@ -10,9 +10,7 @@
<%= translations_form.text_field :title,
maxlength: Debate.title_max_length,
placeholder: t("debates.form.debate_title"),
data: { js_suggest_result: "js_suggest_result",
js_suggest: ".js-suggest",
js_url: suggest_debates_path } %>
data: suggest_data(@debate) %>
</div>
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>

View File

@@ -9,9 +9,7 @@
<div class="small-12 column">
<%= translations_form.text_field :title,
maxlength: Proposal.title_max_length,
data: { js_suggest_result: "js_suggest_result",
js_suggest: ".js-suggest",
js_url: suggest_proposals_path } %>
data: suggest_data(@proposal) %>
</div>
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>