diff options
Diffstat (limited to 'app')
21 files changed, 248 insertions, 219 deletions
diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb index 78d3f64c0..f8b5301d3 100644 --- a/app/controllers/group_of_lines_controller.rb +++ b/app/controllers/group_of_lines_controller.rb @@ -1,4 +1,6 @@ -class GroupOfLinesController < ChouetteController +class GroupOfLinesController < BreadcrumbController + include ApplicationHelper + defaults :resource_class => Chouette::GroupOfLine respond_to :html respond_to :xml @@ -6,7 +8,7 @@ class GroupOfLinesController < ChouetteController respond_to :kml, :only => :show respond_to :js, :only => :index - belongs_to :referential + belongs_to :line_referential def show @map = GroupOfLineMap.new(resource).with_helpers(self) @@ -16,7 +18,7 @@ class GroupOfLinesController < ChouetteController end end - def index + def index index! do |format| format.html { if collection.out_of_bounds? @@ -24,17 +26,16 @@ class GroupOfLinesController < ChouetteController end build_breadcrumb :index } - end + end end - def name_filter - respond_to do |format| - format.json { render :json => filtered_group_of_lines_maps} - end + respond_to do |format| + format.json { render :json => filtered_group_of_lines_maps} + end end - + protected def filtered_group_of_lines_maps @@ -42,29 +43,30 @@ class GroupOfLinesController < ChouetteController { :id => group_of_line.id, :name => group_of_line.name } end end - + def filtered_group_of_lines - referential.group_of_lines.select{ |t| t.name =~ /#{params[:q]}/i } + line_referential.group_of_lines.select{ |t| t.name =~ /#{params[:q]}/i } end - def collection - @q = referential.group_of_lines.search(params[:q]) + def collection + @q = line_referential.group_of_lines.search(params[:q]) @group_of_lines ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end def resource_url(group_of_line = nil) - referential_group_of_line_path(referential, group_of_line || resource) + line_referential_group_of_line_path(line_referential, group_of_line || resource) end def collection_url - referential_group_of_lines_path(referential) + line_referential_group_of_lines_path(line_referential) end + alias_method :line_referential, :parent private def group_of_line_params params.require(:group_of_line).permit( :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :lines, :registration_number, :line_tokens) end - + end diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 50d8dcee3..8c14de06d 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -1,4 +1,6 @@ -class LinesController < ChouetteController +class LinesController < BreadcrumbController + include ApplicationHelper + defaults :resource_class => Chouette::Line respond_to :html respond_to :xml @@ -6,7 +8,7 @@ class LinesController < ChouetteController respond_to :kml, :only => :show respond_to :js, :only => :index - belongs_to :referential + belongs_to :line_referential def index index! do |format| @@ -57,7 +59,7 @@ class LinesController < ChouetteController end def filtered_lines - referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } } + line_referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } } end def collection @@ -76,10 +78,12 @@ class LinesController < ChouetteController params[:q]["group_of_lines_id_blank"] = "1" end - @q = referential.lines.search(params[:q]) + @q = line_referential.lines.search(params[:q]) @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company]) end + alias_method :line_referential, :parent + private def line_params diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e40093da9..0aa106028 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,7 +15,7 @@ module ApplicationHelper end def format_restriction_for_locales(referential) - if referential.data_format.blank? + if !referential.respond_to?(:data_format) or referential.data_format.blank? "" else "."+referential.data_format diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 69494321b..3c595f86b 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -1,3 +1,4 @@ +# coding: utf-8 module BreadcrumbHelper def build_breadcrumb(action) @@ -72,8 +73,8 @@ module BreadcrumbHelper def group_of_line_breadcrumb(action) referential_breadcrumb - add_breadcrumb Chouette::GroupOfLine.model_name.human(:count => 2), referential_group_of_lines_path(@referential) unless action == :index - add_breadcrumb breadcrumb_label(@group_of_line), referential_group_of_line_path(@referential, @group_of_line),:title => breadcrumb_tooltip(@group_of_line) if action == :edit + add_breadcrumb Chouette::GroupOfLine.model_name.human(:count => 2), line_referential_group_of_lines_path(@line_referential) unless action == :index + add_breadcrumb breadcrumb_label(@group_of_line), line_referential_group_of_line_path(@line_referential, @group_of_line),:title => breadcrumb_tooltip(@group_of_line) if action == :edit end def stop_area_breadcrumb(action) @@ -123,8 +124,8 @@ module BreadcrumbHelper def line_breadcrumb(action) referential_breadcrumb - add_breadcrumb Chouette::Line.model_name.human(:count => 2), referential_lines_path(@referential) unless action == :index - add_breadcrumb breadcrumb_label(@line), referential_line_path(@referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit + add_breadcrumb Chouette::Line.model_name.human(:count => 2), line_referential_lines_path(@line.line_referential) unless action == :index + add_breadcrumb breadcrumb_label(@line), line_referential_line_path(@line.line_referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit end def route_breadcrumb(action) diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index 8d79bfe0b..1acde11ff 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -10,7 +10,7 @@ class LineMap < ApplicationMap def customize_map(map, page) page << map.add_layer(kml_layer(line, :styleMap => Design::LineStyleMap.new( :style => line_style).style_map)) - page.assign "stop_areas_layer", kml_layer([line.referential, line], :styleMap => Design::StopAreasStyleMap.new(helpers).style_map) + page.assign "stop_areas_layer", kml_layer([line.line_referential, line], :styleMap => Design::StopAreasStyleMap.new(helpers).style_map) page << map.add_layer(:stop_areas_layer) diff --git a/app/models/chouette/group_of_line.rb b/app/models/chouette/group_of_line.rb index 9443a34e5..0b91f3442 100644 --- a/app/models/chouette/group_of_line.rb +++ b/app/models/chouette/group_of_line.rb @@ -1,5 +1,8 @@ -class Chouette::GroupOfLine < Chouette::TridentActiveRecord +class Chouette::GroupOfLine < Chouette::ActiveRecord + include DefaultAttributesSupport include GroupOfLineRestrictions + include LineReferentialSupport + # FIXME http://jira.codehaus.org/browse/JRUBY-6358 self.primary_key = "id" @@ -26,4 +29,3 @@ class Chouette::GroupOfLine < Chouette::TridentActiveRecord end end - diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index b1e9940d3..ddd6fc37d 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -1,5 +1,9 @@ -class Chouette::Line < Chouette::TridentActiveRecord +class Chouette::Line < Chouette::ActiveRecord + include DefaultAttributesSupport include LineRestrictions + + include LineReferentialSupport + # FIXME http://jira.codehaus.org/browse/JRUBY-6358 self.primary_key = "id" diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index 84ea47693..588014fff 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -15,7 +15,6 @@ class Chouette::StopArea < Chouette::TridentActiveRecord has_and_belongs_to_many :routing_stops, :class_name => 'Chouette::StopArea', :foreign_key => "parent_id", :association_foreign_key => "child_id", :join_table => "stop_areas_stop_areas", :order => "stop_areas.name" belongs_to :stop_area_referential - belongs_to :line_referential validates_presence_of :stop_area_referential_id acts_as_tree :foreign_key => 'parent_id',:order => "name" diff --git a/app/models/chouette/trident_active_record.rb b/app/models/chouette/trident_active_record.rb index 225d7bb4b..cf7a59c0c 100644 --- a/app/models/chouette/trident_active_record.rb +++ b/app/models/chouette/trident_active_record.rb @@ -1,141 +1,19 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord - before_validation :prepare_auto_columns - after_validation :reset_auto_columns - - after_save :build_objectid + include DefaultAttributesSupport - self.abstract_class = true - # - # triggers to generate objectId and objectVersion - # TODO setting prefix in referential object - - def self.object_id_key - model_name - end + self.abstract_class = true - def referential - @referential ||= Referential.where(:slug => Apartment::Tenant.current).first! - end - - def hub_restricted? - referential.data_format == "hub" - end - - def prefix - self.referential.prefix - end - - def prepare_auto_columns - # logger.info 'calling before_validation' - # logger.info 'start before_validation : '+self.objectid.to_s - if self.objectid.nil? || self.objectid.blank? - # if empty, generate a pending objectid which will be completed after creation - if self.id.nil? - self.objectid = "#{prefix}:#{self.class.object_id_key}:__pending_id__#{rand(1000)}" - else - self.objectid = "#{prefix}:#{self.class.object_id_key}:#{self.id}" - fix_uniq_objectid - end - elsif not self.objectid.include? ':' - # if one token : technical token : completed by prefix and key - self.objectid = "#{prefix}:#{self.class.object_id_key}:#{self.objectid}" - end - # logger.info 'end before_validation : '+self.objectid - # initialize or update version - if self.object_version.nil? - self.object_version = 1 - else - self.object_version += 1 - end - self.creation_time = Time.now - self.creator_id = 'chouette' - end - - def reset_auto_columns - clean_object_id unless self.errors.nil? || self.errors.empty? - end - - def clean_object_id - if self.objectid.include?("__pending_id__") - self.objectid=nil - end - end - - def fix_uniq_objectid - base_objectid = self.objectid.rpartition(":").first - self.objectid = "#{base_objectid}:#{self.id}" - if !self.valid? - base_objectid="#{self.objectid}_" - cnt=1 - while !self.valid? - self.objectid = "#{base_objectid}#{cnt}" - cnt += 1 - end - end - - end - - def build_objectid - #logger.info 'start after_create : '+self.objectid - if self.objectid.include? ':__pending_id__' - fix_uniq_objectid - self.update_attributes( :objectid => self.objectid, :object_version => (self.object_version - 1) ) - end - #logger.info 'end after_create : '+self.objectid - end - - validates_presence_of :objectid - validates_uniqueness_of :objectid - validates_numericality_of :object_version - validate :objectid_format_compliance - - def objectid_format_compliance - if !self.objectid.valid? - #errors.add(:objectid, "is not a valid ObjectId object") - errors.add(:objectid,I18n.t("activerecord.errors.models.trident.invalid_object_id",:type => self.class.object_id_key)) -# else -# unless self.objectid.object_type==self.class.object_id_key -# errors.add(:objectid,I18n.t("activerecord.errors.models.trident.invalid_object_id_type",:type => self.class.object_id_key)) -# end - end - end - - def uniq_objectid - i = 0 - baseobjectid = self.objectid - while self.class.exists?(:objectid => self.objectid) - i += 1 - self.objectid = baseobjectid+"_"+i.to_s - end + def referential + @referential ||= Referential.where(:slug => Apartment::Tenant.current).first! end - def self.model_name - ActiveModel::Name.new self, Chouette, self.name.demodulize + def hub_restricted? + referential.data_format == "hub" end - def objectid - Chouette::ObjectId.new read_attribute(:objectid) + def prefix + self.referential.prefix end -# def version -# self.object_version -# end - -# def version=(version) -# self.object_version = version -# end - - before_validation :default_values, :on => :create - def default_values - self.object_version ||= 1 - end - - def timestamp_attributes_for_update #:nodoc: - [:creation_time] - end - - def timestamp_attributes_for_create #:nodoc: - [:creation_time] - end end diff --git a/app/models/concerns/default_attributes_support.rb b/app/models/concerns/default_attributes_support.rb new file mode 100644 index 000000000..ba5611fe3 --- /dev/null +++ b/app/models/concerns/default_attributes_support.rb @@ -0,0 +1,113 @@ +module DefaultAttributesSupport + extend ActiveSupport::Concern + + included do + before_validation :prepare_auto_columns + after_validation :reset_auto_columns + + after_save :build_objectid + + validates_presence_of :objectid + validates_uniqueness_of :objectid + validates_numericality_of :object_version + validate :objectid_format_compliance + + before_validation :default_values, :on => :create + end + + module ClassMethods + def object_id_key + model_name + end + + def model_name + ActiveModel::Name.new self, Chouette, self.name.demodulize + end + end + + def objectid + Chouette::ObjectId.new read_attribute(:objectid) + end + + def prepare_auto_columns + if objectid.nil? || objectid.blank? + if id.nil? + self.objectid = "#{prefix}:#{self.class.object_id_key}:__pending_id__#{rand(1000)}" + else + self.objectid = "#{prefix}:#{self.class.object_id_key}:#{id}" + fix_uniq_objectid + end + elsif not objectid.include? ':' + # if one token : technical token : completed by prefix and key + self.objectid = "#{prefix}:#{self.class.object_id_key}:#{objectid}" + end + + if object_version.nil? + self.object_version = 1 + else + self.object_version += 1 + end + self.creation_time = Time.now + self.creator_id = 'chouette' + end + + def reset_auto_columns + clean_object_id unless errors.nil? || errors.empty? + end + + def clean_object_id + if objectid.include?("__pending_id__") + self.objectid=nil + end + end + + def fix_uniq_objectid + base_objectid = objectid.rpartition(":").first + self.objectid = "#{base_objectid}:#{id}" + if !valid? + base_objectid="#{objectid}_" + cnt=1 + while !valid? + self.objectid = "#{base_objectid}#{cnt}" + cnt += 1 + end + end + + end + + def build_objectid + if objectid.include? ':__pending_id__' + fix_uniq_objectid + update_attributes( :objectid => objectid, :object_version => (object_version - 1) ) + end + end + + def objectid_format_compliance + if !objectid.valid? + errors.add :objectid, I18n.t("activerecord.errors.models.trident.invalid_object_id", type: self.class.object_id_key) + end + end + + def uniq_objectid + # OPTIMIZEME + i = 0 + baseobjectid = objectid + while self.class.exists?(:objectid => objectid) + i += 1 + self.objectid = baseobjectid+"_"+i.to_s + end + end + + def default_values + self.object_version ||= 1 + end + + def timestamp_attributes_for_update #:nodoc: + [:creation_time] + end + + def timestamp_attributes_for_create #:nodoc: + [:creation_time] + end + +end diff --git a/app/models/concerns/line_referential_support.rb b/app/models/concerns/line_referential_support.rb new file mode 100644 index 000000000..4ad437fed --- /dev/null +++ b/app/models/concerns/line_referential_support.rb @@ -0,0 +1,20 @@ +module LineReferentialSupport + extend ActiveSupport::Concern + + included do + belongs_to :line_referential + # validates_presence_of :line_referential_id + + alias_method :referential, :line_referential + end + + def hub_restricted? + false + end + + def prefix + # FIXME #825 + "dummy" + end + +end diff --git a/app/models/concerns/objectid_restrictions.rb b/app/models/concerns/objectid_restrictions.rb index 4e905bdc2..49cc772c7 100644 --- a/app/models/concerns/objectid_restrictions.rb +++ b/app/models/concerns/objectid_restrictions.rb @@ -25,4 +25,3 @@ module ObjectidRestrictions likes.size.zero? || ( likes.size==1 && likes.first.id==self.id) end end - diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb index b5ba56d7b..9c6f324e8 100644 --- a/app/models/line_referential.rb +++ b/app/models/line_referential.rb @@ -2,6 +2,9 @@ class LineReferential < ActiveRecord::Base has_many :line_referential_memberships has_many :organisations, through: :line_referential_memberships + has_many :lines, class_name: 'Chouette::Line' + has_many :group_of_lines, class_name: 'Chouette::GroupOfLine' + def add_member(organisation, options = {}) attributes = options.merge organisation: organisation line_referential_memberships.build attributes diff --git a/app/views/group_of_lines/_form.erb b/app/views/group_of_lines/_form.erb index 0f92897ca..d8417466a 100644 --- a/app/views/group_of_lines/_form.erb +++ b/app/views/group_of_lines/_form.erb @@ -1,7 +1,7 @@ -<%= semantic_form_for [@referential, @group_of_line] do |form| %> +<%= semantic_form_for [@line_referential, @group_of_line] do |form| %> <%= form.inputs do %> - <%= form.input :name, :input_html => { :title => I18n.t("formtastic.titles#{format_restriction_for_locales(@referential)}.group_of_line.name") } %> - <%= form.input :registration_number, :input_html => { :title => I18n.t("formtastic.titles#{format_restriction_for_locales(@referential)}.group_of_line.registration_number") } %> + <%= form.input :name, :input_html => { :title => I18n.t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.group_of_line.name") } %> + <%= form.input :registration_number, :input_html => { :title => I18n.t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.group_of_line.registration_number") } %> <%= form.input :comment %> <%= form.input :objectid, :required => !@group_of_line.new_record?, :input_html => { :title => I18n.t("formtastic.titles#{format_restriction_for_locales(@referential)}.group_of_line.objectid") } %> <% end %> @@ -18,7 +18,7 @@ <script> $(function() { - $( "#group_of_line_line_tokens" ).tokenInput('<%= name_filter_referential_lines_path(@referential, :format => :json) %>', { + $( "#group_of_line_line_tokens" ).tokenInput('<%= name_filter_referential_lines_path(@line_referential, :format => :json) %>', { crossDomain: false, prePopulate: $('#line_tokens').data('pre'), minChars: 1, diff --git a/app/views/group_of_lines/_group_of_line.erb b/app/views/group_of_lines/_group_of_line.erb index 98a1e03d2..c88a3835b 100644 --- a/app/views/group_of_lines/_group_of_line.erb +++ b/app/views/group_of_lines/_group_of_line.erb @@ -1,24 +1,24 @@ <div id="index_item" class="panel panel-default"> <div class="panel-heading"> <div class="panel-title clearfix"> - <span class="pull-right"> - <%= link_to edit_referential_group_of_line_path(@referential, group_of_line), :class => "btn btn-default btn-sm" do %> + <span class="pull-right"> + <%= link_to edit_referential_group_of_line_path(@line_referential, group_of_line), :class => "btn btn-default btn-sm" do %> <span class="fa fa-pencil"></span> <% end if edit %> - <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, referential_group_of_line_path(@referential, group_of_line), :method => :delete, :data => {:confirm => t('group_of_lines.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %> + <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, line_referential_group_of_line_path(@line_referential, group_of_line), :method => :delete, :data => {:confirm => t('group_of_lines.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %> </span> <h5> - <%= link_to([@referential, group_of_line], :class => "preview", :title => "#{Chouette::GroupOfLine.model_name.human.capitalize} #{group_of_line.name}") do %> + <%= link_to([@line_referential, group_of_line], :class => "preview", :title => "#{Chouette::GroupOfLine.model_name.human.capitalize} #{group_of_line.name}") do %> <span class="name"> - <%= truncate(group_of_line.name, :length => 20) %> + <%= truncate(group_of_line.name, :length => 20) %> </span> <% end %> </h5> - </div> + </div> </div> <div class="panel-body"> <p> - <%= group_of_line.human_attribute_name('line_count') %> <%= group_of_line.lines.count %> + <%= group_of_line.human_attribute_name('line_count') %> <%= group_of_line.lines.count %> </p> </div> </div> diff --git a/app/views/group_of_lines/index.html.erb b/app/views/group_of_lines/index.html.erb index 2257096bd..0f34128f4 100644 --- a/app/views/group_of_lines/index.html.erb +++ b/app/views/group_of_lines/index.html.erb @@ -1,9 +1,9 @@ -<%= title_tag t('group_of_lines.index.title') %> +<%= title_tag t('group_of_lines.index.title') %> -<%= search_form_for @q, :url => referential_group_of_lines_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> +<%= search_form_for @q, :url => referential_group_of_lines_path(@line_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> <div class="panel panel-default"> - <div class="panel-heading"> - <div class="input-group col-md-12"> + <div class="panel-heading"> + <div class="input-group col-md-12"> <%= f.text_field :name_cont, :placeholder => "#{t('.name')}", :class => "form-control" %> <div class="input-group-btn"> <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button> @@ -20,7 +20,7 @@ <% content_for :sidebar do %> <ul class="actions"> - <li><%= link_to t('group_of_lines.actions.new'), new_referential_group_of_line_path(@referential), :class => "add" %></li> + <li><%= link_to t('group_of_lines.actions.new'), new_line_referential_group_of_line_path(@line_referential), :class => "add" %></li> <br> </ul> <% end %> diff --git a/app/views/group_of_lines/show.html.erb b/app/views/group_of_lines/show.html.erb index 3369f284d..557d8c82b 100644 --- a/app/views/group_of_lines/show.html.erb +++ b/app/views/group_of_lines/show.html.erb @@ -12,7 +12,7 @@ <%= @group_of_line.comment %> </p> </div> - + <p class="after_map" /> <h3 class="group_of_line_lines"><%= t('.lines') %></h3> <div class="lines_detail"> @@ -22,9 +22,9 @@ <% content_for :sidebar do %> <ul class="actions"> - <li><%= link_to t('group_of_lines.actions.new'), new_referential_group_of_line_path(@referential), :class => "add" %></li> - <li><%= link_to t('group_of_lines.actions.edit'), edit_referential_group_of_line_path(@referential, @group_of_line), :class => "edit" %></li> - <li><%= link_to t('group_of_lines.actions.destroy'), referential_group_of_line_path(@referential, @group_of_line), :method => :delete, :data => {:confirm => t('group_of_lines.actions.destroy_confirm')} , :class => "remove" %></li> + <li><%= link_to t('group_of_lines.actions.new'), new_line_referential_group_of_line_path(@line_referential), :class => "add" %></li> + <li><%= link_to t('group_of_lines.actions.edit'), edit_line_referential_group_of_line_path(@line_referential, @group_of_line), :class => "edit" %></li> + <li><%= link_to t('group_of_lines.actions.destroy'), line_referential_group_of_line_path(@line_referential, @group_of_line), :method => :delete, :data => {:confirm => t('group_of_lines.actions.destroy_confirm')} , :class => "remove" %></li> <br> </ul> <%= creation_tag(@group_of_line) %> diff --git a/app/views/lines/_form.erb b/app/views/lines/_form.erb index 442434d3b..c2af9d6b8 100644 --- a/app/views/lines/_form.erb +++ b/app/views/lines/_form.erb @@ -1,11 +1,11 @@ -<%= semantic_form_for [@referential, @line] do |form| %> +<%= semantic_form_for [@line_referential, @line] do |form| %> <%= form.inputs do %> <%= form.input :network, :as => :select, :collection => Chouette::Network.all, :include_blank => false %> <%= form.input :company, :as => :select, :collection => Chouette::Company.all, :include_blank => false%> - <%= form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.line.name") } %> + <%= form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.line.name") } %> <%= form.input :published_name %> - <%= form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.line.registration_number")} %> - <%= form.input :number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.line.number") } %> + <%= form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.line.registration_number")} %> + <%= form.input :number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.line.number") } %> <%= form.input :transport_mode, :as => :select, :collection => Chouette::Line.transport_modes, :include_blank => false, :member_label => Proc.new { |mode| t("transport_modes.label.#{mode}") } %> <%= form.input :color, :as => :string %> <%= form.input :text_color %> @@ -14,7 +14,7 @@ <%= form.input :mobility_restricted_suitability, :as => :select, :collection => [[@line.human_attribute_name("accessible"), true], [@line.human_attribute_name("not_accessible"), false]], :include_blank => true %> <%= form.input :flexible_service, :as => :select, :collection => [[@line.human_attribute_name("on_demaond_fs"), true], [@line.human_attribute_name("regular_fs"), false]], :include_blank => true %> <%= form.input :comment %> - <%= form.input :objectid, :required => !@line.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.line.objectid")} %> + <%= form.input :objectid, :required => !@line.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.line.objectid")} %> <%= form.input :group_of_line_tokens, :label => t('.group_of_lines'), :as => :text, :input_html => { :"data-pre" => ( @line.group_of_lines.map { |group_of_line| { :id => group_of_line.id, :name => group_of_line.name } } ).to_json } %> <div class="footnotes_block"> @@ -41,7 +41,7 @@ <script> $(function() { - $( "#line_group_of_line_tokens" ).tokenInput('<%= name_filter_referential_group_of_lines_path(@referential, :format => :json) %>', { + $( "#line_group_of_line_tokens" ).tokenInput('<%= name_filter_referential_group_of_lines_path(@line_referential, :format => :json) %>', { crossDomain: false, prePopulate: $('#group_of_line_tokens').data('pre'), minChars: 3, diff --git a/app/views/lines/_line.erb b/app/views/lines/_line.erb index 20bdb9563..bd3a79d0e 100644 --- a/app/views/lines/_line.erb +++ b/app/views/lines/_line.erb @@ -8,15 +8,15 @@ <% end %> </li> <li> - <%= link_to([@referential, line], class: 'preview', title: "#{Chouette::Line.model_name.human.capitalize} #{line.name}") do %> + <%= link_to([line.line_referential, line], class: 'preview', title: "#{Chouette::Line.model_name.human.capitalize} #{line.name}") do %> <h5 class="ce-LineBlock-header-title"><%= truncate(line.name, length: 24) %></h5> <% end %> </li> <li> - <%= link_to edit_referential_line_path(@referential, line), class: 'btn btn-default btn-sm' do %> + <%= link_to edit_line_referential_line_path(line.line_referential, line), class: 'btn btn-default btn-sm' do %> <span class="fa fa-pencil"></span> <% end if edit %> - <%= link_to referential_line_path(@referential, line), method: :delete, data: { confirm: t('lines.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do %> + <%= link_to line_referential_line_path(line.line_referential, line), method: :delete, data: { confirm: t('lines.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do %> <span class="fa fa-trash-o"></span> <% end if delete %> </li> @@ -25,24 +25,25 @@ <div class="panel-body"> <p> <% if line.network.nil? %> - <%= line.human_attribute_name('network') %> <%= t('lines.index.unset') %> + <%= line.human_attribute_name('network') %> <%= t('lines.index.unset') %> <% else %> - <%= line.human_attribute_name('network') %> <%= link_to_if line.network, line.network.name, referential_network_path(@referential, line.network), :title => "#{line.human_attribute_name('network')} #{line.network.name}" %> + <!-- FIXME #825 --> + <%= line.human_attribute_name('network') %> <%#= link_to_if line.network, line.network.name, line_referential_network_path(line.line_referential, line.network), :title => "#{line.human_attribute_name('network')} #{line.network.name}" %> <% end %> </p> <p> <% if line.company.nil? %> - <%= line.human_attribute_name('company') %> <%= t('lines.index.unset') %> + <%= line.human_attribute_name('company') %> <%= t('lines.index.unset') %> <% else %> - <%= line.human_attribute_name('company') %> <%= link_to_if( line.company, line.company.name, referential_company_path(@referential, line.company), :title => "#{line.human_attribute_name('company')} #{line.company.name}" ) %> + <%= line.human_attribute_name('company') %> <%#= link_to_if( line.company, line.company.name, line_referential_company_path(line.line_referential, line.company), :title => "#{line.human_attribute_name('company')} #{line.company.name}" ) %> <% end %> - </p> + </p> <p> - <% if line.group_of_lines.count == 0 %> + <% if line.group_of_lines.count == 0 %> <br><%# t('lines.form.no_group_of_line') %> <% elsif line.group_of_lines.count == 1 %> - <%= line.human_attribute_name('group_of_line') %> - <%= link_to_if( line.group_of_lines.first, line.group_of_lines.first.name, referential_group_of_line_path(@referential, line.group_of_lines.first), :title => "#{line.human_attribute_name('group_of_line')} #{line.group_of_lines.first.name}") %> + <%= line.human_attribute_name('group_of_line') %> + <%= link_to_if( line.group_of_lines.first, line.group_of_lines.first.name, line_referential_group_of_line_path(line.line_referential, line.group_of_lines.first), :title => "#{line.human_attribute_name('group_of_line')} #{line.group_of_lines.first.name}") %> <% else %> <%= t('lines.form.several_group_of_lines', :count => line.group_of_lines.count) %> <% end %> diff --git a/app/views/lines/index.html.erb b/app/views/lines/index.html.erb index ae0cbabf7..0995d0021 100644 --- a/app/views/lines/index.html.erb +++ b/app/views/lines/index.html.erb @@ -1,6 +1,6 @@ <%= title_tag t('lines.index.title') %> -<%= search_form_for @q, :url => referential_lines_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> +<%= search_form_for @q, :url => line_referential_lines_path(@line_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %> <div class="panel panel-default"> <div class="panel-heading"> <div class="input-group col-md-9"> @@ -16,9 +16,10 @@ <div id="advanced_search" class="panel-collapse collapse"> <div class="panel-body"> - <%= f.select(:network_id_eq, @referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), {include_blank: t('.all_networks')}, { :class => 'form-control' }) %> - <%= f.select(:company_id_eq, @referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), { include_blank: t('.all_companies')}, { :class => 'form-control' }) %> - <%= f.select(:group_of_lines_id_eq, @referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), {include_blank: t('.all_group_of_lines')}, { :class => 'form-control' }) %> + <!-- FIXME #825 --> + <%#= f.select(:network_id_eq, @line_referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), {include_blank: t('.all_networks')}, { :class => 'form-control' }) %> + <%#= f.select(:company_id_eq, @line_referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), { include_blank: t('.all_companies')}, { :class => 'form-control' }) %> + <%#= f.select(:group_of_lines_id_eq, @line_referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), {include_blank: t('.all_group_of_lines')}, { :class => 'form-control' }) %> </div> </div> </div> @@ -28,7 +29,7 @@ <% content_for :sidebar do %> <ul class="actions"> - <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> + <li><%= link_to t('lines.actions.new'), new_line_referential_line_path(@line_referential), :class => "add" %></li> </ul> <div id="multiple_selection_menu"> @@ -41,7 +42,7 @@ <a class="disable" href="#"><%= t(".multi_selection_disable") %></a> <ul class="actions"> - <%= link_to t(".delete_selected"), referential_lines_path(@referential), "data-multiple-method" => "delete", :class => "remove", "confirmation-text" => t("lines.actions.destroy_selection_confirm") %> + <%= link_to t(".delete_selected"), line_referential_lines_path(@line_referential), "data-multiple-method" => "delete", :class => "remove", "confirmation-text" => t("lines.actions.destroy_selection_confirm") %> </ul> <a class="select_all" href="#"><%= t(".select_all") %></a> | <a class="deselect_all" href="#"><%= t(".deselect_all") %></a> @@ -49,5 +50,3 @@ </div> <% end %> - - diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index 7cfbf8b23..8426319b6 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -13,14 +13,15 @@ <p> <label><%= t('lines.index.color') %>: </label> <label class="color" style='<%="#{number_style(@line)}"%>'><%= line_sticker(@line) %></label> - </p> + </p> <% end %> <p> <label><%= @line.human_attribute_name(:network) %>: </label> <% if @line.network.nil? %> - <%= t('lines.index.unset') %> + <%= t('lines.index.unset') %> <% else %> - <%= link_to @line.network.name, [@referential, @line.network] %> + <!-- FIXME #825 --> + <%#= link_to @line.network.name, [@referential, @line.network] %> <% end %> </p> <p> @@ -28,7 +29,8 @@ <% if @line.company.nil? %> <%= t('lines.index.unset') %> <% else %> - <%= link_to @line.company.name, [@referential, @line.company] %> + <!-- FIXME #825 --> + <%#= link_to @line.company.name, [@referential, @line.company] %> <% end %> </p> <p> @@ -69,7 +71,7 @@ <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 = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count) %> </p> <p> @@ -87,15 +89,15 @@ <% if @line.flexible_service.nil? %> (<%= @line.human_attribute_name("default_fs_msg") %>) <% end %> - : <%= @line.vehicle_journeys.count - - (@line.vehicle_journeys.where("flexible_service = ?", true).count + + : <%= @line.vehicle_journeys.count - + (@line.vehicle_journeys.where("flexible_service = ?", true).count + @line.vehicle_journeys.where("flexible_service = ?", false).count) %> </p> <p> <label><%= @line.human_attribute_name("footnotes") %>: </label> <ul> <% @line.footnotes.each do |footnote| %> - <li><%= footnote.code %> : <%= footnote.label %></li> + <li><%= footnote.code %> : <%= footnote.label %></li> <% end %> </ul> </p> @@ -114,7 +116,8 @@ <p class="after_map" /> <h3 class="routes"><%= t('.itineraries') %></h3> <div class="routes paginated_content"> - <%= paginated_content @routes, "routes/route" %> + <!-- FIXME #825 --> + <%#= paginated_content @routes, "routes/route" %> </div> <% if @line.group_of_lines.any? %> @@ -126,11 +129,12 @@ <% content_for :sidebar do %> <ul class="actions"> - <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> - <li><%= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), :class => "edit" %></li> - <li><%= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), :method => :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, :class => "remove" %></li> + <li><%= link_to t('lines.actions.new'), new_line_referential_line_path(@line_referential), :class => "add" %></li> + <li><%= link_to t('lines.actions.edit'), edit_line_referential_line_path(@line_referential, @line), :class => "edit" %></li> + <li><%= link_to t('lines.actions.destroy'), line_referential_line_path(@line_referential, @line), :method => :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, :class => "remove" %></li> <% if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2) %> - <li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li> + <!-- FIXME #825 --> + <li><%#= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li> <% end %> </ul> <%= creation_tag(@line) %> |
