From e1c8a62852616fcfcc6a79b6cc4aefc50e4bd628 Mon Sep 17 00:00:00 2001
From: Michel Etienne
Date: Fri, 29 Aug 2014 11:44:05 +0200
Subject: active pagination on remote
---
app/controllers/import_tasks_controller.rb | 2 +-
app/controllers/stop_area_copies_controller.rb | 18 ++--------
app/helpers/application_helper.rb | 42 +++++++++++++++++++++-
.../remote_bootstrap_pagination_link_renderer.rb | 8 +++++
app/models/stop_area_copy.rb | 16 +++++++++
app/views/companies/_companies.erb | 2 +-
.../_compliance_check_task.erb | 25 -------------
.../_compliance_check_task.html.erb | 25 +++++++++++++
.../_compliance_check_tasks.html.erb | 9 +++++
app/views/compliance_check_tasks/index.html.erb | 11 ++----
app/views/compliance_check_tasks/index.js.erb | 1 +
app/views/connection_links/_connection_links.erb | 2 +-
app/views/exports/_exports.html.erb | 17 +++++++++
app/views/exports/index.html.erb | 19 ++--------
app/views/exports/index.js.erb | 1 +
app/views/group_of_lines/_group_of_lines.erb | 2 +-
app/views/import_tasks/_import_tasks.html.erb | 9 +++++
app/views/import_tasks/index.html.erb | 12 ++-----
app/views/import_tasks/index.js.erb | 1 +
app/views/lines/_lines.html.erb | 2 +-
app/views/networks/_networks.erb | 2 +-
app/views/shared/_header.erb | 2 +-
app/views/stop_area_copies/new.html.erb | 7 ++--
app/views/stop_areas/_stop_areas.html.erb | 2 +-
app/views/time_tables/_time_tables.html.erb | 2 +-
25 files changed, 150 insertions(+), 89 deletions(-)
create mode 100644 app/helpers/remote_bootstrap_pagination_link_renderer.rb
delete mode 100644 app/views/compliance_check_tasks/_compliance_check_task.erb
create mode 100644 app/views/compliance_check_tasks/_compliance_check_task.html.erb
create mode 100644 app/views/compliance_check_tasks/_compliance_check_tasks.html.erb
create mode 100644 app/views/compliance_check_tasks/index.js.erb
create mode 100644 app/views/exports/_exports.html.erb
create mode 100644 app/views/exports/index.js.erb
create mode 100644 app/views/import_tasks/_import_tasks.html.erb
create mode 100644 app/views/import_tasks/index.js.erb
diff --git a/app/controllers/import_tasks_controller.rb b/app/controllers/import_tasks_controller.rb
index 37de83f4d..1d7e8c3aa 100644
--- a/app/controllers/import_tasks_controller.rb
+++ b/app/controllers/import_tasks_controller.rb
@@ -1,6 +1,6 @@
class ImportTasksController < ChouetteController
respond_to :html, :xml, :json
- respond_to :js, :only => :show
+ respond_to :js, :only => [:show, :index]
belongs_to :referential
def new
diff --git a/app/controllers/stop_area_copies_controller.rb b/app/controllers/stop_area_copies_controller.rb
index 01dfc5894..dbb66c2bd 100644
--- a/app/controllers/stop_area_copies_controller.rb
+++ b/app/controllers/stop_area_copies_controller.rb
@@ -7,25 +7,13 @@ class StopAreaCopiesController < ChouetteController
respond_to :html, :only => :new
def new
- @stop_area_copy = StopAreaCopy.new(:source_id => parent.id, :hierarchy => params[:hierarchy])
- if @stop_area_copy.hierarchy == "child"
- if parent.area_type.underscore == "stop_place"
- @stop_area_copy.area_type="commercial_stop_point"
- else
- @stop_area_copy.area_type="boarding_position"
- end
- else
- if parent.area_type.underscore == "stop_place" || parent.area_type.underscore == "commercial_stop_point"
- @stop_area_copy.area_type="stop_place"
- else
- @stop_area_copy.area_type="commercial_stop_point"
- end
- end
+ @stop_area_copy = StopAreaCopy.new(:hierarchy => params[:hierarchy], :source => parent)
new!
end
-# TODO
+
def create
@stop_area_copy = StopAreaCopy.new(params[:stop_area_copy])
+ @stop_area = parent
if @stop_area_copy.save
redirect_to referential_stop_area_path( @referential,parent ), notice: I18n.t("stop_area_copies.new.success")
else
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8e655c68d..a3808cfc1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -20,7 +20,47 @@ module ApplicationHelper
end
def help_path
- url_for(:controller => "/help", :action => "show") + '/'
+ path = request.env['PATH_INFO']
+ target = case
+ when path.include?("/help")
+ ""
+ when path.include?("/networks")
+ "networks"
+ when path.include?("/companies")
+ "companies"
+ when path.include?("/group_of_lines")
+ "group_of_lines"
+ when path.include?("/vehicle_journeys")
+ "vehicle_journeys"
+ when path.include?("/journey_patterns")
+ "journey_patterns"
+ when path.include?("/routes")
+ "routes"
+ when path.include?("/lines")
+ "lines"
+ when path.include?("/access_points")
+ "access_points"
+ when path.include?("/access_links")
+ "access_links"
+ when path.include?("/stop_areas")
+ "stop_areas"
+ when path.include?("/connection_links")
+ "connection_links"
+ when path.include?("/time_tables")
+ "time_tables"
+ when path.include?("/rule_parameter_set")
+ "parametersets"
+ when path.include?("/import_tasks")
+ "imports"
+ when path.include?("/exports")
+ "exports"
+ when path.include?("/compliance_check_tasks")
+ "validations"
+ else
+ ""
+ end
+
+ url_for(:controller => "/help", :action => "show") + '/' + target
end
diff --git a/app/helpers/remote_bootstrap_pagination_link_renderer.rb b/app/helpers/remote_bootstrap_pagination_link_renderer.rb
new file mode 100644
index 000000000..fe7f2d06b
--- /dev/null
+++ b/app/helpers/remote_bootstrap_pagination_link_renderer.rb
@@ -0,0 +1,8 @@
+# remote link for will paginate, using bootstrap as renderer
+class RemoteBootstrapPaginationLinkRenderer < BootstrapPagination::Rails
+ def link (text,target, attributes = {})
+ attributes["data-remote"] = true
+ super
+ end
+
+end
diff --git a/app/models/stop_area_copy.rb b/app/models/stop_area_copy.rb
index 2bd6447ab..39ae42c34 100644
--- a/app/models/stop_area_copy.rb
+++ b/app/models/stop_area_copy.rb
@@ -14,6 +14,22 @@ class StopAreaCopy
def initialize(attributes = {})
attributes.each { |name, value| send("#{name}=", value) } if attributes
+ if self.area_type.blank? && self.source != nil
+ self.source_id = self.source.id
+ if self.hierarchy == "child"
+ if self.source.area_type.underscore == "stop_place"
+ self.area_type="commercial_stop_point"
+ else
+ self.area_type="boarding_position"
+ end
+ else
+ if self.source.area_type.underscore == "stop_place" || self.source.area_type.underscore == "commercial_stop_point"
+ self.area_type="stop_place"
+ else
+ self.area_type="commercial_stop_point"
+ end
+ end
+ end
end
def persisted?
diff --git a/app/views/companies/_companies.erb b/app/views/companies/_companies.erb
index 29871b836..fb36a86af 100644
--- a/app/views/companies/_companies.erb
+++ b/app/views/companies/_companies.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@companies) %>
diff --git a/app/views/compliance_check_tasks/_compliance_check_task.erb b/app/views/compliance_check_tasks/_compliance_check_task.erb
deleted file mode 100644
index 081b04b46..000000000
--- a/app/views/compliance_check_tasks/_compliance_check_task.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<%= div_for(compliance_check_task, :class => "compliance_check_task clearfix") do %>
-
- <%= link_to image_tag("compliance_check_task-#{compliance_check_task.status}.png"), referential_compliance_check_task_path(@referential, compliance_check_task) %>
-
-
-
-
- <%= t("compliance_check_tasks.statuses.#{compliance_check_task.status}") %>
-
-
- <% if compliance_check_task.import_task.present? %>
-
<%= link_to( image_tag('icons/link_page.png') + t("compliance_check_tasks.import_task"), referential_import_task_path(@referential, compliance_check_task.import_task)) %>
- <% end %>
- <% if compliance_check_task.parameter_set %>
-
<%= link_to( image_tag('icons/link_page.png') + t("compliance_check_tasks.actions.rule_parameter_set"), rule_parameter_set_referential_compliance_check_task_path(@referential, compliance_check_task)) %>
- <% end %>
-
-
- <%= l compliance_check_task.created_at, :format => "%d/%m/%Y %H:%M" %> | <%= compliance_check_task.user_name %>
-
-
-<% end %>
diff --git a/app/views/compliance_check_tasks/_compliance_check_task.html.erb b/app/views/compliance_check_tasks/_compliance_check_task.html.erb
new file mode 100644
index 000000000..081b04b46
--- /dev/null
+++ b/app/views/compliance_check_tasks/_compliance_check_task.html.erb
@@ -0,0 +1,25 @@
+<%= div_for(compliance_check_task, :class => "compliance_check_task clearfix") do %>
+
+ <%= link_to image_tag("compliance_check_task-#{compliance_check_task.status}.png"), referential_compliance_check_task_path(@referential, compliance_check_task) %>
+
+
+
+
+ <%= t("compliance_check_tasks.statuses.#{compliance_check_task.status}") %>
+
+
+ <% if compliance_check_task.import_task.present? %>
+
<%= link_to( image_tag('icons/link_page.png') + t("compliance_check_tasks.import_task"), referential_import_task_path(@referential, compliance_check_task.import_task)) %>
+ <% end %>
+ <% if compliance_check_task.parameter_set %>
+
<%= link_to( image_tag('icons/link_page.png') + t("compliance_check_tasks.actions.rule_parameter_set"), rule_parameter_set_referential_compliance_check_task_path(@referential, compliance_check_task)) %>
+ <% end %>
+
+
+ <%= l compliance_check_task.created_at, :format => "%d/%m/%Y %H:%M" %> | <%= compliance_check_task.user_name %>
+
+
+<% end %>
diff --git a/app/views/compliance_check_tasks/_compliance_check_tasks.html.erb b/app/views/compliance_check_tasks/_compliance_check_tasks.html.erb
new file mode 100644
index 000000000..9cb805b90
--- /dev/null
+++ b/app/views/compliance_check_tasks/_compliance_check_tasks.html.erb
@@ -0,0 +1,9 @@
+
+ <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @compliance_check_tasks %>
+
+
+ <%= paginated_content @compliance_check_tasks %>
+
+
diff --git a/app/views/compliance_check_tasks/index.html.erb b/app/views/compliance_check_tasks/index.html.erb
index 8a659070c..fe05b3cdc 100644
--- a/app/views/compliance_check_tasks/index.html.erb
+++ b/app/views/compliance_check_tasks/index.html.erb
@@ -1,14 +1,7 @@
<%= title_tag t('.title') %>
<%= t('.warning') %>
-
- <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @compliance_check_tasks %>
-
-
- <%= paginated_content @compliance_check_tasks %>
-
-
+
+<%= render 'compliance_check_tasks' %>
<% content_for :sidebar do %>
diff --git a/app/views/compliance_check_tasks/index.js.erb b/app/views/compliance_check_tasks/index.js.erb
new file mode 100644
index 000000000..08ddf1dc5
--- /dev/null
+++ b/app/views/compliance_check_tasks/index.js.erb
@@ -0,0 +1 @@
+$('#compliance_check_tasks').html('<%= escape_javascript(render("compliance_check_tasks")) %>');
\ No newline at end of file
diff --git a/app/views/connection_links/_connection_links.erb b/app/views/connection_links/_connection_links.erb
index 1f4704596..cfc1d45f4 100644
--- a/app/views/connection_links/_connection_links.erb
+++ b/app/views/connection_links/_connection_links.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@connection_links) %>
diff --git a/app/views/exports/_exports.html.erb b/app/views/exports/_exports.html.erb
new file mode 100644
index 000000000..58d4d7e70
--- /dev/null
+++ b/app/views/exports/_exports.html.erb
@@ -0,0 +1,17 @@
+
+ <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @exports %>
+
+
+ <% @exports.each_slice(3) do |row_exports| %>
+
+ <% row_exports.each do |export| %>
+
+ <%= render :partial => "export", locals: { export: export } %>
+
+ <% end %>
+
+ <% end %>
+
+
diff --git a/app/views/exports/index.html.erb b/app/views/exports/index.html.erb
index 2f89b9458..35b19be62 100644
--- a/app/views/exports/index.html.erb
+++ b/app/views/exports/index.html.erb
@@ -1,22 +1,7 @@
<%= title_tag t('.title') %>
<%= t('.warning') %>
-
- <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @exports %>
-
-
- <% @exports.each_slice(3) do |row_exports| %>
-
- <% row_exports.each do |export| %>
-
- <%= render :partial => "export", locals: { export: export } %>
-
- <% end %>
-
- <% end %>
-
-
+<%= render 'exports' %>
+
<% content_for :sidebar do %>
diff --git a/app/views/exports/index.js.erb b/app/views/exports/index.js.erb
new file mode 100644
index 000000000..08ddf1dc5
--- /dev/null
+++ b/app/views/exports/index.js.erb
@@ -0,0 +1 @@
+$('#compliance_check_tasks').html('<%= escape_javascript(render("compliance_check_tasks")) %>');
\ No newline at end of file
diff --git a/app/views/group_of_lines/_group_of_lines.erb b/app/views/group_of_lines/_group_of_lines.erb
index 4d2d06159..212507d01 100644
--- a/app/views/group_of_lines/_group_of_lines.erb
+++ b/app/views/group_of_lines/_group_of_lines.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@group_of_lines) %>
diff --git a/app/views/import_tasks/_import_tasks.html.erb b/app/views/import_tasks/_import_tasks.html.erb
new file mode 100644
index 000000000..6e3825817
--- /dev/null
+++ b/app/views/import_tasks/_import_tasks.html.erb
@@ -0,0 +1,9 @@
+
+ <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @import_tasks %>
+
+
+ <%= paginated_content @import_tasks %>
+
+
diff --git a/app/views/import_tasks/index.html.erb b/app/views/import_tasks/index.html.erb
index f19c84929..ce0149f72 100644
--- a/app/views/import_tasks/index.html.erb
+++ b/app/views/import_tasks/index.html.erb
@@ -1,14 +1,8 @@
<%= title_tag t('.title') %>
<%= t('.warning') %>
-
- <%= t("will_paginate.page_entries_info.search") %> <%= page_entries_info @import_tasks %>
-
-
- <%= paginated_content @import_tasks %>
-
-
+
+<%= render 'import_tasks' %>
+
<% content_for :sidebar do %>
diff --git a/app/views/import_tasks/index.js.erb b/app/views/import_tasks/index.js.erb
new file mode 100644
index 000000000..79679f8ac
--- /dev/null
+++ b/app/views/import_tasks/index.js.erb
@@ -0,0 +1 @@
+$('#import_tasks').html('<%= escape_javascript(render("import_tasks")) %>');
\ No newline at end of file
diff --git a/app/views/lines/_lines.html.erb b/app/views/lines/_lines.html.erb
index 3bb3cd37f..a4d9a3f0b 100644
--- a/app/views/lines/_lines.html.erb
+++ b/app/views/lines/_lines.html.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@lines) %>
diff --git a/app/views/networks/_networks.erb b/app/views/networks/_networks.erb
index e395d4ebb..9d95d63b6 100644
--- a/app/views/networks/_networks.erb
+++ b/app/views/networks/_networks.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@networks) %>
diff --git a/app/views/shared/_header.erb b/app/views/shared/_header.erb
index dc096f80b..53975556b 100644
--- a/app/views/shared/_header.erb
+++ b/app/views/shared/_header.erb
@@ -82,7 +82,7 @@
- <%= link_to_language :en %>
- - <%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "_blank" %>
+ - <%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "chouette_help" %>
<% if user_signed_in? %>
-
<%= user_gravatar_image_tag(current_user, 16) %><%= current_user.name %>
diff --git a/app/views/stop_area_copies/new.html.erb b/app/views/stop_area_copies/new.html.erb
index 28c201d2f..5edc005cc 100644
--- a/app/views/stop_area_copies/new.html.erb
+++ b/app/views/stop_area_copies/new.html.erb
@@ -3,8 +3,8 @@
<%= semantic_form_for [@referential, @stop_area, @stop_area_copy] do |form| %>
<%= form.inputs do %>
- <%= form.input :source_id , :as => :hidden%>
- <%= form.input :hierarchy , :as => :hidden%>
+ <%= form.input :source_id, :as => :hidden %>
+ <%= form.input :hierarchy, :as => :hidden %>
<% if @stop_area_copy.hierarchy == "child"%>
<% if @stop_area.area_type.underscore == "stop_place"%>
<%= form.input :area_type, :as => :select, :collection => ["stop_place","commercial_stop_point"], :include_blank => false, :member_label => Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } %>
@@ -12,8 +12,7 @@
<%= form.input :area_type, :as => :select, :collection => ["boarding_position","quay"], :include_blank => false, :member_label => Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } %>
<% end %>
<% else %>
- <%= form.input :area_type, :as => :select, :input_html => { :disabled => true }, :collection => [@stop_area_copy.area_type], :include_blank => false, :member_label => Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } %>
- <%= form.input :area_type , :as => :hidden%>
+ <%= form.input :area_type, :as => :select, :collection => [@stop_area_copy.area_type], :include_blank => false, :member_label => Proc.new { |stop_area_type| t("area_types.label.#{stop_area_type}") } %>
<% end %>
<% end %>
<%= form.actions do %>
diff --git a/app/views/stop_areas/_stop_areas.html.erb b/app/views/stop_areas/_stop_areas.html.erb
index 38423aedf..9c7a82d6d 100644
--- a/app/views/stop_areas/_stop_areas.html.erb
+++ b/app/views/stop_areas/_stop_areas.html.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@stop_areas) %>
diff --git a/app/views/time_tables/_time_tables.html.erb b/app/views/time_tables/_time_tables.html.erb
index 72fbd9384..4458f653d 100644
--- a/app/views/time_tables/_time_tables.html.erb
+++ b/app/views/time_tables/_time_tables.html.erb
@@ -5,5 +5,5 @@
<%= paginated_content(@time_tables) %>
--
cgit v1.2.3