diff options
| author | Bruno Perles | 2015-10-21 17:32:59 +0200 | 
|---|---|---|
| committer | Bruno Perles | 2015-10-23 10:15:25 +0200 | 
| commit | 1cfb7ebb2375154eb76c366bcddd30eb94729e15 (patch) | |
| tree | 9191056d66431bf4b61de1f937f63a6f02850564 /app/views/vehicle_journeys | |
| parent | 14ad4be837e5b19dc0ee47c2e638a517af0fc812 (diff) | |
| download | chouette-core-1cfb7ebb2375154eb76c366bcddd30eb94729e15.tar.bz2 | |
Add vehicle journey frequency
Diffstat (limited to 'app/views/vehicle_journeys')
| -rw-r--r-- | app/views/vehicle_journeys/_form.html.erb | 49 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form_footer.html.erb | 5 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_form_vehicle_journey_at_stops.html.erb | 37 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_show_sidebar.html.erb | 15 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_show_vehicle_journey_at_stops.html.erb | 20 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/_sidebar.html.erb | 11 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/edit.html.erb | 3 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/new.html.erb | 2 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.html.erb | 34 | 
9 files changed, 94 insertions, 82 deletions
diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index e4b1ce432..627b2fa60 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -1,5 +1,6 @@ -<%= semantic_form_for [@referential, @line, @route, @vehicle_journey] do |form| %> +<%= semantic_form_for @vehicle_journey, url: form_url do |form| %>    <%= form.inputs do %> +    <%= form.input :is_frequency, as: :hidden %>      <%= form.input :journey_pattern, :as => :select, :collection => @route.journey_patterns, :member_label => Proc.new { |jp| journey_name(jp) }  %>      <%= form.input :number %>      <%= form.input :published_journey_name %> @@ -18,52 +19,14 @@  	    <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>      </li> -    <% unless @vehicle_journey.vehicle_journey_at_stops.empty? || -       @vehicle_journey.vehicle_journey_at_stops.any? { |vjas| vjas.departure_time.nil? } %>    <div class="vehicle_journey_at_stops"> -      <div class="well"> -        <span class="title"><%= t(".slide_title") %></span> -        <div> -          <span><%= t(".set") %></span> <%= select_tag "", options_for_select( [ [t('.slide_departure'), "departure"], [t('.slide_arrival'), "arrival"] ] ), :class => "departure_or_arrival" %> <span><%= t(".to") %></span> -          <%= select_hour(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.hour) %> -          <%= select_minute(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.min) %> -          <a class="slide btn btn-default"><%= t(".slide") %></a> -        </div> -      </div> -    <% end %> - -    <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> -	    </thead> -	    <tfoot> -	      <tr> -	        <td class="title"> <a class="to_departures"><%= t('.to_departures') %></a></td> -	        <td class="title" ></td> -	        <td class="title"><a class="to_arrivals"><%= t('.to_arrivals') %></a></td> -	      </tr> -	    </tfoot> -	    <tbody class="journey_pattern_dependent_list"> -	      <%= render :partial => "vehicle_journeys/vehicle_journey_at_stop_fields", -	      :collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop, :locals => { :vehicle_journey_at_stops_size => @vehicle_journey.vehicle_journey_at_stops.size } %> - -      </tbody> -    </table>     +    <%= render 'form_vehicle_journey_at_stops', form: form %>    <% end %>    <%= form.actions do %> -    <%= form.action :submit, :as => :button %> -    <%= form.action :cancel, :as => :link %> +    <%= form.action :submit, as: :button, label: t(".submit_#{@vehicle_journey.vehicle_journey_type}") %> +    <%= form.action :cancel, as: :link %>    <% end %>  <% end %> -<% if @vehicle_journey.new_record? %> -  <%= javascript_include_tag new_referential_line_route_vehicle_journey_path(@referential, @line, @route, :format => :js) %> -<% else %> -  <%= javascript_include_tag edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey, :format => :js) %> -<% end %> - +<%= render 'form_footer' %> diff --git a/app/views/vehicle_journeys/_form_footer.html.erb b/app/views/vehicle_journeys/_form_footer.html.erb new file mode 100644 index 000000000..1a5259348 --- /dev/null +++ b/app/views/vehicle_journeys/_form_footer.html.erb @@ -0,0 +1,5 @@ +<% if @vehicle_journey.new_record? %> +  <%= javascript_include_tag new_referential_line_route_vehicle_journey_path(@referential, @line, @route, :format => :js) %> +<% else %> +  <%= javascript_include_tag edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey, :format => :js) %> +<% end %> diff --git a/app/views/vehicle_journeys/_form_vehicle_journey_at_stops.html.erb b/app/views/vehicle_journeys/_form_vehicle_journey_at_stops.html.erb new file mode 100644 index 000000000..826733135 --- /dev/null +++ b/app/views/vehicle_journeys/_form_vehicle_journey_at_stops.html.erb @@ -0,0 +1,37 @@ +<% unless @vehicle_journey.vehicle_journey_at_stops.empty? || @vehicle_journey.vehicle_journey_at_stops.any? { |vjas| vjas.departure_time.nil? } %> +  <div class="vehicle_journey_at_stops"> +    <div class="well"> +      <span class="title"><%= t('vehicle_journeys.form.slide_title') %></span> +      <div> +        <span><%= t('vehicle_journeys.form.set') %></span> +        <%= select_tag '', options_for_select( [ [t('vehicle_journeys.form.slide_departure'), "departure"], [t('vehicle_journeys.form.slide_arrival'), "arrival"] ] ), :class => "departure_or_arrival" %> +        <span><%= t('vehicle_journeys.form.to') %></span> +        <%= select_hour(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.hour) %> +        <%= select_minute(@vehicle_journey.vehicle_journey_at_stops.first.departure_time.min) %> +        <a class="slide btn btn-default"><%= t('vehicle_journeys.form.slide') %></a> +      </div> +    </div> +  </div> +<% end %> + +<table class="table table-hover table-striped"> +  <thead> +    <tr> +      <th class="hour title"><%= t('vehicle_journeys.form.arrival') %></th> +      <th class="stop title"><%= t('vehicle_journeys.form.stop_title') %></th> +      <th class="hour title"><%= t('vehicle_journeys.form.departure') %></th> +    </tr> +  </thead> +  <tfoot> +    <tr> +      <td class="title"><a class="to_departures"><%= t('vehicle_journeys.form.to_departures') %></a></td> +      <td class="title"></td> +      <td class="title"><a class="to_arrivals"><%= t('vehicle_journeys.form.to_arrivals') %></a></td> +    </tr> +  </tfoot> +  <tbody class="journey_pattern_dependent_list"> +    <%= render :partial => "vehicle_journeys/vehicle_journey_at_stop_fields", +               :collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop, +               :locals => { :vehicle_journey_at_stops_size => @vehicle_journey.vehicle_journey_at_stops.size } %> +  </tbody> +</table> diff --git a/app/views/vehicle_journeys/_show_sidebar.html.erb b/app/views/vehicle_journeys/_show_sidebar.html.erb new file mode 100644 index 000000000..e649edaef --- /dev/null +++ b/app/views/vehicle_journeys/_show_sidebar.html.erb @@ -0,0 +1,15 @@ +<% content_for :sidebar do %> +  <ul class="actions"> +    <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> +    <li><%= link_to t('vehicle_journeys.actions.new_frequency'), new_referential_line_route_vehicle_journeys_frequency_path(@referential, @line, @route), :class => "add" %></li> +    <li><%= link_to t('vehicle_journeys.actions.edit'), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :class => "edit" %></li> +    <li><%= link_to t('vehicle_journeys.actions.destroy'), referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :method => :delete, :data => {:confirm =>  t('vehicle_journeys.actions.destroy_confirm')}, :class => "remove" %></li> +    <% unless @vehicle_journey.vehicle_journey_at_stops.empty? %> +      <li> +        <i class="fa fa-cubes fa-fw" style="color:#D98F3B;"></i> +        <%= link_to t('vehicle_journeys.show.translation_form'), new_referential_line_route_vehicle_journey_vehicle_translation_path(@referential, @line, @route, @vehicle_journey), {:remote => true, 'data-toggle' =>  "modal", 'data-target' => '#modal_translation', :class => "with_fa" } %> +      </li> +    <% end %> +  </ul> +  <%= creation_tag(@vehicle_journey) %> +<% end %> diff --git a/app/views/vehicle_journeys/_show_vehicle_journey_at_stops.html.erb b/app/views/vehicle_journeys/_show_vehicle_journey_at_stops.html.erb new file mode 100644 index 000000000..e2e0ef82e --- /dev/null +++ b/app/views/vehicle_journeys/_show_vehicle_journey_at_stops.html.erb @@ -0,0 +1,20 @@ +<div class="vehicle_journey_at_stops content"> +  <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> +    <thead> +    <tbody> +    <% @vehicle_journey.vehicle_journey_at_stops.each_with_index do |vjas, index| %> +      <tr class="<%= index%2==0 ? "odd" : "even" %>"> +        <td class="hour <%= vjas.arrival_time.nil? ? "missing" : "" %>"><%= vjas.arrival_time ? l( vjas.arrival_time, :format => :hour) : "" %></td> +        <td><%= link_to vjas.stop_point.stop_area.name, [@referential, vjas.stop_point.stop_area] %></td> +        <td class="hour <%= vjas.departure_time.nil? ? "missing" : "" %>"><%= vjas.departure_time ? l( vjas.departure_time, :format => :hour) : "" %></td> +      </tr> +    <% end %> +    </tbody> +  </table> +</div> diff --git a/app/views/vehicle_journeys/_sidebar.html.erb b/app/views/vehicle_journeys/_sidebar.html.erb index 8d6f310d3..4522fa109 100644 --- a/app/views/vehicle_journeys/_sidebar.html.erb +++ b/app/views/vehicle_journeys/_sidebar.html.erb @@ -1,6 +1,7 @@ -  <ul class="actions"> -    <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> -	<li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li> -    <li><%= link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :zip), :class => "export" %></li> -  </ul> +<ul class="actions"> +  <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> +  <li><%= link_to t('vehicle_journeys.actions.new_frequency'), new_referential_line_route_vehicle_journeys_frequency_path(@referential, @line, @route), :class => "add" %></li> +  <li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li> +  <li><%= link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :zip), :class => "export" %></li> +</ul> diff --git a/app/views/vehicle_journeys/edit.html.erb b/app/views/vehicle_journeys/edit.html.erb index 51653a34a..2d87ffe57 100644 --- a/app/views/vehicle_journeys/edit.html.erb +++ b/app/views/vehicle_journeys/edit.html.erb @@ -1,4 +1,5 @@  <%= title_tag edit_vehicle_title(@vehicle_journey) %> -<%= render "form" %> +<%= render 'form', form_url: referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey) %> + diff --git a/app/views/vehicle_journeys/new.html.erb b/app/views/vehicle_journeys/new.html.erb index a32e9cc31..19b31e422 100644 --- a/app/views/vehicle_journeys/new.html.erb +++ b/app/views/vehicle_journeys/new.html.erb @@ -1,4 +1,4 @@  <%= title_tag t('vehicle_journeys.new.title') %> -<%= render "form" %> +<%= render partial: 'form', locals: { form_url: referential_line_route_vehicle_journeys_path(@referential, @line, @route, @vehicle_journey) } %> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index 695b5c8b5..3bdfbb945 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -79,41 +79,11 @@    </div>  </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-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> -    <thead> -      <tbody> -        <% @vehicle_journey.vehicle_journey_at_stops.each_with_index do |vjas, index| %> -        <tr class="<%= index%2==0 ? "odd" : "even" %>"> -          <td class="hour <%= vjas.arrival_time.nil? ? "missing" : "" %>"><%= vjas.arrival_time ? l( vjas.arrival_time, :format => :hour) : "" %></td> -          <td><%= link_to vjas.stop_point.stop_area.name, [@referential, vjas.stop_point.stop_area] %></td> -          <td class="hour <%= vjas.departure_time.nil? ? "missing" : "" %>"><%= vjas.departure_time ? l( vjas.departure_time, :format => :hour) : "" %></td> -        </tr> -        <% end %> -      </tbody> -  </table> -</div> +<%= render 'show_vehicle_journey_at_stops' %>  <h3><%= t('.time_tables') %></h3>  <div class="time_tables paginated_content">    <%= paginated_content @vehicle_journey.time_tables, "time_tables/time_table", :delete => false %>  </div> - -<% content_for :sidebar do %> -  <ul class="actions"> -    <li><%= link_to t('vehicle_journeys.actions.new'), new_referential_line_route_vehicle_journey_path(@referential, @line, @route), :class => "add" %></li> -    <li><%= link_to t('vehicle_journeys.actions.edit'), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :class => "edit" %></li> -    <li><%= link_to t('vehicle_journeys.actions.destroy'), referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :method => :delete, :data => {:confirm =>  t('vehicle_journeys.actions.destroy_confirm')}, :class => "remove" %></li> -  <% unless @vehicle_journey.vehicle_journey_at_stops.empty? %> -    <li><font color="#D98F3B"><i class="fa fa-cubes fa-fw"></i></font><%= link_to t('.translation_form'), new_referential_line_route_vehicle_journey_vehicle_translation_path(@referential, @line, @route, @vehicle_journey), {:remote => true, 'data-toggle' =>  "modal", 'data-target' => '#modal_translation', :class => "with_fa" } %></li> -  <% end %> -  </ul> -  <%= creation_tag(@vehicle_journey) %> -<% end %> +<%= render 'show_sidebar' %>  | 
