aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-07-11 18:59:27 +0200
committerTeddy Wing2017-07-12 11:11:14 +0200
commit0970ba4be6b152e1f3aea0f10e8471e68dc60c4b (patch)
tree87939671e1e7b4b94e3dbd593a42af067b4a332d /app
parentef937098ef2c5e7ad8a05c5d84b8a201cb6358e8 (diff)
downloadchouette-core-0970ba4be6b152e1f3aea0f10e8471e68dc60c4b.tar.bz2
StopAreaReferentials#index: Use new table builder helper
Change "_filters.html.slim" to call `#human_attribute_name` on the model instead of the collection, because the collection decorator doesn't delegate that method, and it's better to call it on the class. Refs #3479
Diffstat (limited to 'app')
-rw-r--r--app/controllers/stop_areas_controller.rb7
-rw-r--r--app/views/stop_areas/_filters.html.slim6
-rw-r--r--app/views/stop_areas/index.html.slim40
3 files changed, 44 insertions, 9 deletions
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index e97aad8d3..cdb7c59ab 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -53,11 +53,18 @@ class StopAreasController < BreadcrumbController
def index
request.format.kml? ? @per_page = nil : @per_page = 12
@zip_codes = stop_area_referential.stop_areas.where("zip_code is NOT null").distinct.pluck(:zip_code)
+
index! do |format|
format.html {
if collection.out_of_bounds?
redirect_to params.merge(:page => 1)
end
+
+ @stop_areas = ModelDecorator.decorate(
+ @stop_areas,
+ with: StopAreaDecorator
+ )
+
build_breadcrumb :index
}
end
diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim
index b7c57e842..3b99f377c 100644
--- a/app/views/stop_areas/_filters.html.slim
+++ b/app/views/stop_areas/_filters.html.slim
@@ -7,11 +7,11 @@
span.fa.fa-search
.ffg-row
- = f.input :zip_code_cont, placeholder: t('.zip_code'), label: @stop_areas.human_attribute_name(:zip_code), required: false
- = f.input :city_name_cont, placeholder: t('.city_name'), label: @stop_areas.human_attribute_name(:city_name), required: false
+ = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.human_attribute_name(:zip_code), required: false
+ = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.human_attribute_name(:city_name), required: false
.form-group.togglable
- = f.label @stop_areas.human_attribute_name(:area_type), required: false, class: 'control-label'
+ = f.label Chouette::StopArea.human_attribute_name(:area_type), required: false, class: 'control-label'
= f.input :area_type_eq_any, collection: Chouette::StopArea.area_type.options.sort, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + t("enumerize.stop_area.area_type.#{w[1]}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }
.actions
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 338e7e878..adb023633 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -16,12 +16,40 @@
- if @stop_areas.any?
.row
.col-lg-12
- = table_builder @stop_areas,
- { 'ID Reflex' => Proc.new { |n| n.try(:user_objectid) }, :name => 'name', :registration_number => 'registration_number', :deleted_at => Proc.new{|s| s.deleted_at ? t('false') : t('true')},
- :zip_code => 'zip_code', :city_name => 'city_name', :area_type => Proc.new{|s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}"))} },
- [:show, :edit, :delete],
- [],
- 'table has-filter has-search'
+ = table_builder_2 @stop_areas,
+ [ \
+ TableBuilderHelper::Column.new( \
+ name: 'ID Reflex', \
+ attribute: Proc.new { |n| n.try(:user_objectid) }, \
+ sortable: false \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :registration_number, \
+ attribute: 'registration_number' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :deleted_at, \
+ attribute: Proc.new { |s| s.deleted_at ? t('false') : t('true') } \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :zip_code, \
+ attribute: 'zip_code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :city_name, \
+ attribute: 'city_name' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :area_type, \
+ attribute: Proc.new { |s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}")) } \
+ ), \
+ ],
+ links: [:show, :edit, :delete],
+ cls: 'table has-filter has-search'
= new_pagination @stop_areas, 'pull-right'