diff --git a/app/assets/javascripts/admin/votation_types/fields.js b/app/assets/javascripts/admin/votation_types/fields.js new file mode 100644 index 000000000..85649e675 --- /dev/null +++ b/app/assets/javascripts/admin/votation_types/fields.js @@ -0,0 +1,21 @@ +(function() { + "use strict"; + App.AdminVotationTypesFields = { + adjustForm: function() { + if ($(this).val() === "unique") { + $(".max-votes").hide(); + $(".description-unique").show(); + $(".description-multiple").hide(); + $(".votation-type-max-votes").prop("disabled", true); + } else { + $(".max-votes").show(); + $(".description-unique").hide(); + $(".description-multiple").show(); + $(".votation-type-max-votes").prop("disabled", false); + } + }, + initialize: function() { + $(".votation-type-vote-type").on("change", App.AdminVotationTypesFields.adjustForm).trigger("change"); + } + }; +}).call(this); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 52e178b4b..58f344977 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -167,6 +167,7 @@ var initialize_modules = function() { } App.AdminBudgetsWizardCreationStep.initialize(); App.AdminMachineLearningScripts.initialize(); + App.AdminVotationTypesFields.initialize(); App.BudgetEditAssociations.initialize(); App.BudgetHideMoney.initialize(); App.Datepicker.initialize(); diff --git a/app/components/admin/poll/questions/form_component.html.erb b/app/components/admin/poll/questions/form_component.html.erb index fc183f186..bd72edd40 100644 --- a/app/components/admin/poll/questions/form_component.html.erb +++ b/app/components/admin/poll/questions/form_component.html.erb @@ -29,6 +29,14 @@ <% end %> +
+ <%= t("admin.polls.votation_type.title") %>
+
+ <%= VotationType.human_attribute_name("vote_type.#{@question.vote_type}") %>
+
+ <%= VotationType.human_attribute_name("max_votes") %>
+
+ <%= @question.max_votes %>
+