Use active record translations in votation types

We need to build a votation type object in the form so translations are
applied automatically.
This commit is contained in:
Javi Martín
2019-10-05 02:15:16 +02:00
parent 9ddbd01f91
commit bbbd0820c1
6 changed files with 16 additions and 15 deletions

View File

@@ -33,12 +33,12 @@
<div class="row">
<% if !@question.persisted? %>
<%= fields_for :votation_type do |votation_f| %>
<%= fields_for :votation_type, @question.votation_type || @question.build_votation_type do |votation_f| %>
<div class="small-12 medium-6">
<%= votation_f.select :enum_type,
options_for_select(VotationType.enum_types.map { |k, v| [t(k, scope: :enum_type), v] },
params.dig(:votation_type, :enum_type)), default: 0,
disabled: @question.persisted?, label: t("enum_type.title") %>
disabled: @question.persisted? %>
</div>
<div class="info-type">
@@ -47,18 +47,17 @@
</span>
<div class="small-12 medium-6 margin-description js-max_votes hidden ">
<%= votation_f.number_field :max_votes, min: 1, max: 999,
value: params.dig(:votation_type, :max_votes),
label: t("question.max_votes") %>
value: params.dig(:votation_type, :max_votes) %>
</div>
<div class="small-12 medium-6 js-prioritization_type hidden">
<%= votation_f.select :prioritization_type,
options_for_select(VotationType.prioritization_types.map { |k, v| [t(k, scope: :prioritization_type), v] },
params.dig(:votation_type, :prioritization_type)), default: 0,
disabled: @question.persisted?, label: t("prioritization_type.title") %>
disabled: @question.persisted? %>
</div>
<div class="small-12 medium-6 js-max_group_votes hidden">
<%= votation_f.number_field :max_groups_answers, min: 1, max: 999,
value: params.dig(:votation_type, :max_groups_answers), label: t("question.max_group_answers") %>
value: params.dig(:votation_type, :max_groups_answers) %>
</div>
</div>
<% end %>

View File

@@ -42,7 +42,7 @@
<% end %>
<% if !@question.votation_type.prioritization_type.nil? %>
<p>
<strong><%= t("prioritization_type.title") %></strong>
<strong><%= VotationType.human_attribute_name(:prioritization_type) %></strong>
<br>
<%= t("prioritization_type.#{@question.votation_type.prioritization_type}") %>
</p>

View File

@@ -333,6 +333,11 @@ en:
topic:
title: "Title"
description: "Initial text"
votation_type:
enum_type: "Votation type"
max_groups_answers: "Maximum number of answers in the set"
max_votes: "Maximum number of votes"
prioritization_type: "Prioritization type"
banner:
background_color: Background color
font_color: Font color

View File

@@ -992,11 +992,8 @@ en:
poll:
take_part: Take part from %{from} to %{to}
question:
max_votes: Maximum number of votes
max_group_answers: Maximum number of answers in the set
votation_type: Votation type
enum_type:
title: Votation type
unique: Unique answer, closed
multiple: Multiple answers, closed
prioritized: Multiple prioritized answer, closed
@@ -1007,7 +1004,6 @@ en:
answer_set_open: Set of answers, open
answer_set_closed: Set of answers, closed
prioritization_type:
title: Prioritization type
borda: Borda votation
dowdall: Dowdall votation
remote_translations:

View File

@@ -335,6 +335,11 @@ es:
topic:
title: "Título"
description: "Texto inicial"
votation_type:
enum_type: "Tipo de votación"
max_groups_answers: "Número máximo de respuestas en el conjunto"
max_votes: "Número máximo de votos"
prioritization_type: "Tipo de priorizacion"
banner:
background_color: Color del fondo
font_color: Color del texto

View File

@@ -991,11 +991,8 @@ es:
poll:
take_part: Participa del %{from} al %{to}
question:
max_votes: Número máximo de votos
max_group_answers: Número máximo de respuestas en el conjunto
votation_type: Tipo de votación
enum_type:
title: Tipo de votación
unique: Respuesta única, cerrada
multiple: Respuesta múltiple, cerrada
prioritized: Respuesta múltiple priorizada, cerrada
@@ -1006,7 +1003,6 @@ es:
answer_set_open: Conjunto de respuestas, abiertas
answer_set_closed: Conjunto de respuestas, cerradas
prioritization_type:
title: Tipo de priorizacion
borda: Votación con recuento Borda
dowdall: Votación con recuento Dowdall
remote_translations: