From 08aa082e941db7e23d91edb8e48bead2b72e9fe3 Mon Sep 17 00:00:00 2001
From: Zog
Date: Fri, 4 May 2018 16:39:51 +0200
Subject: Refs #6923; Implement a consolidated view
---
app/assets/stylesheets/components/_forms.sass | 8 +-
app/assets/stylesheets/modules/_vj_collection.sass | 61 +++++++++-
.../referential_vehicle_journeys_controller.rb | 4 +-
app/helpers/vehicle_journeys_helper.rb | 12 ++
app/models/chouette/route.rb | 3 +
app/services/referential_consolidated.rb | 124 +++++++++++++++++++++
.../_consolidated.html.slim | 21 ++++
.../_consolidated_line.html.slim | 118 ++++++++++++++++++++
.../_filters.html.slim | 13 ++-
.../referential_vehicle_journeys/_list.html.slim | 49 ++++++++
.../referential_vehicle_journeys/index.html.slim | 52 +--------
11 files changed, 410 insertions(+), 55 deletions(-)
create mode 100644 app/services/referential_consolidated.rb
create mode 100644 app/views/referential_vehicle_journeys/_consolidated.html.slim
create mode 100644 app/views/referential_vehicle_journeys/_consolidated_line.html.slim
create mode 100644 app/views/referential_vehicle_journeys/_list.html.slim
diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass
index b13c5fc23..e7aa31fab 100644
--- a/app/assets/stylesheets/components/_forms.sass
+++ b/app/assets/stylesheets/components/_forms.sass
@@ -507,10 +507,10 @@ table, .table
right: 15px
top: 50%
padding: 0
- margin-top: -13px
z-index: 1
+ transform: translateY(-50%)
- .btn
+ *:not(.btn-group) > .btn
color: $blue
font-weight: 700
background-color: transparent
@@ -718,6 +718,10 @@ table, .table
> .form-group:last-child
border-right: none
+ @for $i from 1 through 99
+ &.w#{$i}
+ display: inline-block
+
// Form group date
.form-group.date
.form-inline
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index 3ff0828ea..3a252bfc0 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -2,7 +2,7 @@
// VJ Collection //
//-----------------//
-#vehicle_journeys_wip
+#vehicle_journeys_wip, .consolidated-view
.table-2entries
.t2e-head
> .td
@@ -218,3 +218,62 @@
// Reset default behaviour
.form-control
border-color: #ccc
+
+
+.consolidated-view
+ $highlighted: #d4ba32
+ .line
+ & > .head
+ font-size: 2em
+ text-transform: capitalize
+ border-top: 3px solid black
+ border-bottom: 3px solid black
+ padding-left: 10px
+ margin-top: 10px
+ .routes
+ .route
+ background: #F9F9F9
+ & > .head
+ padding: 15px
+ &.highlighted
+ .pull-right, span.fa
+ color: $highlighted !important
+ a
+ color: black
+ font-size: 1.2em
+ text-transform: capitalize
+ .fa
+ color: $red
+ transition: transform 0.1s
+ &.active .fa
+ transform: rotate(180deg)
+ .pull-right
+ font-size: 0.9em
+ text-transform: lowercase
+ .vehicle-journeys
+ margin-bottom: 40px
+
+ .highlighted
+ background-color: lighten($highlighted, 20%) !important
+ .disabled
+ background-color: #ccc
+ color: #777
+ .t2e-item-list .t2e-item
+ .th
+ max-width: 100px
+ & > div
+ text-overflow: ellipsis
+ overflow: hidden
+ white-space: nowrap
+ .td
+ text-align: center
+
+
+ .table-2entries > .t2e-head > .td > div > span::after
+ bottom: -6px !important
+
+ .table.table-2entries .t2e-item-list .t2e-item
+ background-color: #F9F9F9
+
+ .table.table-2entries .td > div.headlined::before
+ border-right-color: #F9F9F9
diff --git a/app/controllers/referential_vehicle_journeys_controller.rb b/app/controllers/referential_vehicle_journeys_controller.rb
index 14f7909b9..111d39c2b 100644
--- a/app/controllers/referential_vehicle_journeys_controller.rb
+++ b/app/controllers/referential_vehicle_journeys_controller.rb
@@ -42,9 +42,9 @@ class ReferentialVehicleJourneysController < ChouetteController
@q = @q.ransack(params[:q])
@vehicle_journeys ||= @q.result
@vehicle_journeys = parse_order @vehicle_journeys
- @vehicle_journeys = @vehicle_journeys.paginate page: params[:page], per_page: params[:per_page] || 10
@all_companies = Chouette::Company.where("id IN (#{@referential.vehicle_journeys.select(:company_id).to_sql})").distinct
-
+ @consolidated = ReferentialConsolidated.new @vehicle_journeys, params
+ @vehicle_journeys = @vehicle_journeys.paginate page: params[:page], per_page: params[:per_page] || 10
end
def parse_order scope
diff --git a/app/helpers/vehicle_journeys_helper.rb b/app/helpers/vehicle_journeys_helper.rb
index 1cc865c62..4d7eb7002 100644
--- a/app/helpers/vehicle_journeys_helper.rb
+++ b/app/helpers/vehicle_journeys_helper.rb
@@ -69,4 +69,16 @@ module VehicleJourneysHelper
)
end
+ def vehicle_journey_stop_headline prev_sp, sp
+ if has_feature?(:long_distance_routes)
+ headline = prev_sp && prev_sp.stop_area.country_code
+ headline = sp.stop_area.country_code != headline
+ headline && sp.stop_area.country_name
+ else
+ headline = prev_sp && prev_sp.stop_area.city_name
+ headline = sp.stop_area.city_name != headline
+ headline && sp.stop_area.city_name
+ end
+ end
+
end
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index 7a8d043e0..949b18d6f 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -72,6 +72,9 @@ module Chouette
end
end
+ has_many :time_tables, :through => :vehicle_journeys
+ has_many :purchase_windows, :through => :vehicle_journeys
+
accepts_nested_attributes_for :stop_points, :allow_destroy => :true
validates_presence_of :name
diff --git a/app/services/referential_consolidated.rb b/app/services/referential_consolidated.rb
new file mode 100644
index 000000000..abfb7532b
--- /dev/null
+++ b/app/services/referential_consolidated.rb
@@ -0,0 +1,124 @@
+class ReferentialConsolidated
+ attr_reader :params
+
+ def initialize vehicle_journeys, params
+ @vehicle_journeys = vehicle_journeys
+ @params = params
+ end
+
+ def paginated_lines
+ @paginated_lines ||= begin
+ line_ids = @vehicle_journeys.joins(route: :line).pluck('lines.id')
+ lines = Chouette::Line.where(id: line_ids).order(:name)
+ lines.paginate page: params[:page], per_page: params[:per_page] || 10
+ end
+ end
+
+ def lines
+ @lines ||= paginated_lines.to_a.map {|l| Line.new(self, l, @vehicle_journeys, params) }
+ end
+
+ def _should_highlight?
+ return false unless params[:q].present?
+ keys = params[:q].keys - ["stop_areas"]
+ params[:q].values_at(*keys).each do |value|
+ if value.is_a?(Hash)
+ return true if value.values.any?(&:present?)
+ elsif value.is_a?(Array)
+ return true if value.any?(&:present?)
+ else
+ if value.present?
+ return true
+ end
+ end
+ end
+ false
+ end
+
+ def should_highlight?
+ if @should_highlight.nil?
+ @should_highlight = _should_highlight?
+ end
+ @should_highlight
+ end
+
+ class Base
+ extend Forwardable
+ attr_reader :params
+ attr_reader :parent
+ attr_reader :ar_model
+
+ def initialize parent, ar_model, vehicle_journeys, params
+ @parent = parent
+ @ar_model = ar_model
+ @all_vehicle_journeys = vehicle_journeys
+ @params = params
+ end
+
+ def should_highlight?
+ parent.should_highlight?
+ end
+ end
+
+ class Line < Base
+ delegate name: :ar_model
+ delegate id: :ar_model
+
+ def routes
+ @routes ||= begin
+ ar_model.routes.order(:name).map {|r| Route.new(self, r, @all_vehicle_journeys, params) }
+ end
+ end
+ end
+
+ class Route < Base
+ def_delegators :ar_model, :name, :id, :time_tables, :purchase_windows, :stop_area_ids
+
+ def vehicle_journeys
+ @vehicle_journeys ||= begin
+ ar_model.vehicle_journeys.map {|vj| VehicleJourney.new(self, vj, @all_vehicle_journeys, params) }
+ end
+ end
+
+ def highlighted_journeys
+ @all_vehicle_journeys.joins(:journey_pattern).where(route_id: self.id)
+ end
+
+ def highlighted_count
+ highlighted_journeys.count
+ end
+
+ def highlighted?
+ matching_stop_areas = params[:q]["stop_areas"] && (params[:q]["stop_areas"].values & self.stop_area_ids.map(&:to_s)).present?
+ (should_highlight? || matching_stop_areas) && highlighted_journeys.exists?
+ end
+
+ def stop_points
+ @stop_points ||= ar_model.stop_points.map {|sp| StopPoint.new(self, sp, @all_vehicle_journeys, params) }
+ end
+ end
+
+ class VehicleJourney < Base
+ def_delegators :ar_model, :id, :published_journey_name, :journey_pattern, :time_tables, :purchase_windows, :vehicle_journey_at_stops, :time_table_ids, :purchase_window_ids, :route
+
+ def highlighted?
+ should_highlight? && @all_vehicle_journeys.where(id: self.id).exists?
+ end
+
+ def has_purchase_window? purchase_window
+ purchase_window_ids.include?(purchase_window.id)
+ end
+
+ def has_time_table? time_table
+ time_table_ids.include?(time_table.id)
+ end
+ end
+
+ class StopPoint < Base
+ def_delegators :ar_model, :id, :arrival_time, :departure_time, :name, :stop_area, :stop_area_id
+
+ def highlighted?
+ params[:q]["stop_areas"] && params[:q]["stop_areas"].values.any?{|v| v.to_s == stop_area_id.to_s}
+ end
+ end
+end
diff --git a/app/views/referential_vehicle_journeys/_consolidated.html.slim b/app/views/referential_vehicle_journeys/_consolidated.html.slim
new file mode 100644
index 000000000..b79a61dfb
--- /dev/null
+++ b/app/views/referential_vehicle_journeys/_consolidated.html.slim
@@ -0,0 +1,21 @@
+.row.consolidated-view
+ - @consolidated.lines.each do |line|
+ = render partial: "consolidated_line", object: line
+ .col-md-12
+ = new_pagination @consolidated.paginated_lines, 'pull-right'
+
+coffee:
+ $('a.toggle-timetables').click (e)->
+ e.preventDefault()
+ $(e.target).toggleClass 'active'
+ $(e.target).parents('.table').find('.detailed-timetables').toggleClass 'hidden'
+
+ $('a.toggle-purchase-windows').click (e)->
+ e.preventDefault()
+ $(e.target).toggleClass 'active'
+ $(e.target).parents('.table').find('.detailed-purchase-windows').toggleClass 'hidden'
+
+ $('a.toggle-route').click (e)->
+ e.preventDefault()
+ $(e.currentTarget).toggleClass 'active'
+ $(e.currentTarget).parents('.route').find('.vehicle-journeys').toggleClass 'hidden'
diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
new file mode 100644
index 000000000..b72a17ccd
--- /dev/null
+++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
@@ -0,0 +1,118 @@
+.line.col-md-12
+ .head
+ span
+ = Chouette::Line.ts
+ |
+ strong= consolidated_line.name
+ .routes
+ - consolidated_line.routes.each do |route|
+ .route
+ .head class="#{route.highlighted? ? 'highlighted' : ''}"
+ = link_to '#', class: 'toggle-route' do
+ span.sb.sb-route
+ |
+ = Chouette::Route.ts
+ |
+ strong= route.name
+ .pull-right
+ = route.highlighted_count
+ |
+ = Chouette::VehicleJourney.t
+ |
+ span.fa.fa-angle-up
+ .table.table-2entries.vehicle-journeys.hidden
+ .t2e-head.w20
+ .th
+ div
+ strong= Chouette::VehicleJourney.tmf(:id)
+ div= Chouette::VehicleJourney.tmf(:name)
+ div= Chouette::VehicleJourney.tmf(:journey_pattern_id)
+ div
+ = link_to '#', class: 'toggle-purchase-windows detailed-timetables-bt' do
+ span.fa.fa-angle-up
+ = Chouette::PurchaseWindow.t
+ .detailed-purchase-windows.hidden
+ - route.purchase_windows.uniq.each do |tt|
+ div
+ p
+ = link_to [@referential, tt] do
+ span.fa.fa-calendar style={color: (tt.color ? tt.color : '#4B4B4B')}
+ |
+ = tt.name
+
+ p= tt.bounding_dates.split(' ').join(' > ')
+ div
+ = link_to '#', class: 'toggle-timetables detailed-timetables-bt' do
+ span.fa.fa-angle-up
+ = Chouette::TimeTable.t
+
+ .detailed-timetables.hidden
+ - route.time_tables.uniq.each do |tt|
+ div
+ p
+ = link_to [@referential, tt] do
+ span.fa.fa-calendar style={color: (tt.color ? tt.color : '#4B4B4B')}
+ |
+ = tt.display_day_types
+
+ p= tt.bounding_dates.split(' ').join(' > ')
+ - prev_sp = nil
+ - route.stop_points.each do |sp|
+ ruby:
+ headline = vehicle_journey_stop_headline prev_sp, sp
+ prev_sp = sp
+ .td class="#{sp.highlighted? ? 'highlighted' : ''}"
+ div title="#{sp.stop_area.city_name ? "#{sp.stop_area.city_name} (#{sp.stop_area.zip_code})" : ''}" data-headline=headline class=(headline.present? ? 'headlined' : '')
+ span
+ = sp.name
+ - if sp.stop_area.time_zone_formatted_offset
+ span.small
+ |
+ = "(#{sp.stop_area.time_zone_formatted_offset})"
+ .t2e-item-list.w80
+ div
+ - route.vehicle_journeys.each do |journey|
+ .t2e-item class="#{journey.highlighted? ? 'highlighted' : ''}"
+ .th
+ div
+ strong= link_to journey.id, [@referential, journey.route.line, journey.route]
+ div= journey.published_journey_name
+ div= journey.journey_pattern.get_objectid.short_id
+ div
+ - journey.purchase_windows[0..3].each do |tt|
+ span.vj_tt
+ = link_to [@referential, tt], target: :blank do
+ span.fa.fa-calendar style="color: #{tt.color ? tt.color : '#4B4B4B'}"
+ - if journey.purchase_windows.size > 3
+ span.vj_tt = "+ #{journey.purchase_windows.size - 3}"
+ .detailed-purchase-windows.hidden
+ - route.purchase_windows.uniq.each do |tt|
+ div class=(journey.has_purchase_window?(tt) ? 'active' : 'inactive')
+ div
+ - journey.time_tables[0..3].each do |tt|
+ span.vj_tt
+ = link_to [@referential, tt], target: :blank do
+ span.fa.fa-calendar style="color: #{tt.color ? tt.color : '#4B4B4B'}"
+ - if journey.time_tables.size > 3
+ span.vj_tt = "+ #{journey.time_tables.size - 3}"
+ .detailed-timetables.hidden
+ - route.time_tables.uniq.each do |tt|
+ div class=(journey.has_time_table?(tt) ? 'active' : 'inactive')
+
+ - prev_sp = nil
+ - route.stop_points.each do |sp|
+ ruby:
+ headline = vehicle_journey_stop_headline prev_sp, sp
+ prev_sp = sp
+ vjas = journey.vehicle_journey_at_stops.where(stop_point_id: sp.id).last
+ .td class="#{vjas && sp.highlighted? ? 'highlighted' : ''} #{vjas.nil? ? 'disabled' : ''}"
+ div title="#{sp.stop_area.city_name ? "#{sp.stop_area.city_name} (#{sp.stop_area.zip_code})" : ''}" data-headline=headline class=(headline.present? ? 'headlined' : '')
+ - if vjas.present?
+ - if vjas.departure_time == vjas.arrival_time
+ = vjas.departure_time.l(format: "%H:%M")
+ - else
+ = vjas.arrival_time.l(format: "%H:%M")
+ | -
+ = vjas.departure_time.l(format: "%H:%M")
+ - else
+ | 00:00
diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim
index a6e289b97..b12766df1 100644
--- a/app/views/referential_vehicle_journeys/_filters.html.slim
+++ b/app/views/referential_vehicle_journeys/_filters.html.slim
@@ -1,14 +1,23 @@
= search_form_for @q, url: referential_vehicle_journeys_path(@referential), html: {method: :get}, class: 'form form-filter' do |f|
- .ffg-row
+ input type="hidden" name="display" value=params[:display]
+ .ffg-row.w73
.input-group.search_bar
= f.search_field :published_journey_name_or_objectid_cont, placeholder: t('.published_journey_name_or_objectid'), class: 'form-control'
span.input-group-btn
button.btn.btn-default#search-btn type='submit'
span.fa.fa-search
- .ffg-row
+ .ffg-row.w27
.form-group.per-page-select
= I18n.t("simple_form.per_page")
= %w(10 50 100).each_with_index.map{ |v, i| (params[:per_page] == v || params[:per_page].nil? && i == 0) ? "#{v}" : link_to(v, referential_vehicle_journeys_path(@referential, q: params[:q], per_page: v)) }.join(' - ').html_safe
+ .form-group
+ .btn-group
+ = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :list), class: 'btn btn-default ' + (params[:display] != "consolidated" ? 'active' : '') do
+ span.fa.fa-align-justify
+ = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :consolidated), class: 'btn btn-default ' + (params[:display] == "consolidated" ? 'active' : '') do
+ span.fa.fa-th-large
+
+ .ffg-row
.form-group.togglable class=filter_item_class(params[:q], :company_id_eq_any)
= f.label Chouette::VehicleJourney.human_attribute_name(:company), required: false, class: 'control-label'
- if @all_companies.present?
diff --git a/app/views/referential_vehicle_journeys/_list.html.slim b/app/views/referential_vehicle_journeys/_list.html.slim
new file mode 100644
index 000000000..74f8238f8
--- /dev/null
+++ b/app/views/referential_vehicle_journeys/_list.html.slim
@@ -0,0 +1,49 @@
+.row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @vehicle_journeys,
+ [ \
+ TableBuilderHelper::Column.new( \
+ name: t('objectid'), \
+ attribute: Proc.new { |n| n.get_objectid.short_id }, \
+ sortable: false \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :published_journey_name, \
+ attribute: 'published_journey_name', \
+ link_to: lambda do |vehicle_journey| \
+ vehicle_journey.published_journey_name ? referential_line_route_vehicle_journeys_path(@referential, vehicle_journey.route.line, vehicle_journey.route) : '' \
+ end, \
+ sortable: true \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :line, \
+ attribute: Proc.new {|v| v.route.line.name}, \
+ sortable: true \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :route, \
+ attribute: Proc.new {|v| v.route.name}, \
+ sortable: true \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :departure_time, \
+ attribute: Proc.new {|v| v.vehicle_journey_at_stops.first&.departure_local }, \
+ sortable: true \
+ ), \
+ [@starting_stop, @ending_stop].compact.map{|stop| \
+ TableBuilderHelper::Column.new( \
+ attribute: Proc.new {|v| v.vehicle_journey_at_stops.where("stop_points.stop_area_id" => stop.id).last&.arrival_local }, \
+ sortable: false, \
+ name: stop.name \
+ )\
+ }, \
+ TableBuilderHelper::Column.new( \
+ key: :arrival_time, \
+ attribute: Proc.new {|v| v.vehicle_journey_at_stops.last&.arrival_local }, \
+ sortable: true, \
+ ), \
+ ].flatten.compact,
+ cls: 'table has-filter has-search'
+
+ = new_pagination @vehicle_journeys, 'pull-right'
diff --git a/app/views/referential_vehicle_journeys/index.html.slim b/app/views/referential_vehicle_journeys/index.html.slim
index 00f63cb65..178a88568 100644
--- a/app/views/referential_vehicle_journeys/index.html.slim
+++ b/app/views/referential_vehicle_journeys/index.html.slim
@@ -9,55 +9,11 @@
= render 'filters'
- if @vehicle_journeys.present?
- .row
- .col-lg-12
- .select_table
- = table_builder_2 @vehicle_journeys,
- [ \
- TableBuilderHelper::Column.new( \
- name: t('objectid'), \
- attribute: Proc.new { |n| n.get_objectid.short_id }, \
- sortable: false \
- ), \
- TableBuilderHelper::Column.new( \
- key: :published_journey_name, \
- attribute: 'published_journey_name', \
- link_to: lambda do |vehicle_journey| \
- vehicle_journey.published_journey_name ? referential_line_route_vehicle_journeys_path(@referential, vehicle_journey.route.line, vehicle_journey.route) : '' \
- end, \
- sortable: true \
- ), \
- TableBuilderHelper::Column.new( \
- key: :line, \
- attribute: Proc.new {|v| v.route.line.name}, \
- sortable: true \
- ), \
- TableBuilderHelper::Column.new( \
- key: :route, \
- attribute: Proc.new {|v| v.route.name}, \
- sortable: true \
- ), \
- TableBuilderHelper::Column.new( \
- key: :departure_time, \
- attribute: Proc.new {|v| v.vehicle_journey_at_stops.first&.departure_local }, \
- sortable: true \
- ), \
- [@starting_stop, @ending_stop].compact.map{|stop| \
- TableBuilderHelper::Column.new( \
- attribute: Proc.new {|v| v.vehicle_journey_at_stops.where("stop_points.stop_area_id" => stop.id).last&.arrival_local }, \
- sortable: false, \
- name: stop.name \
- )\
- }, \
- TableBuilderHelper::Column.new( \
- key: :arrival_time, \
- attribute: Proc.new {|v| v.vehicle_journey_at_stops.last&.arrival_local }, \
- sortable: true, \
- ), \
- ].flatten.compact,
- cls: 'table has-filter has-search'
+ - if params[:display] == "consolidated"
+ = render partial: "consolidated"
+ - else
+ = render partial: "list"
- = new_pagination @vehicle_journeys, 'pull-right'
- unless @vehicle_journeys.any?
.row.mt-xs
--
cgit v1.2.3
From 464b3ce20ecaf3c5e1a5cca6194b91b7eb920325 Mon Sep 17 00:00:00 2001
From: Zog
Date: Fri, 4 May 2018 16:42:53 +0200
Subject: Refs #6923; Some css sugar
---
app/assets/stylesheets/modules/_vj_collection.sass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index 3a252bfc0..da61cc5e5 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -260,7 +260,8 @@
color: #777
.t2e-item-list .t2e-item
.th
- max-width: 100px
+ min-width: 100px
+ max-width: 150px
& > div
text-overflow: ellipsis
overflow: hidden
--
cgit v1.2.3
From 2c619e4aa072950681be04a603f91597dfcca088 Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 7 May 2018 08:26:07 +0200
Subject: refs #6923; small improvements
---
app/services/referential_consolidated.rb | 4 ++--
app/views/referential_vehicle_journeys/_consolidated_line.html.slim | 6 ++++--
app/views/referential_vehicle_journeys/_filters.html.slim | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/services/referential_consolidated.rb b/app/services/referential_consolidated.rb
index abfb7532b..465eab405 100644
--- a/app/services/referential_consolidated.rb
+++ b/app/services/referential_consolidated.rb
@@ -89,7 +89,7 @@ class ReferentialConsolidated
end
def highlighted?
- matching_stop_areas = params[:q]["stop_areas"] && (params[:q]["stop_areas"].values & self.stop_area_ids.map(&:to_s)).present?
+ matching_stop_areas = params[:q] && params[:q]["stop_areas"] && (params[:q]["stop_areas"].values & self.stop_area_ids.map(&:to_s)).present?
(should_highlight? || matching_stop_areas) && highlighted_journeys.exists?
end
@@ -118,7 +118,7 @@ class ReferentialConsolidated
def_delegators :ar_model, :id, :arrival_time, :departure_time, :name, :stop_area, :stop_area_id
def highlighted?
- params[:q]["stop_areas"] && params[:q]["stop_areas"].values.any?{|v| v.to_s == stop_area_id.to_s}
+ params[:q] && params[:q]["stop_areas"] && params[:q]["stop_areas"].values.any?{|v| v.to_s == stop_area_id.to_s}
end
end
end
diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
index b72a17ccd..84c09313a 100644
--- a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
+++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
@@ -75,8 +75,10 @@
.t2e-item class="#{journey.highlighted? ? 'highlighted' : ''}"
.th
div
- strong= link_to journey.id, [@referential, journey.route.line, journey.route]
- div= journey.published_journey_name
+ strong= link_to journey.id, [@referential, journey.route.line, journey.route, :vehicle_journeys]
+ div
+ a title=journey.published_journey_name
+ = journey.published_journey_name
div= journey.journey_pattern.get_objectid.short_id
div
- journey.purchase_windows[0..3].each do |tt|
diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim
index b12766df1..0c4018808 100644
--- a/app/views/referential_vehicle_journeys/_filters.html.slim
+++ b/app/views/referential_vehicle_journeys/_filters.html.slim
@@ -82,5 +82,5 @@
.actions
- = link_to t('actions.erase'), referential_vehicle_journeys_path(@referential), class: 'btn btn-link'
+ = link_to t('actions.erase'), referential_vehicle_journeys_path(@referential, display: params[:display]), class: 'btn btn-link'
= f.submit t('actions.filter'), class: 'btn btn-default'
--
cgit v1.2.3
From f5d2df936e76aa06360363ee27e3a6b28ea48c90 Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 7 May 2018 08:39:32 +0200
Subject: Refs #6923; Use a feature: `consolidated_offers`
---
.../_consolidated_line.html.slim | 3 +--
app/views/referential_vehicle_journeys/_filters.html.slim | 13 +++++++------
app/views/referential_vehicle_journeys/index.html.slim | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
index 84c09313a..f6a9dcee8 100644
--- a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
+++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
@@ -77,8 +77,7 @@
div
strong= link_to journey.id, [@referential, journey.route.line, journey.route, :vehicle_journeys]
div
- a title=journey.published_journey_name
- = journey.published_journey_name
+ = link_to journey.published_journey_name, [@referential, journey.route.line, journey.route, :vehicle_journeys], title: journey.published_journey_name
div= journey.journey_pattern.get_objectid.short_id
div
- journey.purchase_windows[0..3].each do |tt|
diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim
index 0c4018808..bcb980f64 100644
--- a/app/views/referential_vehicle_journeys/_filters.html.slim
+++ b/app/views/referential_vehicle_journeys/_filters.html.slim
@@ -10,12 +10,13 @@
.form-group.per-page-select
= I18n.t("simple_form.per_page")
= %w(10 50 100).each_with_index.map{ |v, i| (params[:per_page] == v || params[:per_page].nil? && i == 0) ? "#{v}" : link_to(v, referential_vehicle_journeys_path(@referential, q: params[:q], per_page: v)) }.join(' - ').html_safe
- .form-group
- .btn-group
- = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :list), class: 'btn btn-default ' + (params[:display] != "consolidated" ? 'active' : '') do
- span.fa.fa-align-justify
- = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :consolidated), class: 'btn btn-default ' + (params[:display] == "consolidated" ? 'active' : '') do
- span.fa.fa-th-large
+ - if has_feature?(:consolidated_offers)
+ .form-group
+ .btn-group
+ = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :list), class: 'btn btn-default ' + (params[:display] != "consolidated" ? 'active' : '') do
+ span.fa.fa-align-justify
+ = link_to referential_vehicle_journeys_path(@referential, q: params[:q], display: :consolidated), class: 'btn btn-default ' + (params[:display] == "consolidated" ? 'active' : '') do
+ span.fa.fa-th-large
.ffg-row
.form-group.togglable class=filter_item_class(params[:q], :company_id_eq_any)
diff --git a/app/views/referential_vehicle_journeys/index.html.slim b/app/views/referential_vehicle_journeys/index.html.slim
index 178a88568..d1d1dae07 100644
--- a/app/views/referential_vehicle_journeys/index.html.slim
+++ b/app/views/referential_vehicle_journeys/index.html.slim
@@ -9,7 +9,7 @@
= render 'filters'
- if @vehicle_journeys.present?
- - if params[:display] == "consolidated"
+ - if params[:display] == "consolidated" && has_feature?(:consolidated_offers)
= render partial: "consolidated"
- else
= render partial: "list"
--
cgit v1.2.3
From 8316ed020e2bcd2e9b28d0827ae626a9d927eed4 Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 7 May 2018 09:06:55 +0200
Subject: Refs #6923; :lipstick:
---
app/assets/stylesheets/modules/_vj_collection.sass | 15 +++++++++++++--
.../referential_vehicle_journeys/_consolidated.html.slim | 14 +++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index da61cc5e5..b68b191d8 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -234,14 +234,18 @@
.route
background: #F9F9F9
& > .head
- padding: 15px
&.highlighted
.pull-right, span.fa
color: $highlighted !important
a
+ padding: 15px
color: black
font-size: 1.2em
text-transform: capitalize
+ display: block
+ text-decoration: none
+ &:hover
+ background-color: #F0F0F0
.fa
color: $red
transition: transform 0.1s
@@ -251,7 +255,14 @@
font-size: 0.9em
text-transform: lowercase
.vehicle-journeys
- margin-bottom: 40px
+ display: block
+ overflow: hidden
+ transition: height 0.5s, margin-bottom 0.5s
+ margin-bottom: 0px
+ & > *
+ display: inline-block
+ &.open
+ margin-bottom: 40px
.highlighted
background-color: lighten($highlighted, 20%) !important
diff --git a/app/views/referential_vehicle_journeys/_consolidated.html.slim b/app/views/referential_vehicle_journeys/_consolidated.html.slim
index b79a61dfb..e2de526bc 100644
--- a/app/views/referential_vehicle_journeys/_consolidated.html.slim
+++ b/app/views/referential_vehicle_journeys/_consolidated.html.slim
@@ -15,7 +15,19 @@ coffee:
$(e.target).toggleClass 'active'
$(e.target).parents('.table').find('.detailed-purchase-windows').toggleClass 'hidden'
+ $('.route').find('.vehicle-journeys').each (i, e)->
+ $e = $(e)
+ $e.removeClass 'hidden'
+ e.setAttribute 'data-original-height', $e.height()
+ $e.height 0
+
$('a.toggle-route').click (e)->
e.preventDefault()
$(e.currentTarget).toggleClass 'active'
- $(e.currentTarget).parents('.route').find('.vehicle-journeys').toggleClass 'hidden'
+ tab = $(e.currentTarget).parents('.route').find('.vehicle-journeys')
+ if tab.hasClass 'open'
+ tab.removeClass 'open'
+ tab.height 0
+ else
+ tab.addClass 'open'
+ tab.height tab.attr('data-original-height')
--
cgit v1.2.3
From 5b00d38e4917d9b56a9fcda2bdca381586b824af Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 7 May 2018 09:31:19 +0200
Subject: Refs #6923; More :lipstick:
---
app/assets/stylesheets/modules/_vj_collection.sass | 22 ++++++++++++++++++++--
.../_consolidated_line.html.slim | 2 +-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index b68b191d8..2e9951d35 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -261,13 +261,16 @@
margin-bottom: 0px
& > *
display: inline-block
+ & > *
+ overflow: hidden
+ min-width: 0
&.open
margin-bottom: 40px
.highlighted
background-color: lighten($highlighted, 20%) !important
.disabled
- background-color: #ccc
+ background-color: #dedede
color: #777
.t2e-item-list .t2e-item
.th
@@ -279,6 +282,18 @@
white-space: nowrap
.td
text-align: center
+ &:hover:after
+ position: absolute
+ height: 100%
+ bottom: 0
+ left: -10000px
+ right: -10000px
+ content: ""
+ background-color: $red
+ opacity: 0.1
+ z-index: 10
+ &.headlined:hover:after
+ height: 50%
.table-2entries > .t2e-head > .td > div > span::after
@@ -288,4 +303,7 @@
background-color: #F9F9F9
.table.table-2entries .td > div.headlined::before
- border-right-color: #F9F9F9
+ border-right: none
+
+ // .table.table-2entries .highlighted .td > div.headlined::before
+ // border-right-color: lighten($highlighted, 20%)
diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
index f6a9dcee8..d4c756d38 100644
--- a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
+++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
@@ -106,7 +106,7 @@
headline = vehicle_journey_stop_headline prev_sp, sp
prev_sp = sp
vjas = journey.vehicle_journey_at_stops.where(stop_point_id: sp.id).last
- .td class="#{vjas && sp.highlighted? ? 'highlighted' : ''} #{vjas.nil? ? 'disabled' : ''}"
+ .td class="#{vjas && sp.highlighted? ? 'highlighted' : ''} #{vjas.nil? ? 'disabled' : ''} #{headline.present? ? 'headlined' : ''}"
div title="#{sp.stop_area.city_name ? "#{sp.stop_area.city_name} (#{sp.stop_area.zip_code})" : ''}" data-headline=headline class=(headline.present? ? 'headlined' : '')
- if vjas.present?
- if vjas.departure_time == vjas.arrival_time
--
cgit v1.2.3
From 0ef1a1d4f948ffa4e7d681dfc9a27d8783b7568e Mon Sep 17 00:00:00 2001
From: Zog
Date: Mon, 7 May 2018 09:43:18 +0200
Subject: Refs #6321; :fire: comments
---
app/assets/stylesheets/modules/_vj_collection.sass | 3 ---
1 file changed, 3 deletions(-)
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index 2e9951d35..0131201f0 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -304,6 +304,3 @@
.table.table-2entries .td > div.headlined::before
border-right: none
-
- // .table.table-2entries .highlighted .td > div.headlined::before
- // border-right-color: lighten($highlighted, 20%)
--
cgit v1.2.3
From 3364755e26c5a4a54a6de6080bf1177ee03c7183 Mon Sep 17 00:00:00 2001
From: Alban Peignier
Date: Thu, 10 May 2018 22:13:40 +0200
Subject: Move per-page-select group in the second line in
referential_vehicle_journeys/_filters. Refs #6923
---
app/views/referential_vehicle_journeys/_filters.html.slim | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim
index bcb980f64..31053c5ba 100644
--- a/app/views/referential_vehicle_journeys/_filters.html.slim
+++ b/app/views/referential_vehicle_journeys/_filters.html.slim
@@ -1,15 +1,12 @@
= search_form_for @q, url: referential_vehicle_journeys_path(@referential), html: {method: :get}, class: 'form form-filter' do |f|
input type="hidden" name="display" value=params[:display]
- .ffg-row.w73
+ .ffg-row.w85
.input-group.search_bar
= f.search_field :published_journey_name_or_objectid_cont, placeholder: t('.published_journey_name_or_objectid'), class: 'form-control'
span.input-group-btn
button.btn.btn-default#search-btn type='submit'
span.fa.fa-search
- .ffg-row.w27
- .form-group.per-page-select
- = I18n.t("simple_form.per_page")
- = %w(10 50 100).each_with_index.map{ |v, i| (params[:per_page] == v || params[:per_page].nil? && i == 0) ? "#{v}" : link_to(v, referential_vehicle_journeys_path(@referential, q: params[:q], per_page: v)) }.join(' - ').html_safe
+ .ffg-row.w15
- if has_feature?(:consolidated_offers)
.form-group
.btn-group
@@ -19,6 +16,9 @@
span.fa.fa-th-large
.ffg-row
+ .form-group.per-page-select
+ = I18n.t("simple_form.per_page")
+ = %w(10 50 100).each_with_index.map{ |v, i| (params[:per_page] == v || params[:per_page].nil? && i == 0) ? "#{v}" : link_to(v, referential_vehicle_journeys_path(@referential, q: params[:q], per_page: v)) }.join(' - ').html_safe
.form-group.togglable class=filter_item_class(params[:q], :company_id_eq_any)
= f.label Chouette::VehicleJourney.human_attribute_name(:company), required: false, class: 'control-label'
- if @all_companies.present?
--
cgit v1.2.3