aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/stylesheets/components/_referential_overview.sass32
-rw-r--r--app/javascript/referential_overview/index.coffee1
-rw-r--r--app/services/referential_overview.rb26
-rw-r--r--app/views/referentials/_overview.html.slim31
4 files changed, 78 insertions, 12 deletions
diff --git a/app/assets/stylesheets/components/_referential_overview.sass b/app/assets/stylesheets/components/_referential_overview.sass
index a25c49272..2d903a2d7 100644
--- a/app/assets/stylesheets/components/_referential_overview.sass
+++ b/app/assets/stylesheets/components/_referential_overview.sass
@@ -1,15 +1,43 @@
.referential-overview
margin-top: 50px
- .time-travel
- background-color: $grey
+ .time-travel, .filters
+ background-color: $lightgrey
padding: 10px
float: right
border-top-left-radius: 10px
border-top-right-radius: 10px
+ .time-travel
a.btn:first-child
border-right: 1px solid $grey
+ margin-right: 1px
a.btn:last-child
border-left: 1px solid $grey
+ max-width: 33%
+ .filters
+ float: left
+ max-width: 66%
+ padding: 0
+ background: transparentize(#cbac3e, 0.8)
+ border: 1px solid $grey
+ border-bottom: none
+ form
+ background: transparent
+ display: flex
+ .ffg-row
+ border-color: $grey
+ .form-group
+ border-color: $grey
+ width: auto
+ flex: 1 1
+ padding: 11px
+ .input-group-btn
+ right: 10px
+ &.togglable
+ padding-top: 12px
+ padding-bottom: 11px
+ &:before
+ top: 7px
+
.overview-table
border: 1px solid $grey
clear: both
diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee
index 8dd0e3561..6128d7c98 100644
--- a/app/javascript/referential_overview/index.coffee
+++ b/app/javascript/referential_overview/index.coffee
@@ -28,7 +28,6 @@ class TimeTravel
false
scrolledTo: (progress)->
- console.log "scrolledTo: #{progress*100}%"
@prevBt.removeClass 'disabled'
@nextBt.removeClass 'disabled'
@prevBt.addClass 'disabled' if progress == 0
diff --git a/app/services/referential_overview.rb b/app/services/referential_overview.rb
index 1fafae8ca..ccfe0617a 100644
--- a/app/services/referential_overview.rb
+++ b/app/services/referential_overview.rb
@@ -1,16 +1,17 @@
class ReferentialOverview
attr_reader :h
+ attr_reader :referential
PER_PAGE = 10
- def initialize referential, h
+ def initialize referential, h=nil
@referential = referential
- @page = h.params[pagination_param_name]&.to_i || 1
+ @page = h && h.params[pagination_param_name]&.to_i || 1
@h = h
end
def lines
- referential_lines.includes(:company).map{|l| Line.new(l, @referential, period.first, h)}
+ filtered_lines.includes(:company).map{|l| Line.new(l, @referential, period.first, h)}
end
def period
@@ -30,20 +31,35 @@ class ReferentialOverview
end
def referential_lines
- @referential.metadatas_lines.page(@page).per_page(PER_PAGE)
+ @referential.metadatas_lines
+ end
+
+ def filtered_lines
+ search.result.page(@page).per_page(PER_PAGE)
end
### Pagination
- delegate :empty?, :first, :total_pages, :size, :total_entries, :offset, :length, to: :referential_lines
+ delegate :empty?, :first, :total_pages, :size, :total_entries, :offset, :length, to: :filtered_lines
def current_page
@page
end
+ ### search
+ def search
+ lines = referential_lines
+ lines = lines.search h.params[search_param_name]
+ lines
+ end
+
def pagination_param_name
"referential_#{@referential.slug}_overview"
end
+ def search_param_name
+ "q_#{pagination_param_name}"
+ end
+
class Line
attr_reader :h
attr_reader :referential_line
diff --git a/app/views/referentials/_overview.html.slim b/app/views/referentials/_overview.html.slim
index 26958d152..bccd35aae 100644
--- a/app/views/referentials/_overview.html.slim
+++ b/app/views/referentials/_overview.html.slim
@@ -1,4 +1,24 @@
.referential-overview id=overview.pagination_param_name
+ .filters
+ = search_form_for overview.search, as: overview.search_param_name, url: "", html: {method: :get}, class: 'form form-filter' do |f|
+ .ffg-row
+ .form-group.input-group.search_bar
+ = f.search_field :name_or_number_or_objectid_cont, placeholder: t('lines.index.name_or_number_or_objectid'), class: 'form-control'
+ span.input-group-btn
+ button.btn.btn-default#search-btn type='submit'
+ span.fa.fa-search
+ .form-group.togglable
+ = f.label Chouette::Line.human_attribute_name(:company_id), required: false, class: 'control-label'
+ = f.input :company_id_eq_any, collection: overview.referential.companies.order(name: :asc), as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
+
+ .form-group.togglable
+ = f.label Chouette::Line.human_attribute_name(:transport_mode), required: false, class: 'control-label'
+ = f.input :transport_mode_eq_any, collection: StifTransportModeEnumerations.sorted_transport_modes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_mode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
+
+ .actions
+ = link_to 'Effacer', @workbench, class: 'btn btn-link'
+ = f.submit 'Filtrer', class: 'btn btn-default'
+
.time-travel.btn-group
= link_to I18n.t("referentials.overview.head.prev_page"), '#', class: "prev-page btn btn-default"
= link_to I18n.t("referentials.overview.head.today"), '#', class: "today btn btn-default #{overview.includes_today? ? '' : 'disabled'}"
@@ -31,10 +51,13 @@
.name= day.short_name
.number= day.number
.lines
- - overview.lines.each do |line|
- .line style=line.html_style class=line.html_class
- - line.periods.each do |period|
- .period style=period.html_style class=period.html_class title=period.title
+ - if overview.lines.any?
+ - overview.lines.each do |line|
+ .line style=line.html_style class=line.html_class
+ - line.periods.each do |period|
+ .period style=period.html_style class=period.html_class title=period.title
+ - else
+ = replacement_msg t('referential_lines.search_no_results')
= new_pagination overview, 'pull-right'