aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2017-06-05 17:56:39 +0200
committerjpl2017-06-05 17:56:48 +0200
commit6e6a2158f88e0a4e8973cb8e098e92b444aecf77 (patch)
tree1200de4eeaa68ff7c1e7d1f949a9afa4c805dc00
parentf422c130f9bda3c425cc3e1b9604345ca3586fe1 (diff)
downloadchouette-core-6e6a2158f88e0a4e8973cb8e098e92b444aecf77.tar.bz2
Refs #3486: updating ITL#index layout
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb46
-rw-r--r--app/views/referential_lines/index.js.slim1
-rw-r--r--app/views/referential_lines/show.html.slim5
-rw-r--r--app/views/routing_constraint_zones/_filters.html.slim16
-rw-r--r--app/views/routing_constraint_zones/index.html.slim37
-rw-r--r--config/locales/routing_constraint_zones.en.yml4
-rw-r--r--config/locales/routing_constraint_zones.fr.yml7
7 files changed, 96 insertions, 20 deletions
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index f2f74e801..b5072f401 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -1,6 +1,7 @@
class RoutingConstraintZonesController < ChouetteController
- defaults resource_class: Chouette::RoutingConstraintZone
+ include PolicyChecker
+ defaults resource_class: Chouette::RoutingConstraintZone
respond_to :html, :xml, :json
before_action :remove_empty_stop_point, only: [:create, :update]
@@ -9,11 +10,50 @@ class RoutingConstraintZonesController < ChouetteController
belongs_to :line, parent_class: Chouette::Line
end
- include PolicyChecker
+ def index
+ @routing_constraint_zones = collection
+ end
+
+ def show
+ @routing_constraint_zone = collection.find(params[:id])
+ end
+
+ protected
+
+ def collection
+ @q = resource.routing_constraint_zones.search(params[:q])
+
+ if sort_column && sort_direction
+ @routing_constraint_zones ||= @q.result(distinct: true).order(sort_column + ' ' + sort_direction)
+ else
+ @routing_constraint_zones ||= @q.result(distinct: true).order(:name)
+ end
+ @routing_constraint_zones = @routing_constraint_zones.paginate(page: params[:page], per_page: 10)
+ end
private
+ def sort_column
+ (Chouette::RoutingConstraintZone.column_names).include?(params[:sort]) ? params[:sort] : 'name'
+ end
+ def sort_direction
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc'
+ end
+
+ def resource
+ @referential = Referential.find params[:referential_id]
+ @line = @referential.lines.find params[:line_id]
+ end
+
def routing_constraint_zone_params
- params.require(:routing_constraint_zone).permit(:name, { stop_point_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id)
+ params.require(:routing_constraint_zone).permit(
+ :name,
+ { stop_point_ids: [] },
+ :line_id,
+ :route_id,
+ :objectid,
+ :object_version,
+ :creator_id
+ )
end
def remove_empty_stop_point
diff --git a/app/views/referential_lines/index.js.slim b/app/views/referential_lines/index.js.slim
deleted file mode 100644
index 0165fb077..000000000
--- a/app/views/referential_lines/index.js.slim
+++ /dev/null
@@ -1 +0,0 @@
-| $('#lines').html("#{escape_javascript(render('lines'))}"); \ No newline at end of file
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 1e24f0f15..43a70dfb5 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -7,11 +7,8 @@
/ Below is secundary actions & optional contents
.row
.col-lg-12.text-right.mb-sm
- / = link_to t('lines.actions.show_network'), [@referential, @line.network], class: 'btn btn-primary'
- / = link_to t('lines.actions.show_company'), [@referential, @line.company], class: 'btn btn-primary'
-
= link_to @line.human_attribute_name(:footnotes), referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary'
- = link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary disabled'
+ = link_to t('routing_constraint_zones.index.title'), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary'
- if policy(Chouette::Line).create? && @referential.organisation == current_organisation
= link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary'
diff --git a/app/views/routing_constraint_zones/_filters.html.slim b/app/views/routing_constraint_zones/_filters.html.slim
new file mode 100644
index 000000000..18ef40d61
--- /dev/null
+++ b/app/views/routing_constraint_zones/_filters.html.slim
@@ -0,0 +1,16 @@
+= search_form_for @q, url: referential_line_routing_constraint_zones_path(@referential, @line), class: 'form form-filter' do |f|
+ .ffg-row
+ .input-group.search_bar
+ = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'ITL ou un OiD..."
+ span.input-group-btn
+ button.btn.btn-default#search-btn type='submit'
+ span.fa.fa-search
+
+ .ffg-row
+ .form-group
+ = f.label 'Itinéraire associé', required: false, class: 'control-label'
+ = f.input :route_id, as: :select, collection: @line.routing_constraint_zones.pluck(:route_id), label: false, label_method: lambda {|r| @line.routing_constraint_zones.find_by(route_id: r).route_name}, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Indiquez un itinéraire...' }, wrapper_html: { class: 'select2ed'}
+
+ .actions
+ = link_to 'Effacer', referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-link'
+ = f.submit 'Filtrer', class: 'btn btn-default'
diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim
index 620b0f7db..83d4b47c3 100644
--- a/app/views/routing_constraint_zones/index.html.slim
+++ b/app/views/routing_constraint_zones/index.html.slim
@@ -1,11 +1,30 @@
-= title_tag Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr)
+/ PageHeader
+= pageheader 'map-marker',
+ t('routing_constraint_zones.index.title'),
+ '',
+ '',
+ ((policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation) ? link_to(t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line), class: 'btn btn-primary') : '')
-- if policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation
- = link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line)
+/ PageContent
+.page_content
+ .container-fluid
+ - if params[:q].present? or @routing_constraint_zones.any?
+ .row
+ .col-lg-12
+ = render 'filters'
-- if @routing_constraint_zones.any?
- = table_builder @routing_constraint_zones,
- { objectid: 'objectid', name: 'name', route: 'route_name', stop_points_count: 'stop_points_count' },
- [:show, :edit, :delete],
- [],
- 'table table-bordered'
+ - if @routing_constraint_zones.any?
+ .row
+ .col-lg-12
+ = table_builder @routing_constraint_zones,
+ { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) },
+ :name => 'name', :stop_points_count => 'stop_points_count',
+ :route => 'route_name' },
+ [:show, :edit, :delete],
+ [],
+ 'table has-filter has-search'
+
+ - unless @routing_constraint_zones.any?
+ .row.mt-xs
+ .col-lg-12
+ = replacement_msg t('routing_constraint_zones.search_no_results')
diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml
index 2d4412dba..e72e79148 100644
--- a/config/locales/routing_constraint_zones.en.yml
+++ b/config/locales/routing_constraint_zones.en.yml
@@ -21,6 +21,7 @@ en:
stop_points_not_from_route: 'Stop point does not belong to the Route of this Routing constraint zone.'
all_stop_points_selected: 'All stop points from route cannot be selected.'
routing_constraint_zones:
+ search_no_results: "No ITL matches your query"
actions:
new: New routing constraint zone
edit: Edit this routing constraint zone
@@ -32,4 +33,5 @@ en:
title: "Update routing constraint zone %{routing_constraint_zone}"
show:
title: "Routing constraint zone %{routing_constraint_zone}"
-
+ index:
+ title: "Interdictions of local trafficous"
diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml
index 36dcf9301..c793fe678 100644
--- a/config/locales/routing_constraint_zones.fr.yml
+++ b/config/locales/routing_constraint_zones.fr.yml
@@ -21,14 +21,17 @@ fr:
stop_points_not_from_route: "Arrêt sur séquence d'arrêts n'appartient pas à la Route de cette Zone de contrainte."
all_stop_points_selected: "Une zone de contrainte ne peut pas couvrir tous les arrêts d'une ligne."
routing_constraint_zones:
+ search_no_results: "Aucune ITL ne correspond à votre recherche"
actions:
- new: Ajouter une zone de contrainte
+ new: Ajouter un ITL
edit: Editer cette zone de contrainte
destroy: Supprimer cette zone de contrainte
destroy_confirm: Etes vous sûr de supprimer cette zone de contrainte ?
new:
- title: Ajouter une zone de contrainte
+ title: Ajouter un ITL
edit:
title: "Editer la zone de contrainte %{routing_constraint_zone}"
show:
title: "Zone de contrainte %{routing_constraint_zone}"
+ index:
+ title: "Interdictions de traffic local"