aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2017-02-13 15:32:06 +0100
committerjpl2017-02-13 15:32:06 +0100
commit55468b29bb5b23bfeb8ebe439ed62e5214284a3d (patch)
treef6877faad540ee98fcbd726ec7592367fb00a93c
parent1091a971433fd706941585ac011ee72e6cd2bb73 (diff)
downloadchouette-core-55468b29bb5b23bfeb8ebe439ed62e5214284a3d.tar.bz2
Refs #2597: updatings line_referentials#show, according to new AD
-rw-r--r--app/assets/stylesheets/components/_alerts.sass5
-rw-r--r--app/assets/stylesheets/components/_page_header.sass2
-rw-r--r--app/controllers/referential_lines_controller.rb7
-rw-r--r--app/views/referential_lines/_reflines_routes.html.slim36
-rw-r--r--app/views/referential_lines/show.html.slim217
-rw-r--r--config/locales/lines.en.yml2
-rw-r--r--config/locales/lines.fr.yml2
-rw-r--r--config/locales/routes.en.yml1
-rw-r--r--config/locales/routes.fr.yml1
-rw-r--r--config/locales/will_paginate.en.yml5
-rw-r--r--config/locales/will_paginate.fr.yml3
-rw-r--r--spec/features/routes_spec.rb8
12 files changed, 101 insertions, 188 deletions
diff --git a/app/assets/stylesheets/components/_alerts.sass b/app/assets/stylesheets/components/_alerts.sass
index ecca87197..f05a4f39f 100644
--- a/app/assets/stylesheets/components/_alerts.sass
+++ b/app/assets/stylesheets/components/_alerts.sass
@@ -4,10 +4,13 @@
.alert
margin: 0
- padding: 10px 50px
+ // padding: 10px 50px
border-radius: 0
border: none
+ #main_nav + &
+ padding: 10px 50px
+
.fa + span
margin-left: 10px
diff --git a/app/assets/stylesheets/components/_page_header.sass b/app/assets/stylesheets/components/_page_header.sass
index 9329b2171..33fc1ed7c 100644
--- a/app/assets/stylesheets/components/_page_header.sass
+++ b/app/assets/stylesheets/components/_page_header.sass
@@ -49,6 +49,8 @@
.pm-col
display: inline-block
+ vertical-align: top
+ min-width: 150px
+ .pm-col
margin-left: 15px
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb
index c0d71d891..a91ad4b6b 100644
--- a/app/controllers/referential_lines_controller.rb
+++ b/app/controllers/referential_lines_controller.rb
@@ -24,7 +24,7 @@ class ReferentialLinesController < ChouetteController
def show
@map = LineMap.new(resource).with_helpers(self)
- @routes = @line.routes.order(:name)
+ @routes = @line.routes.order(:name).paginate(page: params[:page], per_page: 10)
@group_of_lines = @line.group_of_lines
show! do
build_breadcrumb :show
@@ -79,10 +79,11 @@ class ReferentialLinesController < ChouetteController
@q = referential.lines.search(params[:q])
if sort_column && sort_direction
- @lines ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction).paginate(:page => params[:page]).includes([:network, :company])
+ @lines ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction)
else
- @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company])
+ @lines ||= @q.result(:distinct => true).order(:number)
end
+ @lines = @lines.paginate(page: params[:page], per_page: 10).includes([:network, :company])
end
diff --git a/app/views/referential_lines/_reflines_routes.html.slim b/app/views/referential_lines/_reflines_routes.html.slim
deleted file mode 100644
index 8dcae73b5..000000000
--- a/app/views/referential_lines/_reflines_routes.html.slim
+++ /dev/null
@@ -1,36 +0,0 @@
-- if @routes.any?
- h3 = "Itinéraires"
-
- table.table.table-bordered.table-hover
- thead
- tr
- th.text-center = @routes.human_attribute_name(:name)
- th.text-center = @routes.human_attribute_name(:published_name)
- th.text-center = @routes.human_attribute_name(:wayback)
- th.text-center = @routes.human_attribute_name(:opposite_route)
- th.text-center = "Actions"
-
- tbody
- - @routes.each do |route|
- tr
- td = truncate(route.name, length: 20)
- td = route.published_name
- td = route.wayback_text
- td
- - if route.opposite_route
- = route.opposite_route.name
- - else
- = "Aucune séquence d'arrêts associée en sens opposé"
-
- td.text-center
- .btn.btn-group.btn-group-sm
- = link_to [@referential, @line, route], class: 'btn btn-default preview', title: "#{Chouette::Route.model_name.human.capitalize} #{route.name}" do
- span.fa.fa-eye
-
- - if policy(route).edit?
- = link_to edit_referential_line_route_path(@referential, @line, route), class: 'btn btn-default' do
- span.fa.fa-pencil
-
- - if policy(route).destroy?
- = link_to referential_line_route_path(@referential, @line, route), method: :delete, :data => {:confirm => t('routes.actions.destroy_confirm')}, class: 'btn btn-danger' do
- span.fa.fa-trash-o
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index dcd1e587c..9eed5345e 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -1,145 +1,80 @@
-- text_color = @line.text_color.blank? ? "black" : "##{@line.text_color}"
-- bg_color = @line.color.blank? ? "white" : "##{@line.color}"
-
-h2
- = t('lines.show.title', line: @line.name)
- - if @line.deactivated?
- small = " (désactivé)"
-
-.line_show
- = @map.to_html
-
- .summary
- - text_color = @line.text_color.blank? ? "black" : "##{@line.text_color}"
- - bg_color = @line.color.blank? ? "white" : "##{@line.color}"
-
- - if colors?(@line)
- p
- label = "#{t('lines.index.color')} : "
- label.color style="#{number_style(@line)}"
- = " #{line_sticker(@line)}"
-
- p
- label = "#{@line.human_attribute_name(:network)} : "
- - if @line.network.nil?
- = " #{t('lines.index.unset')}"
- - else
- = link_to " #{@line.network.name}", [@referential, @line.network]
-
- p
- label = "#{@line.human_attribute_name(:company)} : "
- - if @line.company.nil?
- = " #{t('lines.index.unset')}"
- - else
- = link_to " #{@line.company.name}", [@referential, @line.company]
-
- p
- label = "#{@line.human_attribute_name('number')} : "
- = " #{@line.number}"
-
- p
- label = "#{@line.human_attribute_name('published_name')} : "
- = " #{@line.published_name}"
-
- p
- label = "#{@line.human_attribute_name('registration_number')} : "
- = " #{@line.registration_number}"
-
- p
- label = "#{@line.human_attribute_name('transport_mode')} : "
- - if @line.transport_mode
- = " " + t("enumerize.line.transport_mode.#{@line.transport_mode}")
- - else
- = " -"
-
- p
- label = "#{@line.human_attribute_name('transport_submode')} : "
- - if @line.transport_submode
- = " " + t("enumerize.line.transport_submode.#{@line.transport_submode}")
- - else
- = " -"
-
- / p
- / label = "#{@line.human_attribute_name('stable_id')} : "
- / = " #{@line.stable_id}"
-
- p
- label = "#{@line.human_attribute_name('url')} : "
- = " #{@line.url}"
-
- / p
- / label = "#{@line.human_attribute_name('mobility_restricted_suitability')} : "
- /
- / - if @line.mobility_restricted_suitability.nil?
- / = @line.human_attribute_name("unspecified_mrs")
- / - elsif @line.mobility_restricted_suitability?
- / = @line.human_attribute_name("accessible")
- / - else
- / = @line.human_attribute_name("not_accessible")
- /
- / br
- / = "#{@line.human_attribute_name('number_of_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', true).count}"
- / br
- / = "#{@line.human_attribute_name('number_of_non_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', false).count}"
- / br
- / = "#{@line.human_attribute_name('number_of_null_mrs_vj')} : "
- / = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("mobility_restricted_suitability = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count)
- /
- / p
- / label = "#{@line.human_attribute_name('flexible_service')} : "
- /
- / - if @line.flexible_service.nil?
- / = @line.human_attribute_name("unspecified_fs")
- / - elsif @line.flexible_service?
- / = @line.human_attribute_name("on_demaond_fs")
- / - else
- / = @line.human_attribute_name("regular_fs")
- /
- / br
- / = "#{@line.human_attribute_name('number_of_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', true).count}"
- / br
- / = "#{@line.human_attribute_name('number_of_non_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', false).count}"
- / br
- / = @line.human_attribute_name("number_of_null_fs_vj")
- /
- / - if @line.flexible_service.nil?
- / = "(#{@line.human_attribute_name('default_fs_msg')})"
- /
- / = ": #{@line.vehicle_journeys.count - (@line.vehicle_journeys.where('flexible_service = ?', true).count + @line.vehicle_journeys.where('flexible_service = ?', false).count)}"
- /
- p
- label = link_to @line.human_attribute_name('footnotes'), referential_line_footnotes_path(@referential, @line)
- / p
- / label = "#{@line.human_attribute_name('comment')} : "
- / = @line.comment
- p
- label = link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line)
+/ PageHeader
+= pageheader 'map-marker',
+ @line.name,
+ 'Lorem ipsum dolor sit amet' do
+ / t('last_update', time: l(@line.updated_at, format: :short)),
+ / Below is secundary actions & optional contents (filters, ...)
.row
- #mobility_restricted_suitability.col-md-6
- #flexible_service.col-md-6
-
-p.after_map
+ .col-lg-12
+ .page_metalist
+ .pm-col
+ .pm-item
+ span.label.label-default
+ = @line.deactivated? ? 'Désactivée' : 'Activée'
+
+ .pm-item
+ strong = "#{@line.human_attribute_name(:network)} : "
+ = @line.network.nil? ? t('lines.index.unset') : @line.network.name
+
+ .pm-item
+ strong = "#{@line.human_attribute_name(:company)} : "
+ = @line.company.nil? ? t('lines.index.unset') : @line.company.name
+
+ .pm-col
+ .pm-item
+ strong = "#{@line.human_attribute_name(:number)} : "
+ = @line.number
+ .pm-item
+ strong = "#{@line.human_attribute_name(:published_name)} : "
+ = @line.published_name
+ .pm-item
+ strong = "#{@line.human_attribute_name(:registration_number)} : "
+ = @line.registration_number
+ .pm-col
+ .pm-item
+ strong = "#{@line.human_attribute_name(:transport_mode)} : "
+ = t("enumerize.line.transport_mode.#{@line.transport_mode}") if @line.transport_mode
+ .pm-item
+ strong = "#{@line.human_attribute_name(:transport_submode)} : "
+ = t("enumerize.line.transport_submode.#{@line.transport_submode}") if @line.transport_submode
+ .pm-item
+ strong = "#{@line.human_attribute_name(:url)} : "
+ = @line.try(:url)
-.routes
- = render 'reflines_routes'
-
-- content_for :sidebar do
- ul.actions
- - if policy(Chouette::Line).create? && @referential.organisation == current_organisation
- li
- = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'add'
- - if policy(@line).update?
- li
- = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'edit'
- - if policy(@line).destroy?
- li
- = link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), method: :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, class: 'remove'
-
- - if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2)
- / FIXME #825
- li
+ .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'
+
+ - if policy(Chouette::Line).create? && @referential.organisation == current_organisation
+ = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary'
+ - if policy(@line).update?
+ = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'btn btn-primary'
+ - if policy(@line).destroy?
+ = link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), method: :delete, data: {confirm: t('lines.actions.destroy_confirm')}, class: 'btn btn-primary'
+ - if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2)
- if policy(Chouette::Route).create? && @referential.organisation == current_organisation
- = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'add'
-
- = creation_tag(@line)
+ = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'btn btn-primary'
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-12
+ - if @routes.any?
+ = new_pagination @routes, 'pull-right'
+
+ = table_builder @routes,
+ { @routes.human_attribute_name(:name) => 'name', @routes.human_attribute_name(:published_name) => 'published_name', @routes.human_attribute_name(:wayback) => Proc.new{|r| r.try(:wayback_text)}, @routes.human_attribute_name(:opposite_route) => Proc.new{|r| r.try(:opposite_route).try(:name)} },
+ [:show, :edit, :delete],
+ [],
+ 'table'
+
+ = new_pagination @routes, 'pull-right'
+
+ - else
+ = replacement_msg t('routes.search_no_results')
diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml
index 748064c3d..899aa3761 100644
--- a/config/locales/lines.en.yml
+++ b/config/locales/lines.en.yml
@@ -13,6 +13,8 @@ en:
export_kml_all: "Export KML lines"
export_hub: "Export HUB line"
export_hub_all: "Export HUB lines"
+ show_network: 'Show network'
+ show_company: 'Show company'
new:
title: "Add a new line"
edit:
diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml
index f59d0afea..f4898758a 100644
--- a/config/locales/lines.fr.yml
+++ b/config/locales/lines.fr.yml
@@ -13,6 +13,8 @@ fr:
export_kml_all: "Export KML des lignes"
export_hub: "Export HUB de la ligne"
export_hub_all: "Export HUB des lignes"
+ show_network: 'Voir le réseau'
+ show_company: 'Voir le transporteur principal'
new:
title: "Ajouter une ligne"
edit:
diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml
index d2502ef6c..1aaa45ff5 100644
--- a/config/locales/routes.en.yml
+++ b/config/locales/routes.en.yml
@@ -1,5 +1,6 @@
en:
routes:
+ search_no_results: "No route matching your query"
actions:
new: "Add a new route"
edit: "Edit this route"
diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml
index 183531236..ce2562583 100644
--- a/config/locales/routes.fr.yml
+++ b/config/locales/routes.fr.yml
@@ -1,5 +1,6 @@
fr:
routes:
+ search_no_results: "Aucun itinéraire ne correspond à votre recherche"
actions:
new: "Ajouter un itinéraire"
edit: "Modifier cet itinéraire"
diff --git a/config/locales/will_paginate.en.yml b/config/locales/will_paginate.en.yml
index 0e189ebae..f47c63986 100644
--- a/config/locales/will_paginate.en.yml
+++ b/config/locales/will_paginate.en.yml
@@ -19,5 +19,6 @@ en:
multi_page: "%{model} %{from} to %{to} of %{count}"
multi_page_html: "%{model} %{from} to %{to} of %{count}"
- referential: 'data spaces'
- line: 'lines'
+ referential: 'data space'
+ line: 'line'
+ route: 'route'
diff --git a/config/locales/will_paginate.fr.yml b/config/locales/will_paginate.fr.yml
index 38998e7f5..b23f5da7c 100644
--- a/config/locales/will_paginate.fr.yml
+++ b/config/locales/will_paginate.fr.yml
@@ -20,4 +20,5 @@ fr:
multi_page_html: "Liste des %{model} %{from}&nbsp;à&nbsp;%{to} sur %{count}"
referential: 'jeu(x) de données'
- line: 'ligne(s)'
+ line: 'ligne'
+ route: 'itinéraire'
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 0e398feb3..af0a4520a 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -94,7 +94,7 @@ describe "Routes", :type => :feature do
context 'user has permission to edit routes' do
it 'shows edit buttons for routes' do
- expect(page).to have_css('span.fa.fa-pencil')
+ expect(page).to have_content(I18n.t('actions.edit'))
end
end
@@ -102,7 +102,7 @@ describe "Routes", :type => :feature do
it 'does not show edit buttons for routes' do
@user.update_attribute(:permissions, [])
visit referential_line_path(referential, line)
- expect(page).not_to have_css('span.fa.fa-pencil')
+ expect(page).not_to have_content(I18n.t('actions.edit'))
end
end
@@ -128,7 +128,7 @@ describe "Routes", :type => :feature do
context 'user has permission to destroy routes' do
it 'shows destroy buttons for routes' do
- expect(page).to have_css('span.fa.fa-trash-o')
+ expect(page).to have_content(I18n.t('actions.edit'))
end
end
@@ -136,7 +136,7 @@ describe "Routes", :type => :feature do
it 'does not show destroy buttons for routes' do
@user.update_attribute(:permissions, [])
visit referential_line_path(referential, line)
- expect(page).not_to have_css('span.fa.fa-trash-o')
+ expect(page).not_to have_content(I18n.t('actions.destroy'))
end
end
end