diff options
| author | Marc Florisson | 2012-09-10 21:35:49 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-09-10 21:35:49 +0200 | 
| commit | 8024e9a869c3eeb4ca752206a7fb3add9559de13 (patch) | |
| tree | 4263eec873112888a8bd198a01887e2a798d0154 | |
| parent | abcb13a2e4dff2b155ff25f20b5ba6e7b1f2d5f7 (diff) | |
| download | chouette-core-8024e9a869c3eeb4ca752206a7fb3add9559de13.tar.bz2 | |
Add feature on TimeTables. Refs #118
| -rw-r--r-- | Gemfile.lock | 3 | ||||
| -rw-r--r-- | app/assets/stylesheets/time_tables.css.scss | 43 | ||||
| -rw-r--r-- | app/helpers/time_tables_helper.rb | 9 | ||||
| -rw-r--r-- | app/views/referentials/show.html.erb | 8 | ||||
| -rw-r--r-- | app/views/time_tables/_time_table.erb | 14 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.erb | 11 | ||||
| -rw-r--r-- | config/locales/referentials.yml | 8 | ||||
| -rw-r--r-- | config/locales/time_tables.yml | 4 | 
8 files changed, 89 insertions, 11 deletions
| diff --git a/Gemfile.lock b/Gemfile.lock index 8f1af43a9..d9ee88d74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@  GIT    remote: git://chouette.dryade.priv/ninoxe -  revision: a2fa3bf8ef30572bf91f64746b92a47653c1c0a6 +  revision: 848e356ff197dc5dcd143057e770373646b4c62c    specs:      ninoxe (0.0.8)        GeoRuby @@ -195,6 +195,7 @@ GEM      jruby-rack (1.1.9)      jruby-rack-worker (0.4-java)        jruby-rack (>= 1.1.1) +    json (1.7.5)      json (1.7.5-java)      json_pure (1.7.5)      launchy (2.1.0) 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> diff --git a/config/locales/referentials.yml b/config/locales/referentials.yml index ff09fc35d..f4e0c8840 100644 --- a/config/locales/referentials.yml +++ b/config/locales/referentials.yml @@ -7,8 +7,8 @@ en:        objects: Data space elements        count: count        clean_up: Clean up -      expired_time_tables: Closed timetables -      almost_expired_time_tables: Timetables closed in %{count} days     +      validity_out_time_tables: Closed timetables +      validity_out_soon_time_tables: Timetables closed in %{count} days          new:        title: Create a new data space        submit: "Create a data space" @@ -69,8 +69,8 @@ fr:        objects: Eléments         count: Qté        clean_up: Purge des données obsolètes -      expired_time_tables: Calendriers échus -      almost_expired_time_tables: Calendriers à échoir dans %{count} jours     +      validity_out_time_tables: Calendriers échus +      validity_out_soon_time_tables: Calendriers à échoir dans %{count} jours          new:        title: Créer un nouvel espace de données        submit: "Créer un espace de données" diff --git a/config/locales/time_tables.yml b/config/locales/time_tables.yml index 421838586..d2fd44887 100644 --- a/config/locales/time_tables.yml +++ b/config/locales/time_tables.yml @@ -18,6 +18,8 @@ en:      edit:        title: Update timetable %{time_table}      show: +      resume: "From %{start_date} to %{end_date} (independently of any period day types)" +      resume_empty: "Empty timetable"        title: Timetable %{time_table}        dates: "Application dates"        periods: "Application periods" @@ -84,6 +86,8 @@ fr:      edit:        title: "Modifier le calendrier %{time_table}"      show: +      resume: "Validité comprise du %{start_date} au %{end_date} (sans tenir compte des jours d'application)" +      resume_empty: "Calendrier vide"        title: Calendrier %{time_table}        dates: "Dates d'application"        periods: "Périodes d'application" | 
