aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarc Florisson2012-10-03 09:37:09 +0200
committerMarc Florisson2012-10-03 09:37:09 +0200
commit04835501dbf267b2046d24e65400e23c927d4ab3 (patch)
tree52e218503aa75a083c498a83fea3fe11e0077218 /app
parent159e9c1ee586cf48cd2150f64d825a1580d79225 (diff)
parent7d447652d1adf357ce9fd1c89a5fa8fda638608e (diff)
downloadchouette-core-04835501dbf267b2046d24e65400e23c927d4ab3.tar.bz2
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/logoMEDDE.jpgbin13842 -> 9767 bytes
-rw-r--r--app/assets/javascripts/public/jquery.ui.datepicker-i18n.js9
-rw-r--r--app/assets/javascripts/time_tables.js.coffee39
-rw-r--r--app/assets/javascripts/vehicle_journey.js.coffee6
-rw-r--r--app/assets/stylesheets/time_tables.css.scss61
-rw-r--r--app/views/exports/index.html.erb2
-rw-r--r--app/views/file_validations/index.html.erb2
-rw-r--r--app/views/imports/index.html.erb2
-rw-r--r--app/views/time_tables/_date_fields.erb4
-rw-r--r--app/views/time_tables/_dates.html.erb4
-rw-r--r--app/views/time_tables/_form.erb37
-rw-r--r--app/views/time_tables/_period_fields.erb5
-rw-r--r--app/views/time_tables/_periods.html.erb3
-rw-r--r--app/views/time_tables/show.html.erb27
14 files changed, 181 insertions, 20 deletions
diff --git a/app/assets/images/logoMEDDE.jpg b/app/assets/images/logoMEDDE.jpg
index 51e0a3a44..06d4a2a1f 100644
--- a/app/assets/images/logoMEDDE.jpg
+++ b/app/assets/images/logoMEDDE.jpg
Binary files differ
diff --git a/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js
index 3d0d55b46..b7748a77a 100644
--- a/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js
+++ b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js
@@ -53,7 +53,14 @@ jQuery(function($){
monthNamesShort: $.datepicker.regional[ $('html').attr('lang') ].monthNamesShort,
monthNames: $.datepicker.regional[ $('html').attr('lang') ].monthNames
} );
- $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) );
+ if ($(element).val().indexOf('/') >= 0)
+ {
+ $(element).datepicker("setDate", $.datepicker.parseDate('dd/mm/y', $(element).val() ) );
+ }
+ else
+ {
+ $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) );
+ }
});
$("form").submit(function(event) {
diff --git a/app/assets/javascripts/time_tables.js.coffee b/app/assets/javascripts/time_tables.js.coffee
new file mode 100644
index 000000000..b85376edb
--- /dev/null
+++ b/app/assets/javascripts/time_tables.js.coffee
@@ -0,0 +1,39 @@
+jQuery ->
+# add trigger to hide/show application dates and periods
+ switch_dates = (event) ->
+ event.preventDefault()
+ $('.time_tables .dates.content').toggle('slow')
+ $('a.dates .switcher').toggle()
+
+ $('.time_tables a.dates').click(switch_dates)
+
+ switch_periods = (event) ->
+ event.preventDefault()
+ $('.time_tables .periods.content').toggle('slow')
+ $('a.periods .switcher').toggle()
+
+ $('.time_tables a.periods').click(switch_periods)
+
+# add trigger when creating new date or period entries to activate datepicker
+ tt_datepickerI18n = (index, element) ->
+ # do nothig if a datepicker is already attached
+ return if ($(element).hasClass('hasDatepicker') )
+ $(element).datepicker({
+ dateFormat: "dd/mm/y",
+ dayNamesShort: $.datepicker.regional[ $('html').attr('lang') ].dayNamesShort,
+ dayNames: $.datepicker.regional[ $('html').attr('lang') ].dayNames,
+ monthNamesShort: $.datepicker.regional[ $('html').attr('lang') ].monthNamesShort,
+ monthNames: $.datepicker.regional[ $('html').attr('lang') ].monthNames
+ })
+ $(element).datepicker("setDate", $.datepicker.parseDate('dd/mm/y', $(element).val() ) ) if ($(element).val().indexOf('/') >= 0)
+ $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) ) if ($(element).val().indexOf('/') < 0)
+
+ after_inserts = ->
+ $('input[type="date"]').each(tt_datepickerI18n)
+
+ bind_after_inserts = ->
+ $('#periods_content').bind('insertion-callback',after_inserts)
+ $('#dates_content').bind('insertion-callback',after_inserts)
+ #after_inserts()
+
+ $(document).ready(bind_after_inserts) if $('.time_tables').length > 0
diff --git a/app/assets/javascripts/vehicle_journey.js.coffee b/app/assets/javascripts/vehicle_journey.js.coffee
index 513d177c8..89bc8825f 100644
--- a/app/assets/javascripts/vehicle_journey.js.coffee
+++ b/app/assets/javascripts/vehicle_journey.js.coffee
@@ -1,6 +1,6 @@
jQuery ->
swap_hour_minute = ( from, to) ->
- rows = $('.vehicle_journeys.edit tbody.journey_pattern_dependent_list tr')
+ rows = $('.vehicle_journeys tbody.journey_pattern_dependent_list tr')
for row in rows
do (row) ->
$(row).find( to).find('.hour')[0].value = $(row).find( from).find('.hour')[0].value
@@ -10,13 +10,13 @@ jQuery ->
event.preventDefault()
swap_hour_minute( '.departure_time', '.arrival_time')
- $('.vehicle_journeys.edit a.to_arrivals').live("click", copy_departures_to_arrivals)
+ $('.vehicle_journeys a.to_arrivals').live("click", copy_departures_to_arrivals)
copy_arrivals_to_departures = (event) ->
event.preventDefault()
swap_hour_minute( '.arrival_time', '.departure_time')
- $('.vehicle_journeys.edit a.to_departures').live("click", copy_arrivals_to_departures)
+ $('.vehicle_journeys a.to_departures').live("click", copy_arrivals_to_departures)
switch_vehicle_journey_at_stops = (event) ->
event.preventDefault()
diff --git a/app/assets/stylesheets/time_tables.css.scss b/app/assets/stylesheets/time_tables.css.scss
index 6a168eb4f..f1ff7b3d2 100644
--- a/app/assets/stylesheets/time_tables.css.scss
+++ b/app/assets/stylesheets/time_tables.css.scss
@@ -103,6 +103,16 @@
#workspace.time_tables.edit,#workspace.time_tables.new,#workspace.time_tables.create,#workspace.time_tables.update
{
+ h3 {
+ .dates {
+ cursor: pointer;
+ }
+ .periods {
+ cursor: pointer;
+ }
+ }
+
+
.day_type ol {
float: left;
margin: 0;
@@ -126,4 +136,55 @@
.day_type ol li label {
padding-left: 10%;
}
+
+ .dates ol {
+ margin-top: -0.3em;
+ margin-bottom: 1em;
+ margin-left: 25%;
+ padding: 0;
+ width: 75%;
+ }
+ .dates ol li { padding : 0.3em 0; }
+
+ .dates ol li label {
+ width: 40%;
+ margin-top: -0.3em;
+ }
+ .dates ol li.fl1 {float: left; width: 30% ;}
+ .dates ol li.fl1 label {width: 40%; margin-top: -0.3em; }
+ .dates ol li.fl1 input { width: 50%; }
+
+
+ .periods ol {
+ margin-top: -0.3em;
+ margin-bottom: 1em;
+ margin-left: 25%;
+ padding: 0;
+ width: 75%;
+ }
+ .periods ol li { padding : 0.3em 0; }
+
+ .periods ol li label {
+ width: 40%;
+ margin-top: -0.3em;
+ }
+ .periods ol li.fl1 {float: left; width: 30% ;}
+ .periods ol li.fl1 label {width: 40%; margin-top: -0.3em; }
+ .periods ol li.fl1 input { width: 50%; }
+
+ .periods ol li.fl2 {float: left; width: 30% ;}
+ .periods ol li.fl2 label {width: 40%; margin-top: -0.3em;}
+ .periods ol li.fl2 input { width: 50%; }
+ a.add_fields {
+ margin-left: 25%;
+ color: #666;
+ padding-left: 18px;
+ background: url(image-path('user_interface/ui/add.png')) no-repeat 0% 50%;
+ }
+ a.remove_fields {
+ color: #666;
+ padding-left: 18px;
+ background: url(image-path('user_interface/ui/remove.png')) no-repeat 0% 50%;
+ }
+
}
diff --git a/app/views/exports/index.html.erb b/app/views/exports/index.html.erb
index 25db2e1ba..b7847b70e 100644
--- a/app/views/exports/index.html.erb
+++ b/app/views/exports/index.html.erb
@@ -1,5 +1,5 @@
<%= title_tag t('.title') %>
-
+<div class="warning"><%= t('.warning') %> </div>
<div class="page_info">
<span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @exports %>
</div>
diff --git a/app/views/file_validations/index.html.erb b/app/views/file_validations/index.html.erb
index e1416fa96..2e0cefbe8 100644
--- a/app/views/file_validations/index.html.erb
+++ b/app/views/file_validations/index.html.erb
@@ -1,5 +1,5 @@
<%= title_tag t('.title') %>
-
+<div class="warning"><%= t('.warning') %> </div>
<div class="pagination">
<div class="page_info">
<%= page_entries_info @file_validations %>
diff --git a/app/views/imports/index.html.erb b/app/views/imports/index.html.erb
index 7e0d366a3..8469fbd7b 100644
--- a/app/views/imports/index.html.erb
+++ b/app/views/imports/index.html.erb
@@ -1,5 +1,5 @@
<%= title_tag t('.title') %>
-
+<div class="warning"><%= t('.warning') %> </div>
<div class="page_info">
<span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @imports %>
</div>
diff --git a/app/views/time_tables/_date_fields.erb b/app/views/time_tables/_date_fields.erb
new file mode 100644
index 000000000..5d24456a3
--- /dev/null
+++ b/app/views/time_tables/_date_fields.erb
@@ -0,0 +1,4 @@
+<%= f.inputs :class => 'dates nested-fields' do %>
+ <%= f.input :date, :as => :date_picker, :label => @time_table.human_attribute_name("date"), :wrapper_html => { :class => 'fl1' }%>
+ <%= link_to_remove_association t('actions.destroy'), f %>
+<% end %>
diff --git a/app/views/time_tables/_dates.html.erb b/app/views/time_tables/_dates.html.erb
index 47ae01710..663efec58 100644
--- a/app/views/time_tables/_dates.html.erb
+++ b/app/views/time_tables/_dates.html.erb
@@ -1,10 +1,6 @@
<ul class='dates'>
<% @time_table.dates.each do |tmd| %>
<li class="<%= (tmd.position%2==0) ? 'odd' : 'even' %>"><%= l tmd.date %>
- <div class="actions">
- <%= link_to t("actions.destroy"), referential_time_table_time_table_date_path(@referential, @time_table,tmd), :method => :delete, :confirm => t('time_tables.actions.destroy_date_confirm'), :class => "remove" %>
- </div>
-
</li>
<% end %>
</ul>
diff --git a/app/views/time_tables/_form.erb b/app/views/time_tables/_form.erb
index fbced7bd4..3325b97a5 100644
--- a/app/views/time_tables/_form.erb
+++ b/app/views/time_tables/_form.erb
@@ -17,6 +17,43 @@
<%= form.input :objectid, :required => !@time_table.new_record?, :input_html => { :disabled => !@time_table.new_record? } %>
<% end %>
+ <h3 class="time_table_dates">
+ <a class="dates"><%= @time_table.human_attribute_name("dates") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+ </h3>
+
+ <div class="dates content" id="dates_content">
+ <div id="dates">
+ <%= form.semantic_fields_for :dates do |p| %>
+ <%= render "date_fields", :f => p %>
+ <% end %>
+ </div>
+ <%= link_to_add_association t("time_tables.actions.add_date"), form, :dates ,
+ :"data-association-insertion-method" => "append",
+ :"data-association-insertion-node" => "div#dates" %>
+ </div>
+
+
+ <h3 class="time_table_periods">
+ <a class="periods"><%= @time_table.human_attribute_name("periods") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+
+ </h3>
+ <div class="periods content" id="periods_content">
+ <div id="periods">
+ <%= form.semantic_fields_for :periods do |p| %>
+ <%= render "period_fields", :f => p %>
+ <% end %>
+ </div>
+ <%= link_to_add_association t("time_tables.actions.add_period"), form, :periods ,
+ :"data-association-insertion-method" => "append",
+ :"data-association-insertion-node" => "div#periods"%>
+ </div>
+ <p/>
<%= form.actions do %>
<%= form.action :submit, :as => :button %>
<%= form.action :cancel, :as => :link %>
diff --git a/app/views/time_tables/_period_fields.erb b/app/views/time_tables/_period_fields.erb
new file mode 100644
index 000000000..120a526bb
--- /dev/null
+++ b/app/views/time_tables/_period_fields.erb
@@ -0,0 +1,5 @@
+<%= f.inputs :class => 'periods nested-fields' do %>
+ <%= f.input :period_start, :as => :date_picker, :label => @time_table.human_attribute_name("period_start"), :wrapper_html => { :class => 'fl1' }%>
+ <%= f.input :period_end, :as => :date_picker, :label => @time_table.human_attribute_name("period_end"), :wrapper_html => { :class => 'fl2' }%>
+ <%= link_to_remove_association t('actions.destroy'), f %>
+<% end %>
diff --git a/app/views/time_tables/_periods.html.erb b/app/views/time_tables/_periods.html.erb
index 9f3974735..1f0aea057 100644
--- a/app/views/time_tables/_periods.html.erb
+++ b/app/views/time_tables/_periods.html.erb
@@ -1,9 +1,6 @@
<ul class='periods'>
<% @time_table.periods.each do |tmp| %>
<li class='period'><%= t('time_tables.show.from')%> <%= l tmp.period_start %> <%= t('time_tables.show.to')%> <%= l tmp.period_end %>
- <div class="actions">
- <%= link_to t("actions.destroy"), referential_time_table_time_table_period_path(@referential, @time_table,tmp), :method => :delete, :confirm => t('time_tables.actions.destroy_period_confirm'), :class => "remove" %>
- </div>
</li>
<% end %>
</ul>
diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb
index 60eee8d04..3536dedae 100644
--- a/app/views/time_tables/show.html.erb
+++ b/app/views/time_tables/show.html.erb
@@ -70,18 +70,33 @@
<%= @time_table.creator_id %>
</p>
</div>
- <h3 class="dates"><%= t('.dates') %></h3>
- <%= render "dates" %>
- <h3 class="periods"><%= t('.periods') %></h3>
- <%= render "periods" %>
+ <h3 class="time_table_dates">
+ <a class="dates"><%= @time_table.human_attribute_name("dates") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+ </h3>
+
+ <div class="dates content">
+ <%= render "dates" %>
+ </div>
+
+ <h3 class="time_table_periods">
+ <a class="periods"><%= @time_table.human_attribute_name("periods") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+
+ </h3>
+ <div class="periods content">
+ <%= render "periods" %>
+ </div>
</div>
<% content_for :sidebar do %>
<ul class="actions">
<li><%= link_to t('time_tables.actions.edit'), edit_referential_time_table_path(@referential, @time_table), :class => "edit" %></li>
<li><%= link_to t('time_tables.actions.destroy'), referential_time_table_path(@referential, @time_table), :method => :delete, :confirm => t('time_tables.actions.destroy_confirm'), :class => "remove" %></li>
- <li><%= link_to t('time_tables.show.add_date'), new_referential_time_table_time_table_date_path(@referential, @time_table), :class => 'add' %></li>
- <li><%= link_to t('time_tables.show.add_period'), new_referential_time_table_time_table_period_path(@referential, @time_table), :class => 'add' %></li>
<br>
</ul>
<% end %>