diff options
| -rw-r--r-- | app/controllers/calendars_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 9 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 9 | ||||
| -rw-r--r-- | app/decorators/route_decorator.rb | 5 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper/url.rb | 2 | ||||
| -rw-r--r-- | app/views/calendars/index.html.slim | 24 | ||||
| -rw-r--r-- | app/views/referential_lines/show.html.slim | 52 | ||||
| -rw-r--r-- | app/views/routing_constraint_zones/show.html.slim | 19 | ||||
| -rw-r--r-- | app/views/time_tables/_filter.html.slim | 6 | ||||
| -rw-r--r-- | app/views/time_tables/index.html.slim | 50 |
11 files changed, 147 insertions, 42 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 23af4129b..1c342c718 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -5,9 +5,19 @@ class CalendarsController < BreadcrumbController respond_to :html respond_to :js, only: :index + def index + index! do + @calendars = ModelDecorator.decorate(@calendars, with: CalendarDecorator) + + build_breadcrumb :index + end + end + def show show! do @calendar = @calendar.decorate + + build_breadcrumb :show end end diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 5d36e7da7..4b4a822b4 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -39,6 +39,15 @@ class ReferentialLinesController < ChouetteController @routes = @routes.paginate(page: params[:page], per_page: 10) + @routes = ModelDecorator.decorate( + @routes, + with: RouteDecorator, + context: { + referential: referential, + line: @line + } + ) + show! do build_breadcrumb :show end diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 786bd57cc..4781d0d16 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -44,8 +44,7 @@ class RoutesController < ChouetteController show! do @route = @route.decorate(context: { referential: @referential, - line: @line, - route_sp: @route_sp + line: @line }) build_breadcrumb :show diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 0e0cade56..f23e4c201 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -85,6 +85,15 @@ class TimeTablesController < ChouetteController if collection.out_of_bounds? redirect_to params.merge(:page => 1) end + + @time_tables = ModelDecorator.decorate( + @time_tables, + with: TimeTableDecorator, + context: { + referential: @referential + } + ) + build_breadcrumb :index } end diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb index 99b174dff..484c3db04 100644 --- a/app/decorators/route_decorator.rb +++ b/app/decorators/route_decorator.rb @@ -6,13 +6,12 @@ class RouteDecorator < Draper::Decorator # Requires: # context: { # referential: , - # line: , - # route_sp + # line: # } def action_links links = [] - if context[:route_sp].any? + if object.stop_points.any? links << Link.new( content: h.t('journey_patterns.index.title'), href: [ diff --git a/app/helpers/table_builder_helper/url.rb b/app/helpers/table_builder_helper/url.rb index 894e5ddf8..0894df0fe 100644 --- a/app/helpers/table_builder_helper/url.rb +++ b/app/helpers/table_builder_helper/url.rb @@ -10,7 +10,7 @@ module TableBuilderHelper polymorph_url << item.route.line if item.is_a?(Chouette::RoutingConstraintZone) polymorph_url << item if item.respond_to? :line_referential polymorph_url << item.stop_area if item.respond_to? :stop_area - polymorph_url << item if item.respond_to? :stop_points || item.is_a?(Chouette::TimeTable) + polymorph_url << item if item.respond_to?(:stop_points) || item.is_a?(Chouette::TimeTable) elsif item.respond_to? :referential polymorph_url << item.referential end diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim index ec3893959..843ec1256 100644 --- a/app/views/calendars/index.html.slim +++ b/app/views/calendars/index.html.slim @@ -15,12 +15,24 @@ - if @calendars.any? .row .col-lg-12 - = table_builder @calendars, - { :name => 'name', :short_name => 'short_name', :shared => Proc.new{|c| t("#{c.try(:shared)}") } }, - [:show, :edit, :delete], - [], - 'table has-filter' - + = table_builder_2 @calendars, + [ \ + TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :short_name, \ + attribute: 'short_name' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :shared, \ + attribute: Proc.new { |c| t("#{c.try(:shared)}") } \ + ) \ + ], + links: [:show, :edit], + cls: 'table has-filter' + = new_pagination @calendars, 'pull-right' - unless @calendars.any? diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 0bb6d9032..14e300aa2 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -51,18 +51,46 @@ - if @routes.any? .row .col-lg-12 - = table_builder @routes, - { 'ID' => Proc.new { |n| n.objectid.local_id }, - :name => 'name', - :published_name => 'published_name', - :wayback => 'wayback_text', - 'Arrêt de départ' => Proc.new{|r| r.try(:stop_points).first.try(:stop_area).try(:name)}, - "Arrêt d'arrivée" => Proc.new{|r| r.try(:stop_points).last.try(:stop_area).try(:name)}, - :stop_points => Proc.new{|r| r.try(:stop_points).count}, - :journey_patterns => Proc.new{|r| r.try(:journey_patterns).count} }, - [:show, :edit, :delete], - [], - 'table has-search' + = table_builder_2 @routes, + [ \ + TableBuilderHelper::Column.new( \ + name: 'ID', \ + attribute: Proc.new { |n| n.objectid.local_id }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :published_name, \ + attribute: 'published_name' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :wayback, \ + attribute: 'wayback_text' \ + ), \ + TableBuilderHelper::Column.new( \ + name: 'Arrêt de départ', \ + attribute: Proc.new { |r| r.try(:stop_points).first.try(:stop_area).try(:name) }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + name: "Arrêt d'arrivée", \ + attribute: Proc.new{ |r| r.try(:stop_points).last.try(:stop_area).try(:name) }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + key: :stop_points, \ + attribute: Proc.new{ |r| r.try(:stop_points).count } \ + ), \ + TableBuilderHelper::Column.new( \ + key: :journey_patterns, \ + attribute: Proc.new{ |r| r.try(:journey_patterns).count } \ + ) \ + ], + links: [:show, :edit], + cls: 'table has-search' = new_pagination @routes, 'pull-right' diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 3decc086f..07b5ac6e6 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -26,9 +26,16 @@ .row .col-lg-12 - = table_builder @routing_constraint_zone.route.stop_points, - { "Arrêts de l'itinéraire" => 'name', - "Arrêts inclus dans l'ITL" => Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? 'Oui' : 'Non' } }, - [], - [], - 'table has-stoppoints' + = table_builder_2 @routing_constraint_zone.route.stop_points, + [ \ + TableBuilderHelper::Column.new( \ + name: "Arrêts de l'itinéraire", \ + attribute: 'name' \ + ), + TableBuilderHelper::Column.new( \ + name: "Arrêts inclus dans l'ITL", \ + attribute: Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? 'Oui' : 'Non' } \ + ) \ + ], + sortable: false, + cls: 'table has-stoppoints' diff --git a/app/views/time_tables/_filter.html.slim b/app/views/time_tables/_filter.html.slim index 10e46d884..1015eca31 100644 --- a/app/views/time_tables/_filter.html.slim +++ b/app/views/time_tables/_filter.html.slim @@ -8,15 +8,15 @@ .ffg-row / .form-group.togglable - / = f.label @time_tables.human_attribute_name(:color), required: false, class: 'control-label' + / = f.label Chouette::TimeTable.human_attribute_name(:color), required: false, class: 'control-label' / = f.input :color_cont_any, collection: ["#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7", "#6321A0", "#E796C6", "#DD2DAA"], as: :check_boxes, label: false, label_method: lambda{|tt| ("<span style='height:19px;'><span class='fa fa-circle' style='position:relative;top:0;margin-top:0;color:" + tt + "'></span></span>").html_safe }, required: false, wrapper_html: { class: 'checkbox_list' } .form-group - = f.label @time_tables.human_attribute_name(:tag_search), required: false, class: 'control-label' + = f.label Chouette::TimeTable.human_attribute_name(:tag_search), required: false, class: 'control-label' = f.input :tag_search, as: :tags, collection: Chouette::TimeTable.tags_on(:tags).pluck(:name), label: false, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Indiquez une étiquette...' }, wrapper_html: { class: 'select2ed'}, include_blank: false .form-group.togglable - = f.label @time_tables.human_attribute_name(:bounding_dates), required: false, class: 'control-label' + = f.label Chouette::TimeTable.human_attribute_name(:bounding_dates), required: false, class: 'control-label' .filter_menu = f.input :start_date_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @begin_range, include_blank: @begin_range ? false : true = f.input :end_date_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @end_range, include_blank: @end_range ? false : true diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index a0b9e4380..72c025bc1 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -14,15 +14,47 @@ - if @time_tables.any? .row .col-lg-12 - = table_builder @time_tables, - { 'ID' => Proc.new { |n| n.objectid.local_id }, :color => Proc.new{|tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }, :comment => 'comment', - "Période englobante" => Proc.new{ |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) }, - "Nombre de courses associées" => Proc.new{ |tt| tt.vehicle_journeys.count }, - "Journées d'application" => Proc.new{ |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe }, - :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} }, - [:show, :edit, :duplicate, :actualize, :delete], - [], - 'table has-search' + = table_builder_2 @time_tables, + [ \ + TableBuilderHelper::Column.new( \ + name: 'ID', \ + attribute: Proc.new { |n| n.objectid.local_id }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + key: :color, \ + attribute: Proc.new { |tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }, \ + ), \ + TableBuilderHelper::Column.new( \ + key: :comment, \ + attribute: 'comment' \ + ), \ + TableBuilderHelper::Column.new( \ + name: "Période englobante", \ + attribute: Proc.new { |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + name: "Nombre de courses associées", \ + attribute: Proc.new{ |tt| tt.vehicle_journeys.count }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + name: "Journées d'application", \ + attribute: Proc.new { |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe }, \ + sortable: false \ + ), \ + TableBuilderHelper::Column.new( \ + key: :calendar, \ + attribute: Proc.new { |tt| tt.calendar ? tt.calendar.try(:name) : '-' } \ + ), \ + TableBuilderHelper::Column.new( \ + key: :updated_at, \ + attribute: Proc.new { |tt| l(tt.updated_at, format: :short) } \ + ) \ + ], + links: [:show, :edit], + cls: 'table has-search' = new_pagination @time_tables, 'pull-right' |
