aboutsummaryrefslogtreecommitdiffstats
path: root/app/views
diff options
context:
space:
mode:
authorBruno Perles2015-12-16 10:02:29 +0100
committerBruno Perles2015-12-16 10:02:29 +0100
commit013f4fa8fe9bb08f3ed1d15f905ca2a8437d6aa7 (patch)
tree426b9c17167c10547da2222517cbd4433ae554fe /app/views
parent2590606c5912a85b8cb1aaa40c57dab67d75e7f7 (diff)
downloadchouette-core-013f4fa8fe9bb08f3ed1d15f905ca2a8437d6aa7.tar.bz2
Add route_sections for traces
Diffstat (limited to 'app/views')
-rw-r--r--app/views/journey_patterns/show.html.erb4
-rw-r--r--app/views/referentials/_counts.html.erb4
-rw-r--r--app/views/route_sections/_form.html.erb24
-rw-r--r--app/views/route_sections/edit.html.erb4
-rw-r--r--app/views/route_sections/index.html.erb56
-rw-r--r--app/views/route_sections/new.html.erb3
-rw-r--r--app/views/route_sections/show.html.erb28
-rw-r--r--app/views/route_sections/show.kml.erb8
-rw-r--r--app/views/route_sections_selectors/_selection.js.erb28
-rw-r--r--app/views/route_sections_selectors/edit.html.erb48
-rw-r--r--app/views/shared/_header.erb4
11 files changed, 209 insertions, 2 deletions
diff --git a/app/views/journey_patterns/show.html.erb b/app/views/journey_patterns/show.html.erb
index dc9e852fa..3a2b18ea1 100644
--- a/app/views/journey_patterns/show.html.erb
+++ b/app/views/journey_patterns/show.html.erb
@@ -34,9 +34,9 @@
<ul class="actions">
<li><%= link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), :class => "add" %></li>
<li><%= link_to t('journey_patterns.actions.edit'), edit_referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern), :class => "edit" %></li>
- <li><%= link_to t('journey_patterns.actions.destroy'), referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern), :method => :delete, :data => {:confirm => t('journey_patterns.actions.destroy_confirm')}, :class => "remove" %></li>
+ <li><%= link_to t('journey_patterns.actions.destroy'), referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern), :method => :delete, :data => {:confirm => t('journey_patterns.actions.destroy_confirm')}, :class => "remove" %></li>
+ <li><%= link_to t('journey_patterns.actions.edit_route_sections'), edit_referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern), class: 'edit' %></li>
<li><%= link_to t('journey_patterns.journey_pattern.vehicle_journey_at_stops'), referential_line_route_vehicle_journeys_path(@referential, @line, @route, :q => {:journey_pattern_id_eq => @journey_pattern.id}), :class => "clock" %></li>
</ul>
<%= creation_tag(@journey_pattern) %>
<% end %>
-
diff --git a/app/views/referentials/_counts.html.erb b/app/views/referentials/_counts.html.erb
index 3ade4e945..20078429b 100644
--- a/app/views/referentials/_counts.html.erb
+++ b/app/views/referentials/_counts.html.erb
@@ -32,6 +32,10 @@
<%= Referential.human_attribute_name("connection_links") %>
</li>
<li class="list-group-item">
+ <span class="badge"><%= @referential.route_sections.size %></span>
+ <%= link_to Referential.human_attribute_name("route_sections"), referential_route_sections_path(@referential) %>
+ </li>
+ <li class="list-group-item">
<span class="badge"><%= @referential.stop_areas.size %></span>
<%= Referential.human_attribute_name("stop_areas") %>
</li>
diff --git a/app/views/route_sections/_form.html.erb b/app/views/route_sections/_form.html.erb
new file mode 100644
index 000000000..28a1dd47a
--- /dev/null
+++ b/app/views/route_sections/_form.html.erb
@@ -0,0 +1,24 @@
+<%= semantic_form_for [@referential, @route_section] do |form| %>
+ <%= form.inputs do %>
+ <% if @route_section.new_record? %>
+ <%= form.input :departure, as: :select, collection: @stop_areas, include_blank: false %>
+ <%= form.input :arrival, as: :select, collection: @stop_areas, include_blank: false %>
+ <% else %>
+ <li class="input optional">
+ <label class="label"><%= @route_section.human_attribute_name("departure") %></label>
+ <%= @route_section.departure.name %>
+ </li>
+ <li class="input optional">
+ <label class="label"><%= @route_section.human_attribute_name("arrival") %></label>
+ <%= @route_section.arrival.name %>
+ </li>
+ <%= form.input :editable_geometry, as: :hidden %>
+ <% end %>
+
+ <%= form.input :no_processing, label: t('.no_processing'), as: :select, collection: { t('.standard_processor') => false, t('.no_processor') => true }, include_blank: false %>
+ <% end %>
+ <%= form.actions do %>
+ <%= form.action :submit, :as => :button, label: t('.submit') %>
+ <%= form.action :cancel, :as => :link %>
+ <% end %>
+<% end %>
diff --git a/app/views/route_sections/edit.html.erb b/app/views/route_sections/edit.html.erb
new file mode 100644
index 000000000..80b7bde4a
--- /dev/null
+++ b/app/views/route_sections/edit.html.erb
@@ -0,0 +1,4 @@
+<%= title_tag t('route_sections.edit.title') %>
+
+<%= @map.to_html %>
+<%= render "form" %>
diff --git a/app/views/route_sections/index.html.erb b/app/views/route_sections/index.html.erb
new file mode 100644
index 000000000..5d7bef989
--- /dev/null
+++ b/app/views/route_sections/index.html.erb
@@ -0,0 +1,56 @@
+<%= title_tag t('.title') %>
+
+<%= form_for search, url: referential_route_sections_path(@referential), method: :get, class: "form-inline" do |form| %>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <div class="col-md-6">
+ <%= form.text_field :departure_name, class: 'form-control', placeholder: Chouette::RouteSection.human_attribute_name(:departure) %>
+ </div>
+
+ <div class="input-group col-md-6">
+ <%= form.text_field :arrival_name, class: 'form-control', placeholder: Chouette::RouteSection.human_attribute_name(:arrival) %>
+ <div class="input-group-btn">
+ <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
+ </div>
+ </div>
+ </div>
+
+ <div class="panel-body">
+ <div class="col-md-4">
+ <%= form.select :line_id, @referential.lines.order(:name).pluck(:name, :id), { include_blank: t('.all_lines')}, class: 'form-control' %>
+ </div>
+ </div>
+ </div>
+<% end %>
+
+<table class="table table-hover table-striped">
+ <thead>
+ <tr>
+ <th><%= Chouette::RouteSection.human_attribute_name :departure %></th>
+ <th><%= Chouette::RouteSection.human_attribute_name :arrival %></th>
+ <th class="distance"><%= Chouette::RouteSection.human_attribute_name :distance %></th>
+ <th class="points"><%= Chouette::RouteSection.human_attribute_name :points %></th>
+ <th class="actions"></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @route_sections.each do |route_section| %>
+ <tr>
+ <td><%= route_section.departure.name %> <%= link_to content_tag(:i, "", class: "fa fa-external-link"), referential_stop_area_path(@referential, route_section.departure) %></td>
+ <td><%= route_section.arrival.name %> <%= link_to content_tag(:i, "", class: "fa fa-external-link"), referential_stop_area_path(@referential, route_section.arrival) %></td>
+ <td class="distance"><%= route_section.distance.to_i if route_section.distance %></td>
+ <td class="points"><%= route_section.via_count if route_section.via_count > 0 %></td>
+ <td class="actions">
+ <%= link_to t('.actions.show'), referential_route_section_path(@referential, route_section), class: "view" %>
+ <%= link_to t('.actions.edit'), edit_referential_route_section_path(@referential, route_section), class: "edit" %>
+ <%= link_to t('.actions.destroy'), referential_route_section_path(@referential, route_section), method: :delete, data: { confirm: t('route_sections.actions.destroy_confirm') }, class: "remove" %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+
+</table>
+
+<div class="pagination">
+ <%= will_paginate @route_sections, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer %>
+</div>
diff --git a/app/views/route_sections/new.html.erb b/app/views/route_sections/new.html.erb
new file mode 100644
index 000000000..1ff3c74d0
--- /dev/null
+++ b/app/views/route_sections/new.html.erb
@@ -0,0 +1,3 @@
+<%= title_tag t('route_sections.new.title') %>
+
+<%= render "form" %>
diff --git a/app/views/route_sections/show.html.erb b/app/views/route_sections/show.html.erb
new file mode 100644
index 000000000..61c7c8149
--- /dev/null
+++ b/app/views/route_sections/show.html.erb
@@ -0,0 +1,28 @@
+<%= title_tag t('.title') %>
+
+<div class="route_section">
+ <%= @map.to_html %>
+
+ <div class="summary">
+ <p>
+ <label><%= @route_section.human_attribute_name("departure") %>: </label>
+ <%= @route_section.departure.name %>
+ </p>
+ <p>
+ <label><%= @route_section.human_attribute_name("arrival") %>: </label>
+ <%= @route_section.arrival.name %>
+ </p>
+ <p>
+ <label><%= @route_section.human_attribute_name("distance") %>: </label>
+ <%= "#{@route_section.distance.round}m" if @route_section.distance %>
+ </p>
+ </div>
+</div>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('route_sections.actions.edit'), edit_referential_route_section_path(@referential, @route_section), :class => "edit" %></li>
+ <li><%= link_to t('route_sections.actions.destroy'), referential_route_section_path(@referential, @route_section), :method => :delete, :data => {:confirm => t('route_sections.actions.destroy_confirm')}, :class => "remove" %></li>
+</ul>
+ <%= creation_tag(@route_section) %>
+<% end %>
diff --git a/app/views/route_sections/show.kml.erb b/app/views/route_sections/show.kml.erb
new file mode 100644
index 000000000..0d41f0fdb
--- /dev/null
+++ b/app/views/route_sections/show.kml.erb
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2">
+ <Document>
+ <Placemark id="route-section-<%= @route_section.id %>">
+ <%= @route_section.geometry(params[:mode]).kml_representation.html_safe %>
+ </Placemark>
+ </Document>
+</kml>
diff --git a/app/views/route_sections_selectors/_selection.js.erb b/app/views/route_sections_selectors/_selection.js.erb
new file mode 100644
index 000000000..70d03cf75
--- /dev/null
+++ b/app/views/route_sections_selectors/_selection.js.erb
@@ -0,0 +1,28 @@
+<div>
+ <span class="departure">
+ <label><%= @route_section.human_attribute_name("departure") %>:</label>
+ <%= link_to @route_section.departure.name, referential_stop_area_path(@referential, @route_section.departure) %>
+ </span>
+
+ <span class="arrival">
+ <label><%= @route_section.human_attribute_name("arrival") %>:</label>
+ <%= link_to @route_section.arrival.name, referential_stop_area_path(@referential, @route_section.arrival) %>
+ </span>
+
+ <span class="distance">
+ <label><%= @route_section.human_attribute_name("distance") %>:</label>
+ <%= "#{@route_section.distance.to_i} m" if @route_section.distance > 0 %>
+ </span>
+
+ <% if @route_section.via_count > 0 %>
+ <span class="via_count">
+ <label><%= @route_section.human_attribute_name("via_count") %>:</label>
+ <%= @route_section.via_count if @route_section.via_count > 0 %>
+ </span>
+ <% end %>
+
+ <span class="actions">
+ <%= link_to_edit_route_section @route_section %>
+ <%= link_to_create_route_section @route_section.departure, @route_section.arrival %>
+ </span>
+</div>
diff --git a/app/views/route_sections_selectors/edit.html.erb b/app/views/route_sections_selectors/edit.html.erb
new file mode 100644
index 000000000..0cd58d9c1
--- /dev/null
+++ b/app/views/route_sections_selectors/edit.html.erb
@@ -0,0 +1,48 @@
+<%= title_tag t('.title', journey_pattern: journey_name(@journey_pattern)) %>
+
+<div class = "large-map">
+ <%= @map.to_html %>
+</div>
+
+<%= semantic_form_for resource, url: referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern), method: :put do |form| %>
+
+<h3><%= t('.selection.title') %></h3>
+
+<div id="map-selection" style="display: none">
+ <div>
+ </div>
+</div>
+
+<div id="empty-map-selection">
+ <%= t('.no_selection') %>
+</div>
+
+<h3><%= t('.form.title') %></h3>
+
+<table class="table table-hover table-striped">
+ <tbody>
+ <%= form.fields_for :sections do |section_form| %>
+ <tr>
+ <td><%= link_to section_form.object.departure.name, referential_stop_area_path(@referential, section_form.object.departure) %></td>
+ <td class="route_section">
+ <% if section_form.object.candidates.present? %>
+ <%= section_form.input :route_section_id, as: :select, label: false, collection: section_form.object.candidates, include_blank: t('.no_selection') %>
+ <% else %>
+ <%= t('.no_candidate') %>
+ <% end %>
+ </td>
+ <td class="action">
+ <%= link_to_edit_route_section section_form.object.route_section %>
+ <%= link_to_create_route_section section_form.object.departure, section_form.object.arrival %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<%= form.actions do %>
+ <%= form.action :submit, as: :button, label: t('.submit') %>
+ <%= form.action :cancel, as: :link, url: referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern) %>
+<% end %>
+
+<% end %>
diff --git a/app/views/shared/_header.erb b/app/views/shared/_header.erb
index 1e8a63fba..9d53d807f 100644
--- a/app/views/shared/_header.erb
+++ b/app/views/shared/_header.erb
@@ -65,6 +65,10 @@
<span class="badge pull-right"><%= @referential.time_tables.size %></span><%= Referential.human_attribute_name("time_tables") %>
<% end %>
</li>
+ <li><%= link_to referential_route_sections_path(@referential) do %>
+ <span class="badge pull-right"><%= @referential.route_sections.size %></span><%= Referential.human_attribute_name("route_sections") %>
+ <% end %>
+ </li>
<li><%= link_to referential_timebands_path(@referential) do %>
<span class="badge pull-right"><%= @referential.timebands.size %></span><%= Referential.human_attribute_name("timebands") %>
<% end %>