diff options
| author | Michel Etienne | 2014-08-19 15:40:36 +0200 |
|---|---|---|
| committer | Michel Etienne | 2014-08-19 15:40:36 +0200 |
| commit | fcd08af1f843900e5664f92fe814138f7d6e50e9 (patch) | |
| tree | 5c45b59235183cc71ea99554c0ca556017b050b3 | |
| parent | 1800c071b0ef185077d14fc0355ae2a53b904008 (diff) | |
| parent | 27495717e45bfc8ab107822b71053425f4179eaa (diff) | |
| download | chouette-core-fcd08af1f843900e5664f92fe814138f7d6e50e9.tar.bz2 | |
Merge branch 'sismo' of github.com:afimb/chouette2 into sismo
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | app/assets/javascripts/vehicle_journey.js.coffee | 2 | ||||
| -rw-r--r-- | app/assets/stylesheets/main/vehicle_journeys.css.scss | 15 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 16 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 1 | ||||
| -rw-r--r-- | app/views/layouts/without_sidebar.html.erb | 1 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.erb | 3 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 35 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.html.erb | 2 | ||||
| -rw-r--r-- | config/application.rb | 2 | ||||
| -rw-r--r-- | lib/bootstrap_breadcrumbs_builder.rb | 31 |
12 files changed, 80 insertions, 31 deletions
@@ -51,6 +51,7 @@ gem 'simple_form' gem 'tagmanager-rails', '~> 3.0.1.0' #gem 'typeahead-rails', '~> 0.10.1' gem "twitter-typeahead-rails", :git => "https://github.com/ldonnet/twitter-typeahead-rails" +gem "breadcrumbs_on_rails" # Format Output gem 'json' diff --git a/Gemfile.lock b/Gemfile.lock index edf070b29..0517b95e3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,6 +77,7 @@ GEM bootswatch-rails (3.1.1.1) railties (>= 3.1) bouncy-castle-java (1.5.0146.1) + breadcrumbs_on_rails (2.3.0) builder (3.0.4) calendar_helper (0.2.5) open4 @@ -385,6 +386,7 @@ DEPENDENCIES acts_as_tree-1.8 (= 1.1.0) bootstrap-sass (~> 3.1.1) bootswatch-rails + breadcrumbs_on_rails calendar_helper (= 0.2.5) capistrano capistrano-ext diff --git a/app/assets/javascripts/vehicle_journey.js.coffee b/app/assets/javascripts/vehicle_journey.js.coffee index 145e86f0f..b2f8b9ec7 100644 --- a/app/assets/javascripts/vehicle_journey.js.coffee +++ b/app/assets/javascripts/vehicle_journey.js.coffee @@ -55,7 +55,7 @@ jQuery -> hour = parseInt( $(".vehicle_journeys .date select#date_hour").val()) minute = parseInt( $(".vehicle_journeys .date select#date_minute").val()) - selector_prefix = ".stop_times .journey_pattern_dependent_list" + selector_prefix = ".vehicle_journey_at_stops .journey_pattern_dependent_list" if $(this).hasClass("departure") vjas_hour_selector = selector_prefix + " .departure_time select.hour" vjas_minute_selector = selector_prefix + " .departure_time select.minute" diff --git a/app/assets/stylesheets/main/vehicle_journeys.css.scss b/app/assets/stylesheets/main/vehicle_journeys.css.scss index 52a9978e0..78e936ac3 100644 --- a/app/assets/stylesheets/main/vehicle_journeys.css.scss +++ b/app/assets/stylesheets/main/vehicle_journeys.css.scss @@ -4,14 +4,21 @@ #workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update, #workspace.vehicle_journeys.create, #workspace.vehicle_journeys.new { - #route_color{ width: 100px; - color: white; - font-weight: bold;} + #route_color{ + width: 100px; + color: white; + font-weight: bold; + } + .journey_pattern_dependent_list { tr.no_stop { display: none; } } + .time_table_list { padding-left: 25%; } - .vehicle_journey_at_stops { margin-left: 20%; } + + .vehicle_journey_at_stops { + margin-left: 25%; + } } #workspace.vehicle_journeys.index diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 14cc7aa10..a18603ed9 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -8,19 +8,27 @@ class TimeTablesController < ChouetteController belongs_to :referential def show + add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) + @year = params[:year] ? params[:year].to_i : Date.today.cwyear @time_table_combination = TimeTableCombination.new show! end - def new + def new + add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) + @autocomplete_items = ActsAsTaggableOn::Tag.all new! end - def edit - @autocomplete_items = ActsAsTaggableOn::Tag.all - edit! + def edit + edit! do + add_breadcrumb Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) + add_breadcrumb @time_table.comment, referential_time_table_path(@referential, @time_table) + + @autocomplete_items = ActsAsTaggableOn::Tag.all + end end def comment_filter diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5ff860a54..418b90e72 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,6 +25,7 @@ <div class="col-md-9"> <div id="workspace" class="<%= controller_name %> <%= action_name %>"> <%= render partial: "shared/flash_messages", flash: flash %> + <%= render partial: "shared/breadcrumb" %> <%= yield %> </div> </div> diff --git a/app/views/layouts/without_sidebar.html.erb b/app/views/layouts/without_sidebar.html.erb index d07139c2f..c61dc6b25 100644 --- a/app/views/layouts/without_sidebar.html.erb +++ b/app/views/layouts/without_sidebar.html.erb @@ -25,6 +25,7 @@ <div class="col-md-12"> <div id="workspace" class="<%= controller_name %> <%= action_name %>"> <%= render partial: "shared/flash_messages", flash: flash %> + <%= render partial: "shared/breadcrumb" %> <%= yield %> </div> </div> diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb index b5c5c9dfe..e02d96a58 100644 --- a/app/views/time_tables/show.html.erb +++ b/app/views/time_tables/show.html.erb @@ -1,7 +1,4 @@ <% require 'calendar_helper' %> -<ol class="breadcrumb"> - <li><%= link_to Referential.human_attribute_name("time_tables"), referential_time_tables_path(@referential) %></li> -</ol> <%= title_tag t('time_tables.show.title', :time_table => @time_table.comment )%> diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 934e76066..e785c70dc 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -11,26 +11,29 @@ <%= form.input :facility %> <%= form.input :vehicle_type_identifier%> <%= form.input :objectid, :required => !@vehicle_journey.new_record? %> - - <%= form.inputs :class => "stop_times", :name => @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids) do %> - <table border="0" class="vehicle_journey_at_stops"> + <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :text, :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map { |time_table| { :id => time_table.id, :name => time_table_description(time_table) } } ).to_json } %> + <li class="input"> + <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %> + </li> + <div class="vehicle_journey_at_stops"> + <table class="table table-hover table-striped"> <thead> <tr> <th class="hour title"><%= t('.arrival') %></th> <th class="stop title" ><%= t('.stop_title') %></th> <th class="hour title"><%= t('.departure') %></th> </tr> - <% unless @vehicle_journey.vehicle_journey_at_stops.empty? || - @vehicle_journey.vehicle_journey_at_stops.any? { |vjas| vjas.departure_time.nil? } %> - <tr> - <td class="title"> <a class="slide arrival"><%= t('.slide_arrival') %></a></td> - <td class="date"> - <%= select_hour(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.hour, :class => "hour") %> - <%= select_minute(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.min, :class => "minute") %> - </td> - <td class="title"> <a class="slide departure"><%= t('.slide_departure') %></a></td> - </tr> - <% end %> + <% unless @vehicle_journey.vehicle_journey_at_stops.empty? || + @vehicle_journey.vehicle_journey_at_stops.any? { |vjas| vjas.departure_time.nil? } %> + <tr> + <td class="title"> <a class="slide arrival"><%= t('.slide_arrival') %></a></td> + <td class="date"> + <%= select_hour(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.hour, :class => "hour") %> + <%= select_minute(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.min, :class => "minute") %> + </td> + <td class="title"> <a class="slide departure"><%= t('.slide_departure') %></a></td> + </tr> + <% end %> </thead> <tfoot> <tr> @@ -44,9 +47,7 @@ :collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop %> </tbody> </table> - <% end %> - <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :text, :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map { |time_table| { :id => time_table.id, :name => time_table_description(time_table) } } ).to_json } %> - + </div> <% end %> <%= form.actions do %> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index 235268575..01f44c7b0 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -68,7 +68,7 @@ </div> <h3><%= @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids) %></h3> <div class="vehicle_journey_at_stops content"> - <table class="table table-hover"> + <table class="table table-hover table-striped"> <thead> <tr> <th class="hour title"><%= t('.arrival') %></th> diff --git a/config/application.rb b/config/application.rb index 7ce9e9d0a..d86b254f3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ module ChouetteIhm # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths += %W(#{config.root}/lib) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. diff --git a/lib/bootstrap_breadcrumbs_builder.rb b/lib/bootstrap_breadcrumbs_builder.rb new file mode 100644 index 000000000..daa154bdf --- /dev/null +++ b/lib/bootstrap_breadcrumbs_builder.rb @@ -0,0 +1,31 @@ +# bootstrap builder for breadcrumbs_on_rails gem +class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder + def render + @context.content_tag(:ul, class: 'breadcrumb') do + @elements.collect do |element| + render_element(element) + end.join.html_safe + end + end + + def render_element(element) + active = element.path.nil? || @context.current_page?(compute_path(element)) + # Bootstrap use '/' divider by default but you can customize it: + # divider = @context.content_tag(:span, '/'.html_safe, class: 'divider') unless active + + @context.content_tag(:li, :class => ('active' if active)) do + content = if element.path.nil? + compute_name(element) + else + @context.link_to_unless_current(compute_name(element), compute_path(element), element.options) + end + + # content + (divider || '') + content + end + end +end + + +# Usage: +# = render_breadcrumbs(builder: BootstrapBreadcrumbsBuilder)
\ No newline at end of file |
