Checkboxes for process dates

This commit is contained in:
Amaia Castro
2017-02-09 19:09:59 +01:00
parent 28de717300
commit 132d5622ca
5 changed files with 67 additions and 0 deletions

View File

@@ -52,6 +52,7 @@
//= require markdown-it //= require markdown-it
//= require markdown_editor //= require markdown_editor
//= require cocoon //= require cocoon
//= require legislation_admin
//= require legislation //= require legislation
//= require legislation_allegations //= require legislation_allegations
//= require legislation_annotatable //= require legislation_annotatable
@@ -83,6 +84,7 @@ var initialize_modules = function() {
App.Banners.initialize(); App.Banners.initialize();
App.SocialShare.initialize(); App.SocialShare.initialize();
App.MarkdownEditor.initialize(); App.MarkdownEditor.initialize();
App.LegislationAdmin.initialize();
App.LegislationAllegations.initialize(); App.LegislationAllegations.initialize();
App.Legislation.initialize(); App.Legislation.initialize();
if ( $(".legislation-annotatable").length ) if ( $(".legislation-annotatable").length )

View File

@@ -0,0 +1,45 @@
App.LegislationAdmin =
initialize: ->
$("input[type='checkbox']#debate_phase_active").on
change: ->
if $("input[type='checkbox']#debate_phase_active").is(':checked')
console.log("checked")
$("input#debate_start_date").removeAttr("disabled")
$("input#debate_end_date").removeAttr("disabled")
else
console.log("unchecked")
$("input#debate_start_date").val("")
$("input#debate_start_date").attr("disabled", true)
$("input#debate_end_date").val("")
$("input#debate_end_date").attr("disabled", true)
$("input[type='checkbox']#allegations_phase_active").on
change: ->
if $("input[type='checkbox']#allegations_phase_active").is(':checked')
$("input#allegations_start_date").removeAttr("disabled")
$("input#allegations_end_date").removeAttr("disabled")
else
$("input#allegations_start_date").val("")
$("input#allegations_start_date").prop( "disabled", true )
$("input#allegations_end_date").val("")
$("input#allegations_end_date").prop( "disabled", true )
$("input[type='checkbox']#draft_publication_phase_active").on
change: ->
if $("input[type='checkbox']#draft_publication_phase_active").is(':checked')
$("input#draft_publication_date").removeAttr("disabled")
else
$("input#draft_publication_date").val("")
$("input#draft_publication_date").prop( "disabled", true )
$("input[type='checkbox']#final_version_publication_phase_active").on
change: ->
if $("input[type='checkbox']#final_version_publication_phase_active").is(':checked')
$("input#final_publication_date").removeAttr("disabled")
else
$("input#final_publication_date").val("")
$("input#final_publication_date").prop( "disabled", true )

View File

@@ -63,6 +63,10 @@
class: "js-calendar-full", class: "js-calendar-full",
id: "debate_end_date" %> id: "debate_end_date" %>
</div> </div>
<div class="small-12 medium-2 column">
<%= check_box_tag :debate_phase_active, @process.active_phase?(:debate), @process.new_record? || @process.active_phase?(:debate) %>
<%= t('admin.legislation.processes.form.active') %>
</div>
<div class="small-12 medium-4 column"> <div class="small-12 medium-4 column">
<label><%= t('admin.legislation.processes.form.allegations_phase') %></label> <label><%= t('admin.legislation.processes.form.allegations_phase') %></label>
@@ -87,7 +91,13 @@
class: "js-calendar-full", class: "js-calendar-full",
id: "allegations_end_date" %> id: "allegations_end_date" %>
</div> </div>
<div class="small-12 medium-2 column">
<%= check_box_tag :allegations_phase_active, @process.active_phase?(:allegations), @process.new_record? || @process.active_phase?(:allegations) %>
<%= t('admin.legislation.processes.form.active') %>
</div>
</div>
<div class="row">
<div class="small-12 medium-4 column"> <div class="small-12 medium-4 column">
<%= f.label :draft_publication_date %> <%= f.label :draft_publication_date %>
</div> </div>
@@ -98,6 +108,10 @@
class: "js-calendar-full", class: "js-calendar-full",
id: "draft_publication_date" %> id: "draft_publication_date" %>
</div> </div>
<div class="small-12 medium-2 column">
<%= check_box_tag :draft_publication_phase_active, @process.active_phase?(:draft_publication), @process.new_record? || @process.active_phase?(:draft_publication) %>
<%= t('admin.legislation.processes.form.active') %>
</div>
</div> </div>
<div class="row"> <div class="row">
@@ -111,6 +125,10 @@
class: "js-calendar-full", class: "js-calendar-full",
id: "final_publication_date" %> id: "final_publication_date" %>
</div> </div>
<div class="small-12 medium-2 column">
<%= check_box_tag :final_version_publication_phase_active, @process.active_phase?(:final_version_publication), @process.new_record? || @process.active_phase?(:final_version_publication) %>
<%= t('admin.legislation.processes.form.active') %>
</div>
</div> </div>
<div class="row"> <div class="row">

View File

@@ -193,6 +193,7 @@ en:
form: form:
error: Error error: Error
form: form:
active: Active
process: Process process: Process
debate_phase: Debate phase debate_phase: Debate phase
allegations_phase: Allegations phase allegations_phase: Allegations phase

View File

@@ -193,6 +193,7 @@ es:
form: form:
error: Error error: Error
form: form:
active: Activo
process: Proceso process: Proceso
debate_phase: Fase previa debate_phase: Fase previa
allegations_phase: Fase de alegaciones allegations_phase: Fase de alegaciones