aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarc Florisson2012-05-15 15:39:53 +0200
committerMarc Florisson2012-05-15 15:39:53 +0200
commit63f7a0b5183f52b8791adf2a61521e12f652a98e (patch)
tree77cb710b8adc0536c3592c0b742d28793f070285 /app
parenta2260f9d3737188d22504f705825ed5a846bb861 (diff)
downloadchouette-core-63f7a0b5183f52b8791adf2a61521e12f652a98e.tar.bz2
add route and stop_point views
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/icons/link-small.pngbin0 -> 228 bytes
-rw-r--r--app/assets/images/icons/move.pngbin0 -> 594 bytes
-rw-r--r--app/assets/stylesheets/routes.css.scss25
-rw-r--r--app/assets/stylesheets/stop_points.css.scss56
-rw-r--r--app/controllers/routes_controller.rb2
-rw-r--r--app/controllers/stop_point_areas_controller.rb22
-rw-r--r--app/controllers/stop_points_controller.rb29
-rw-r--r--app/views/routes/show.html.erb18
-rw-r--r--app/views/stop_points/_stop_point.html.erb20
-rw-r--r--app/views/stop_points/index.html.erb70
-rw-r--r--app/views/stop_points/new.html.erb31
11 files changed, 255 insertions, 18 deletions
diff --git a/app/assets/images/icons/link-small.png b/app/assets/images/icons/link-small.png
new file mode 100644
index 000000000..27cc0d9ee
--- /dev/null
+++ b/app/assets/images/icons/link-small.png
Binary files differ
diff --git a/app/assets/images/icons/move.png b/app/assets/images/icons/move.png
new file mode 100644
index 000000000..2e9bc42be
--- /dev/null
+++ b/app/assets/images/icons/move.png
Binary files differ
diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss
index 3e2e5b5ed..a5c63bf01 100644
--- a/app/assets/stylesheets/routes.css.scss
+++ b/app/assets/stylesheets/routes.css.scss
@@ -58,39 +58,40 @@
font-weight: bold;
}
- .stop_area:after {
+ .stop_point:after {
@include after_div_for_object;
}
- .stop_areas {
+ .stop_points {
margin-top: 20px;
}
- .stop_areas:after {
+ .stop_points:after {
@include content_to_clear;
}
- .route_stop_areas {
+ .route_stop_points {
clear: both;
+ margin: 0px;
+ padding: 0px;
}
- .stop_area {
+ .stop_point {
@include div_for_object;
/* to create multi-column index */
width: 350px;
float: left;
padding-right: 10px;
- .area_type {
+ .position {
width: 25px;
- height: 64px;
+ height: 20px;
float: left;
+ background-color: #61970B;
+ font-weight: bold;
+ color: white;
margin-right: 10px;
-
-
- a {
- text-decoration: none;
- }
+ padding-left: 4px;
}
}
diff --git a/app/assets/stylesheets/stop_points.css.scss b/app/assets/stylesheets/stop_points.css.scss
new file mode 100644
index 000000000..d774fe0e7
--- /dev/null
+++ b/app/assets/stylesheets/stop_points.css.scss
@@ -0,0 +1,56 @@
+// Place all the styles related to the lines controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+@import "common";
+
+#workspace.stop_points.index
+{
+ .stop_point {
+ margin-top: 8px;
+ margin-bottom: 8px;
+
+ .description:after {
+ clear: both;
+ float: left;
+ }
+
+ .description {
+ .position {
+ width: 25px;
+ height: 20px;
+ float: left;
+ background-color: #61970B;
+ font-weight: bold;
+ color: white;
+ margin-right: 10px;
+ padding-left: 4px;
+ }
+ .info {
+ margin-bottom: 5px;
+ font-size: 10px;
+ color: #777;
+ font-weight: normal;
+ line-height: 14px;
+ .actions {
+ margin-top: 3px;
+ a {
+ padding-left: 15px;
+ }
+ a.link {
+ background: url(image-path('icons/link-small.png')) no-repeat 0% 50%;
+ }
+ a.remove {
+ background: url(image-path('user_interface/ui/remove-small.png')) no-repeat 0% 50%;
+ }
+ }
+ }
+ }
+ .handle {
+ float: left;
+ cursor: move;
+ margin-right: 7px;
+ margin-bottom: 20px;
+ }
+ }
+}
+
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 2ed39b0ac..fa429fbac 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -16,7 +16,7 @@ class RoutesController < ChouetteController
def show
@map = RouteMap.new referential, resource
- @stop_areas = resource.stop_areas.paginate(:page => params[:page], :per_page => 10)
+ @stop_points = resource.stop_points.paginate(:page => params[:page], :per_page => 10)
show!
end
diff --git a/app/controllers/stop_point_areas_controller.rb b/app/controllers/stop_point_areas_controller.rb
new file mode 100644
index 000000000..b307936f0
--- /dev/null
+++ b/app/controllers/stop_point_areas_controller.rb
@@ -0,0 +1,22 @@
+class StopPointAreasController < ChouetteController
+
+ respond_to :json, :only => :index
+
+ def index
+ respond_to do |format|
+ format.json { render :json => areas_maps }
+ end
+ end
+
+ def areas_maps
+ areas.collect do |area|
+ { :id => area.id.to_s, :name => "#{area.name} #{area.country_code}" }
+ end
+ end
+
+ def areas
+ Chouette::StopPoint.area_candidates.select{ |p| p.name =~ /#{params[:q]}/i }
+ end
+
+end
+
diff --git a/app/controllers/stop_points_controller.rb b/app/controllers/stop_points_controller.rb
new file mode 100644
index 000000000..a5e5f2a79
--- /dev/null
+++ b/app/controllers/stop_points_controller.rb
@@ -0,0 +1,29 @@
+class StopPointsController < ChouetteController
+ defaults :resource_class => Chouette::StopPoint
+
+ respond_to :html
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line do
+ belongs_to :route, :parent_class => Chouette::Route
+ end
+ end
+
+ def index
+ index!
+ end
+
+ def create
+ create! do |success, failure|
+ success.html { redirect_to referential_line_route_path(@referential,@line,@route) }
+ end
+ end
+
+
+ def sort
+ parent.reorder!( params[:stop_point])
+ render :nothing => true
+ end
+
+end
+
diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb
index c933d3c11..b98bab92a 100644
--- a/app/views/routes/show.html.erb
+++ b/app/views/routes/show.html.erb
@@ -64,18 +64,26 @@
</div>
-<h3 class="route_stop_areas"><%= t('.stop_areas') %></h3>
-<%= will_paginate @stop_areas %>
-<div class="stop_areas paginated_content">
- <%= render :partial => "stop_areas/stop_area", :collection => @stop_areas %>
+<h3 class="route_stop_points"><%= t('.stop_points') %></h3>
+<div class="pagination">
+ <div class="page_info">
+ <%= page_entries_info @stop_points %>
+ </div>
+ <%= will_paginate @stop_points, :container => false %>
+</div>
+<div class="stop_points paginated_content">
+ <%= render :partial => "stop_points/stop_point", :collection => @stop_points %>
+</div>
+<div class="pagination">
+ <%= will_paginate @stop_points, :container => false %>
</div>
-<%= will_paginate @stop_areas %>
<% content_for :sidebar do %>
<ul class="actions">
<li><%= link_to t('routes.actions.edit'), edit_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li>
<li><%= link_to t('routes.actions.destroy'), referential_line_route_path(@referential, @line, @route), :method => :delete, :confirm => t('routes.actions.destroy_confirm'), :class => "remove" %></li>
<li>
+ <%= link_to t('stop_points.actions.index'), referential_line_route_stop_points_path(@referential, @line, @route), :class => "edit" %>
</li>
</ul>
<% end %>
diff --git a/app/views/stop_points/_stop_point.html.erb b/app/views/stop_points/_stop_point.html.erb
new file mode 100644
index 000000000..3d9297b32
--- /dev/null
+++ b/app/views/stop_points/_stop_point.html.erb
@@ -0,0 +1,20 @@
+<%= div_for(stop_point) do %>
+ <span class="position">
+ <%= stop_point.position + 1 %>
+ </span>
+ <%= link_to stop_point.stop_area.name, [@referential, stop_point.stop_area] %>
+ <div class="info">
+ <p>
+ <% unless stop_point.stop_area.geometry %>
+ <span class="warning"><%= t('.no_position') %></span> -
+ <% end %>
+ </p>
+ <p>
+ <%= t('.lines') %> <% stop_point.stop_area.lines.each do |line| %>
+ <span class="line"><%= line.number %></span>
+ <% end %> -
+ <%= stop_point.stop_area.human_attribute_name('country_code') %> <%= stop_point.stop_area.country_code %>
+ </p>
+ </div>
+<% end %>
+
diff --git a/app/views/stop_points/index.html.erb b/app/views/stop_points/index.html.erb
new file mode 100644
index 000000000..54ba8cfe6
--- /dev/null
+++ b/app/views/stop_points/index.html.erb
@@ -0,0 +1,70 @@
+<%= title_tag t('stop_points.index.title', :route => @route.name ) %>
+
+<div class="stop_points_index">
+ <div class="summary">
+ <p>
+ <label><%= @route.class.model_name.human %>: </label>
+ <%= link_to @route.name, [@referential, @line, @route] %>
+ </p>
+ <p>
+ <label><%= @route.human_attribute_name(:line) %>: </label>
+ <%= link_to line_formatted_name( @line), [@referential, @line] %>
+ </p>
+ </div>
+
+ <h3><%= t('stop_points.index.subtitle')%></h3>
+<% if @route.stop_points.empty? %>
+ <p><%= t('.no_stop_point') %></p>
+<% end %>
+ <ul id="stop_areas">
+ <% for stop_point in @route.stop_points %>
+ <%= content_tag_for :li, stop_point do %>
+ <div class="handle" alt="<%= t('stop_points.index.move') %>" title="<%= t('stop_points.index.move') %>" ><%= image_tag "icons/move.png" %></div>
+ <div class="description">
+ <span class="position">
+ <%= stop_point.position + 1 %>
+ </span>
+ <%= stop_point.stop_area.name %>
+ <div class="info">
+ <%= stop_point.stop_area.human_attribute_name('country_code') %> <%= stop_point.stop_area.country_code %>
+ <div class="actions">
+ <%= link_to t("stop_points.actions.show"), referential_stop_area_path(@referential, stop_point.stop_area), :class => "link" %> |
+ <%= link_to t("actions.destroy"), referential_line_route_stop_point_path(@referential, @line, @route, stop_point), :method => :delete, :confirm => t('stop_points.actions.destroy_confirm'), :class => "remove" %>
+ </div>
+ </div>
+ </div>
+ <% end %>
+ <% end %>
+ </ul>
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('stop_points.actions.new'), new_referential_line_route_stop_point_path(@referential, @line, @route), :class => "add" %>
+ </li>
+</ul>
+<% end %>
+<script>
+// Sorting the list
+
+ $(document).ready(function(){
+ $('#stop_areas').sortable({
+ axis: 'y',
+ dropOnEmpty: false,
+ handle: '.handle',
+ cursor: 'crosshair',
+ items: 'li',
+ opacity: 0.4,
+ scroll: true,
+ update: function(){
+ $.ajax({
+ type: 'post',
+ data: $('#stop_areas').sortable('serialize'),
+ dataType: 'script',
+ complete: function(request){
+ $('#stop_areas').effect('highlight');
+ },
+ url: "<%= sort_referential_line_route_stop_points_path( @referential, @line, @route)%>"})
+ }
+ });
+ });
+</script>
+</div>
diff --git a/app/views/stop_points/new.html.erb b/app/views/stop_points/new.html.erb
new file mode 100644
index 000000000..a69840bf6
--- /dev/null
+++ b/app/views/stop_points/new.html.erb
@@ -0,0 +1,31 @@
+<%= title_tag t('.title', :route => @route.name) %>
+
+<%= semantic_form_for [@referential, @line, @route, @stop_point] do |form| %>
+<div>
+ <%= form.inputs do %>
+ <%= form.input :stop_area_id, :label => t('.select_area'),:input_html => { :"data-pre" => [].to_json } %>
+ <% end %>
+
+ <%= form.buttons do %>
+ <%= form.commit_button %>
+ ou <%= link_to "revenir", referential_line_route_stop_points_path(@referential, @line, @route) %>
+ <% end %>
+</div>
+<% end %>
+
+<script>
+ $(function() {
+ $( "#stop_point_stop_area_id" ).tokenInput('<%= referential_stop_point_areas_path(@referential, :format => :json) %>', {
+ crossDomain: false,
+ prePopulate: $('#stop_area_id').data('pre'),
+ tokenLimit: 1,
+ minChars: 3,
+ });
+ });
+</script>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+</ul>
+<% end %>
+