aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarc Florisson2012-09-10 21:35:49 +0200
committerMarc Florisson2012-09-10 21:35:49 +0200
commit8024e9a869c3eeb4ca752206a7fb3add9559de13 (patch)
tree4263eec873112888a8bd198a01887e2a798d0154 /app
parentabcb13a2e4dff2b155ff25f20b5ba6e7b1f2d5f7 (diff)
downloadchouette-core-8024e9a869c3eeb4ca752206a7fb3add9559de13.tar.bz2
Add feature on TimeTables. Refs #118
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/time_tables.css.scss43
-rw-r--r--app/helpers/time_tables_helper.rb9
-rw-r--r--app/views/referentials/show.html.erb8
-rw-r--r--app/views/time_tables/_time_table.erb14
-rw-r--r--app/views/time_tables/show.html.erb11
5 files changed, 79 insertions, 6 deletions
diff --git a/app/assets/stylesheets/time_tables.css.scss b/app/assets/stylesheets/time_tables.css.scss
index 961f1657b..81beb645b 100644
--- a/app/assets/stylesheets/time_tables.css.scss
+++ b/app/assets/stylesheets/time_tables.css.scss
@@ -24,7 +24,32 @@
width: 350px;
float: left;
padding-right: 10px;
+ position: relative;
+ .state-code {
+ width: 25px;
+ height: 64px;
+ float: left;
+ margin-right: 10px;
+
+ .validity_out {
+ background-color: #FC4903;
+ width: 25px;
+ height: 25px;
+ }
+
+ .validity_out_soon {
+ background-color: orange;
+ width: 25px;
+ height: 25px;
+ }
+
+ .validity_regular {
+ background-color: #86B41D;
+ width: 25px;
+ height: 25px;
+ }
+ }
}
}
@@ -56,6 +81,24 @@
.summary p label {
font-weight: bold;
}
+
+ .resume {
+ .validity {
+ float: left;
+ width: 20px;
+ height: 20px;
+ margin-right: 10px;
+ }
+ .validity.validity_out {
+ background-color: #FC4903;
+ }
+ .validity.validity_out_soon {
+ background-color: orange;
+ }
+ .validity.validity_regular {
+ background-color: #86B41D;
+ }
+ }
}
#workspace.time_tables.edit,#workspace.time_tables.new,#workspace.time_tables.create,#workspace.time_tables.update
diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb
index a7607f7a0..b6dc3de48 100644
--- a/app/helpers/time_tables_helper.rb
+++ b/app/helpers/time_tables_helper.rb
@@ -1,4 +1,13 @@
module TimeTablesHelper
+ def time_table_state_code(time_table)
+ if time_table.validity_out_from_on?(Date.today)
+ "validity_out"
+ elsif time_table.validity_out_between?(Date.today,Date.today+7.day)
+ "validity_out_soon"
+ else
+ "validity_regular"
+ end
+ end
def bounding_info(time_table)
return t('time_tables.time_table.empty') if time_table.bounding_dates.empty?
t('time_tables.time_table.bounding',
diff --git a/app/views/referentials/show.html.erb b/app/views/referentials/show.html.erb
index 951c299af..e1baf0d57 100644
--- a/app/views/referentials/show.html.erb
+++ b/app/views/referentials/show.html.erb
@@ -100,12 +100,12 @@
<table class="count" width="75%">
<thead>
<tr>
- <td><%= t('.expired_time_tables') %>: <%= tm_cnt = @referential.time_tables.expired_on(Date.today).size %></td>
+ <td><%= t('.validity_out_time_tables') %>: <%= tm_cnt = @referential.time_tables.validity_out_from_on?(Date.today).size %></td>
</tr>
</thead>
<tbody>
<% if tm_cnt > 0 %>
- <% @referential.time_tables.expired_on(Date.today,5).each do |tm| %>
+ <% @referential.time_tables.validity_out_from_on?(Date.today,5).each do |tm| %>
<tr><td><%= link_to tm.comment, referential_time_table_path(@referential, tm) %></td></tr>
<% end %>
<% if tm_cnt > 5 %>
@@ -118,12 +118,12 @@
<table class="count" width="75%">
<thead>
<tr>
- <td><%= t('.almost_expired_time_tables', :count => "7") %>: <%= tm_cnt = @referential.time_tables.expired_between(Date.today,Date.today+7).size %></td>
+ <td><%= t('.validity_out_soon_time_tables', :count => "7") %>: <%= tm_cnt = @referential.time_tables.validity_out_between?(Date.today,Date.today+7).size %></td>
</tr>
</thead>
<tbody>
<% if tm_cnt > 0 %>
- <% @referential.time_tables.expired_between(Date.today,Date.today+7,5).each do |tm| %>
+ <% @referential.time_tables.validity_out_between?(Date.today,Date.today+7,5).each do |tm| %>
<tr><td><%= link_to tm.comment, referential_time_table_path(@referential, tm) %></td></tr>
<% end %>
<% if tm_cnt > 5 %>
diff --git a/app/views/time_tables/_time_table.erb b/app/views/time_tables/_time_table.erb
index 6cb4289a3..a2b3f1ff3 100644
--- a/app/views/time_tables/_time_table.erb
+++ b/app/views/time_tables/_time_table.erb
@@ -1,6 +1,16 @@
-<%= div_for(time_table, :class => "time_table") do %>
- <%= link_to time_table.comment, [@referential, time_table] %>
+<%= div_for(time_table) do %>
+ <%= link_to ( [@referential, time_table]) do %>
+ <div class="state-code" >
+ <div class="<%= time_table_state_code(time_table) %>" >
+ </div>
+ </div>
+ <% end %>
+ <div class="name">
+ <%= link_to truncate(time_table.comment, :length => 30), [@referential, time_table], :title => "#{Chouette::TimeTable.model_name.human.capitalize} #{time_table.comment}"%>
+ </div>
<div class="info">
+ <%= time_tables_shortest_info(time_table) %> -
+ <%= composition_info(time_table) %>
<div class="actions">
<%= link_to t("actions.edit"), edit_referential_time_table_path(@referential, time_table), :class => "edit" %> |
<%= link_to t("actions.destroy"), referential_time_table_path(@referential, time_table), :method => :delete, :confirm => t('time_tables.actions.destroy_confirm'), :class => "remove" %>
diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb
index f3e0bbce3..60eee8d04 100644
--- a/app/views/time_tables/show.html.erb
+++ b/app/views/time_tables/show.html.erb
@@ -2,6 +2,17 @@
<div class="time_table_show">
+ <div class="resume">
+ <div class="validity <%= time_table_state_code(@time_table) %>"></div>
+ <label>
+ <% if @time_table.bounding_dates.empty? %>
+ <%= t(".resume_empty") %>
+ <% else %>
+ <%= t(".resume", :start_date => l(@time_table.bounding_dates.min),
+ :end_date => l(@time_table.bounding_dates.max)) %>
+ <% end %>
+ </label>
+ </div>
<div class="summary">
<p>
<label><%= @time_table.human_attribute_name("comment") %>: </label>