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}") %> -
- -
- <%= 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}") %> +
+ +
+ <%= 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 %>