Switch date selects for shift tasks

This commit is contained in:
María Checa
2017-09-28 10:40:48 +02:00
parent 13aa5a3ba8
commit 08cdf93ecc
3 changed files with 26 additions and 8 deletions

View File

@@ -67,6 +67,7 @@
//= require tree_navigator
//= require custom
//= require tag_autocomplete
//= require polls_admin
var initialize_modules = function() {
App.Comments.initialize();
@@ -103,6 +104,7 @@ var initialize_modules = function() {
App.Documentable.initialize();
App.Imageable.initialize();
App.TagAutocomplete.initialize();
App.PollsAdmin.initialize();
};
$(function(){

View File

@@ -0,0 +1,12 @@
App.PollsAdmin =
initialize: ->
$("select[class='js-poll-shifts']").on
change: ->
switch ($(this).val())
when 'vote_collection'
$("select[class='js-shift-vote-collection-dates']").show();
$("select[class='js-shift-recount-scrutiny-dates']").hide();
when 'recount_scrutiny'
$("select[class='js-shift-recount-scrutiny-dates']").show();
$("select[class='js-shift-vote-collection-dates']").hide();

View File

@@ -16,20 +16,24 @@
<label><%= t("admin.poll_shifts.new.task") %></label>
<%= f.select :task,
Poll::Shift.tasks.map {|k,v| [t("admin.poll_shifts.#{k}"), k]},
prompt: t("admin.poll_shifts.new.select_task"),
label: false %>
{ prompt: t("admin.poll_shifts.new.select_task"),
label: false },
class: 'js-poll-shifts' %>
</div>
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.date") %></label>
<%= select 'shift[date]', 'vote_collection_date',
options_for_select(shift_vote_collection_dates(@polls)),
prompt: t("admin.poll_shifts.new.select_date"),
label: false %>
options_for_select(shift_vote_collection_dates(@polls)),
{ prompt: t("admin.poll_shifts.new.select_date"),
label: false },
class: 'js-shift-vote-collection-dates' %>
<%= select 'shift[date]', 'recount_scrutiny_date',
options_for_select(shift_recount_scrutiny_dates(@polls)),
prompt: t("admin.poll_shifts.new.select_date"),
label: false %>
options_for_select(shift_recount_scrutiny_dates(@polls)),
{ prompt: t("admin.poll_shifts.new.select_date"),
label: false },
class: 'js-shift-recount-scrutiny-dates',
hidden: 'hidden' %>
</div>
<%= f.hidden_field :booth_id, value: @booth.id %>