diff options
| -rw-r--r-- | app/controllers/networks_controller.rb | 2 | ||||
| -rw-r--r-- | app/decorators/line_decorator.rb | 77 | ||||
| -rw-r--r-- | app/models/concerns/objectid_support.rb | 2 | ||||
| -rw-r--r-- | app/views/companies/_form.html.slim | 34 | ||||
| -rw-r--r-- | app/views/companies/edit.html.slim | 11 | ||||
| -rw-r--r-- | app/views/companies/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/companies/new.html.slim | 14 | ||||
| -rw-r--r-- | app/views/companies/show.html.slim | 2 | ||||
| -rw-r--r-- | app/views/lines/_form.html.slim | 63 | ||||
| -rw-r--r-- | app/views/lines/edit.html.slim | 11 | ||||
| -rw-r--r-- | app/views/lines/new.html.slim | 11 | ||||
| -rw-r--r-- | app/views/networks/_form.html.slim | 27 | ||||
| -rw-r--r-- | app/views/networks/edit.html.slim | 14 | ||||
| -rw-r--r-- | app/views/networks/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/networks/new.html.slim | 12 | ||||
| -rw-r--r-- | app/views/networks/show.html.slim | 4 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 234 | ||||
| -rw-r--r-- | app/views/stop_areas/edit.html.slim | 11 | ||||
| -rw-r--r-- | app/views/stop_areas/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/new.html.slim | 11 | ||||
| -rw-r--r-- | config/initializers/simple_form_bootstrap.rb | 11 |
21 files changed, 282 insertions, 275 deletions
diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index 98c840777..9d5e1bf0d 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -22,10 +22,12 @@ class NetworksController < InheritedResources::Base def new authorize resource_class + new! end def create authorize resource_class + create! end def index diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index d465f9321..d86916873 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -1,45 +1,54 @@ - class LineDecorator < Draper::Decorator - decorates Chouette::Line +class LineDecorator < Draper::Decorator + decorates Chouette::Line - delegate_all + delegate_all - # Requires: - # context: { - # line_referential: , - # current_organisation: - # } - def action_links - links = [] + # Requires: + # context: { + # line_referential: , + # current_organisation: + # } + def action_links + links = [] + links << Link.new( + content: h.t('lines.actions.show_network'), + href: [context[:line_referential], object.network] + ) + + links << Link.new( + content: h.t('lines.actions.show_company'), + href: [context[:line_referential], object.company] + ) + if h.policy(Chouette::Line).create? && + context[:line_referential].organisations.include?( + context[:current_organisation] + ) links << Link.new( - content: h.t('lines.actions.show_network'), - href: [context[:line_referential], object.network] + content: h.t('lines.actions.edit'), + href: h.edit_line_referential_line_path(context[:line_referential], object.id) ) + end + if h.policy(Chouette::Line).create? && + context[:line_referential].organisations.include?( + context[:current_organisation] + ) links << Link.new( - content: h.t('lines.actions.show_company'), - href: [context[:line_referential], object.company] + content: h.t('lines.actions.new'), + href: h.new_line_referential_line_path(context[:line_referential]) ) + end - if h.policy(Chouette::Line).create? && - context[:line_referential].organisations.include?( - context[:current_organisation] - ) - links << Link.new( - content: h.t('lines.actions.new'), - href: h.new_line_referential_line_path(context[:line_referential]) - ) - end - - if h.policy(object).destroy? - links << Link.new( - content: h.destroy_link_content('lines.actions.destroy_confirm'), - href: h.line_referential_line_path(context[:line_referential], object), - method: :delete, - data: { confirm: h.t('lines.actions.destroy_confirm') } - ) - end - - links + if h.policy(object).destroy? + links << Link.new( + content: h.destroy_link_content('lines.actions.destroy'), + href: h.line_referential_line_path(context[:line_referential], object), + method: :delete, + data: {confirm: h.t('lines.actions.destroy_confirm')} + ) end + + links end +end diff --git a/app/models/concerns/objectid_support.rb b/app/models/concerns/objectid_support.rb index 97af9019c..f20723f63 100644 --- a/app/models/concerns/objectid_support.rb +++ b/app/models/concerns/objectid_support.rb @@ -35,4 +35,4 @@ module ObjectidSupport self.referential.objectid_format end end -end
\ No newline at end of file +end diff --git a/app/views/companies/_form.html.slim b/app/views/companies/_form.html.slim index caf75bd8b..3979c5800 100644 --- a/app/views/companies/_form.html.slim +++ b/app/views/companies/_form.html.slim @@ -1,18 +1,18 @@ -= semantic_form_for [@line_referential, @company] do |form| - = form.inputs do - = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.company.name") } - = form.input :short_name - = form.input :organizational_unit - = form.input :operating_department_name - = form.input :code - = form.input :phone, as: :phone - = form.input :fax, as: :phone - = form.input :email, as: :email - = form.input :time_zone, include_blank: true - = form.input :url - = form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.company.registration_number") } - = form.input :objectid, :required => !@company.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.company.objectid") } += simple_form_for [@line_referential, @company], html: {class: 'form-horizontal', id: 'company_form'}, wrapper: :horizontal_form do |f| + .row + .col-lg-12 + = f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.company.name")} + = f.input :short_name + = f.input :organizational_unit + = f.input :operating_department_name + = f.input :code + = f.input :phone + = f.input :fax + = f.input :email, as: :email + = f.input :time_zone, include_blank: true + = f.input :url + = f.input :registration_number, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.company.registration_number")} - = form.actions do - = form.action :submit, as: :button - = form.action :cancel, as: :link
\ No newline at end of file + .separator + + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'company_form' diff --git a/app/views/companies/edit.html.slim b/app/views/companies/edit.html.slim index 2f4c559b9..a20efeb46 100644 --- a/app/views/companies/edit.html.slim +++ b/app/views/companies/edit.html.slim @@ -1,4 +1,11 @@ - breadcrumb :company, @company +/ PageHeader += pageheader 'jeux-de-controle', + t('companies.edit.title', company: @company.name) -= title_tag t('companies.edit.title', company: @company.name) -= render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form' diff --git a/app/views/companies/index.html.slim b/app/views/companies/index.html.slim index ba061f505..8fcadc370 100644 --- a/app/views/companies/index.html.slim +++ b/app/views/companies/index.html.slim @@ -27,7 +27,7 @@ [ \ TableBuilderHelper::Column.new( \ name: 'Oid', \ - attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \ + attribute: Proc.new { |n| n.try(:get_objectid).try(:short_id) }, \ sortable: false \ ), \ TableBuilderHelper::Column.new( \ diff --git a/app/views/companies/new.html.slim b/app/views/companies/new.html.slim index 68c0f76c3..d80916ed9 100644 --- a/app/views/companies/new.html.slim +++ b/app/views/companies/new.html.slim @@ -1,2 +1,12 @@ -= title_tag t('companies.new.title') -= render 'form' +- breadcrumb :lines, @line_referential +/ PageHeader += pageheader 'jeux-de-controle', + t('companies.new.title') + + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form' diff --git a/app/views/companies/show.html.slim b/app/views/companies/show.html.slim index 668226938..eebb4a57c 100644 --- a/app/views/companies/show.html.slim +++ b/app/views/companies/show.html.slim @@ -23,7 +23,7 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { 'ID Codif' => @company.try(:objectid).try(:local_id), + { 'ID Codif' => @company.try(:get_objectid).try(:short_id), Chouette::Company.human_attribute_name(:phone) => @company.phone, Chouette::Company.human_attribute_name(:email) => @company.email, Chouette::Company.human_attribute_name(:url) => @company.url } diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim index d7b5a65ed..4952b72ff 100644 --- a/app/views/lines/_form.html.slim +++ b/app/views/lines/_form.html.slim @@ -1,45 +1,22 @@ -= 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(@line_referential)}.line.name") } - / = form.input :published_name - / = 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, include_blank: false - / = form.input :color, as: :string - / = form.input :text_color - / = form.input :stable_id - / = form.input :url - / = 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(@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 } += simple_form_for [@line_referential, @line], html: {class: 'form-horizontal', id: 'lines_form'}, wrapper: :horizontal_form do |f| + .row + .col-lg-12 + = f.input :name + = f.input :network_id, as: :select, :collection => @line_referential.networks, include_blank: false + = f.input :company_id, as: :select, :collection => @line_referential.companies, include_blank: false + = f.input :published_name + = f.input :registration_number + = f.input :number + = f.input :transport_mode, as: :select, collection: Chouette::Line.sorted_transport_modes, label: t('activerecord.attributes.compliance_control_blocks.transport_mode'), label_method: lambda {|t| ("<span>" + t("enumerize.transport_mode.#{t}") + "</span>").html_safe}, required: true, :include_blank => false + = f.input :transport_submode, as: :select, collection: Chouette::Line.sorted_transport_submodes, label: t('activerecord.attributes.compliance_control_blocks.transport_submode'), label_method: lambda {|t| ("<span>" + t("enumerize.transport_submode.#{t}") + "</span>").html_safe}, :include_blank => true + = f.input :color, as: :string + = f.input :text_color + = f.input :stable_id + = f.input :url + = f.input :mobility_restricted_suitability, as: :select, :collection => [[@line.human_attribute_name("accessible"), true], [@line.human_attribute_name("not_accessible"), false]], :include_blank => true + = f.input :flexible_service, as: :select, :collection => [[@line.human_attribute_name("on_demaond_fs"), true], [@line.human_attribute_name("regular_fs"), false]], :include_blank => true + = f.input :comment + .separator - .footnotes_block - h3 = t("footnotes.index.title") + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'lines_form' - #footnotes - = form.semantic_fields_for :footnotes do |f| - = render "footnotes/footnote_fields", :f => f - - .add_footnote - = link_to_add_association t("footnotes.actions.add_footnote"), form, :footnotes , :partial => "footnotes/footnote_fields", :"data-association-insertion-method" => "append", :"data-association-insertion-node" => "div#footnotes", class: 'add' - - = form.actions do - = form.action :submit, as: :button - = form.action :cancel, as: :link - -javascript: - $(function() { - $("#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, - preventDuplicates: true, - hintText: "#{I18n.t('search_hint')}", - noResultsText: "#{I18n.t('no_result_text')}", - searchingText: "#{I18n.t('searching_term')}" - }); - }); diff --git a/app/views/lines/edit.html.slim b/app/views/lines/edit.html.slim index 3c2eee03f..4a904d16a 100644 --- a/app/views/lines/edit.html.slim +++ b/app/views/lines/edit.html.slim @@ -1,5 +1,12 @@ - breadcrumb :line, @line -= title_tag t('lines.edit.title', line: @line.name) +/ PageHeader += pageheader 'jeux-de-controle', + t('lines.edit.title', line: @line.name) -= render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form' diff --git a/app/views/lines/new.html.slim b/app/views/lines/new.html.slim index f09a4b4aa..00872dcfb 100644 --- a/app/views/lines/new.html.slim +++ b/app/views/lines/new.html.slim @@ -1,5 +1,12 @@ - breadcrumb :lines, @line_referential +/ PageHeader += pageheader 'jeux-de-controle', + t('lines.new.title') -= title_tag t('lines.new.title') -= render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form'
\ No newline at end of file diff --git a/app/views/networks/_form.html.slim b/app/views/networks/_form.html.slim index 7b048edc9..6ee2a4512 100644 --- a/app/views/networks/_form.html.slim +++ b/app/views/networks/_form.html.slim @@ -1,15 +1,14 @@ -= semantic_form_for [@line_referential, @network] do |form| - = form.inputs do - = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.network.name")} - = form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.network.registration_number")} - = form.input :comment - = form.input :version_date, as: :date_picker - = form.input :description - = form.input :source_name - = form.input :source_type_name, as: :select, :collection => source_type_name_label_pairs, :include_blank => true - = form.input :source_identifier - = form.input :objectid, :required => !@network.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.network.objectid")} += simple_form_for [@line_referential, @network], html: {class: 'form-horizontal', id: 'network_form'}, wrapper: :horizontal_form do |f| + .row + .col-lg-12 + = f.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.network.name")} + = f.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@line_referential)}.network.registration_number")} + = f.input :comment + = f.input :version_date, :label_html => { :class => 'string optional col-sm-4 col-xs-5 control-label' }, :wrapper => :multi_select_inline + = f.input :description + = f.input :source_name + = f.input :source_type_name, as: :select, :collection => source_type_name_label_pairs, :include_blank => true + = f.input :source_identifier + .separator - = form.actions do - = form.action :submit, as: :button - = form.action :cancel, as: :link + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'network_form' diff --git a/app/views/networks/edit.html.slim b/app/views/networks/edit.html.slim index 2d511e15d..dbb8bada9 100644 --- a/app/views/networks/edit.html.slim +++ b/app/views/networks/edit.html.slim @@ -1,4 +1,12 @@ -- breadcrumb :network, @network -= title_tag t('networks.edit.title', network: @network.name) +- breadcrumb :networks, @network +/ PageHeader += pageheader 'jeux-de-controle', + t('networks.edit.title', network: @network.name) -= render 'form' + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form' diff --git a/app/views/networks/index.html.slim b/app/views/networks/index.html.slim index e498ea35f..5829cf649 100644 --- a/app/views/networks/index.html.slim +++ b/app/views/networks/index.html.slim @@ -27,7 +27,7 @@ [ \ TableBuilderHelper::Column.new( \ name: 'Oid', \ - attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \ + attribute: Proc.new { |n| n.try(:get_objectid).try(:short_id) }, \ sortable: false \ ), TableBuilderHelper::Column.new( \ diff --git a/app/views/networks/new.html.slim b/app/views/networks/new.html.slim index cf04ab03f..d014fb35a 100644 --- a/app/views/networks/new.html.slim +++ b/app/views/networks/new.html.slim @@ -1,4 +1,12 @@ - breadcrumb :networks, @line_referential -= title_tag t('networks.new.title') +/ PageHeader += pageheader 'jeux-de-controle', + t('networks.new.title') -= render 'form' + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form' diff --git a/app/views/networks/show.html.slim b/app/views/networks/show.html.slim index 9b2a0dbf8..e45ed46ae 100644 --- a/app/views/networks/show.html.slim +++ b/app/views/networks/show.html.slim @@ -1,4 +1,4 @@ -- breadcrumb :network, @network +- breadcrumb :networks, @network / PageHeader = pageheader 'reseau', @network.name, @@ -21,4 +21,4 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { 'ID Codif' => @network.try(:objectid).try(:local_id) } + { 'ID Codif' => @network.try(:get_objectid).try(:short_id) } diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 546143393..b055113a9 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -1,153 +1,101 @@ -= semantic_form_for [@stop_area_referential, @stop_area] do |form| +/= semantic_form_for [@stop_area_referential, @stop_area] do |form| +/ .row +/ .container-fluid +/ - if !manage_itl && @map +/ = @map.to_html +/ +/ = form.inputs do +/ = form.input :id, as: :hidden +/ = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} +/ = form.input :stop_area_type, as: :select, :input_html => { :disabled => !@stop_area.new_record? }, :collection => Chouette::StopArea.area_type.options, :include_blank => false +/ +/ .location_info +/ h3 = t("stop_areas.stop_area.localisation") +/ +/ #prefetch +/ label = t('.geolocalize') +/ input.typeahead.form-control.input-lg maxlength="255" type="text" placeholder="#{t('.address')}" +/ +/ - unless @stop_area.projection.blank? or @stop_area.projection_type_label.empty? +/ = form.input :projection_xy, :label => t("activerecord.attributes.stop_area.projection_xy", :projection => @referential.projection_type_label), :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.projection_xy")} +/ +/ = form.input :coordinates, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")} +/ = form.input :street_name +/ = form.input :country_code, required: format_restriction_for_locales(@referential) == '.hub' +/ = form.input :zip_code, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} +/ = form.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")} +/ +/ .stop_areas.stop_area.general_info +/ h3 = t("stop_areas.stop_area.general") +/ +/ = form.inputs do +/ = form.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} +/ = form.input :fare_code, as: :number +/ = form.input :nearest_topic_name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} +/ = form.input :comment, as: :text, :input_html => { :rows => 5, :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.comment") } +/ = form.input :time_zone, :include_blank => true +/ = form.input :url +/ +/ .pmr_info +/ h3 = t("stop_areas.stop_area.accessibility") +/ = form.inputs do +/ - if !manage_itl +/ = form.input :mobility_restricted_suitability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true +/ = form.input :stairs_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true +/ = form.input :lift_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true +/ +/ = form.actions do +/ = form.action :submit, as: :button +/ = form.action :cancel, as: :link + + += simple_form_for [@stop_area_referential, @stop_area], html: {class: 'form-horizontal', id: 'stop_area_form'}, wrapper: :horizontal_form do |f| .row - .container-fluid + .col-lg-12 - if !manage_itl && @map - = @map.to_html - - = form.inputs do - = form.input :id, as: :hidden - = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} - = form.input :stop_area_type, as: :select, :input_html => { :disabled => !@stop_area.new_record? }, :collection => Chouette::StopArea.area_type.options, :include_blank => false + /= @map.to_html + = f.input :id, as: :hidden + = f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} + = f.input :area_type, as: :select, :input_html => {:disabled => !@stop_area.new_record?}, :collection => Chouette::StopArea.area_type.values, :include_blank => false + = f.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} + = f.input :fare_code + = f.input :nearest_topic_name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} + = f.input :comment, as: :text, :input_html => {:rows => 5, :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.comment")} + = f.input :time_zone, :include_blank => true + = f.input :url .location_info h3 = t("stop_areas.stop_area.localisation") - #prefetch label = t('.geolocalize') input.typeahead.form-control.input-lg maxlength="255" type="text" placeholder="#{t('.address')}" - unless @stop_area.projection.blank? or @stop_area.projection_type_label.empty? - = form.input :projection_xy, :label => t("activerecord.attributes.stop_area.projection_xy", :projection => @referential.projection_type_label), :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.projection_xy")} - - = form.input :coordinates, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")} - = form.input :street_name - = form.input :country_code, required: format_restriction_for_locales(@referential) == '.hub' - = form.input :zip_code, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} - = form.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")} - - .stop_areas.stop_area.general_info - h3 = t("stop_areas.stop_area.general") - - = form.inputs do - = form.input :objectid, :required => !@stop_area.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.objectid")} - = form.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} - = form.input :fare_code, as: :number - = form.input :nearest_topic_name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} - = form.input :comment, as: :text, :input_html => { :rows => 5, :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.comment") } - = form.input :time_zone, :include_blank => true - = form.input :url - - .pmr_info - h3 = t("stop_areas.stop_area.accessibility") - = form.inputs do - - if !manage_itl - = form.input :mobility_restricted_suitability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true - = form.input :stairs_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true - = form.input :lift_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true - - = form.actions do - = form.action :submit, as: :button - = form.action :cancel, as: :link - -javascript: - $(document).ready(function() { - var address_display = function( address ) { - var name = ""; - if ( address.house_number) { - name += address.house_number+" "; - } - name += address.road+", "; - if ( address.suburb) { - name += address.suburb+", "; - } - if ( address.postcode) { - name += address.postcode+" "; - } - if ( address.city) { - name += address.city; - } else if ( address.village) { - name += address.village; - } else if ( address.town) { - name += address.town; - } else if ( address.county ) { - name += address.county; - } else if ( address.country ) { - name += address.country; - } - - - return name; - }; - var filtering = function(list) { - // update map view - removeAddress(); - - var selection = $.grep( list, function(item) { - return (item.type == "house" || item.type == "residential" || - item.type == "tertiary" || item.type == "primary" || - item.type == "secondary") && item.address.road ; - }); - return $.map( selection, function( d) { - var city = ""; - if ( d.address.city) { - city = d.address.city; - } else if ( d.address.town) { - city = d.address.town; - } else if ( d.address.village) { - city = d.address.village; - } - return { postcode: d.address.postcode, - road: d.address.road, - lon: d.lon, lat: d.lat, - suburb: d.address.suburb, - city: city, - postcode: d.address.postcode, - the_key: address_display( d.address)}; - }); - }; - - var addressesEngine = new Bloodhound({ - datumTokenizer: function(d) { - return Bloodhound.tokenizers.whitespace(d.id+" : "+d.road); - }, - queryTokenizer: function(d) { - return Bloodhound.tokenizers.whitespace(d.id+" :: "+d.road); - }, - limit: 10, - remote: { - url: 'http://nominatim.openstreetmap.org/search?q=%QUERY&format=json&addressdetails=1&bounded=1&viewbox='+ - // FIXME #821 - //= @stop_area_referential.viewbox_left_top_right_bottom - filter: filtering, - } - }); - - // kicks off the loading/processing of `local` and `prefetch` - var promise = addressesEngine.initialize(); - - // passing in `null` for the `options` arguments will result in the default - // options being used - $('#prefetch .typeahead').typeahead( - { - hint: true, - highlight: true, - minLength: 1 - }, - { - name: 'addresses', - displayKey: 'the_key', - source: addressesEngine.ttAdapter(), - } - ); - - $('.typeahead').on('typeahead:selected', function($e, datum) { - // update map view - addAddress( datum.lon, datum.lat, datum.road); - // update form fields - <% if @stop_area.new_record? %> - $('input[name="stop_area[street_name]"]').val(datum.road); - $('input[name="stop_area[zip_code]"]').val(datum.postcode); - $('input[name="stop_area[city_name]"]').val(datum.city); - <% end %> - }) - }); + = f.input :projection_xy, :label => t("activerecord.attributes.stop_area.projection_xy", :projection => @referential.projection_type_label), :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.projection_xy")} + + = f.input :coordinates, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")}, required: true + = f.input :street_name + /= f.input :country_code, required: format_restriction_for_locales(@referential) == '.hub' + = f.input :zip_code, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")} + = f.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")} + + .stop_areas.stop_area.general_info + h3 = t("stop_areas.stop_area.general") + + = f.input :registration_number, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number")} + = f.input :fare_code + = f.input :nearest_topic_name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.nearest_topic_name")} + = f.input :comment, as: :text, :input_html => {:rows => 5, :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.comment")} + = f.input :time_zone, :include_blank => true + = f.input :url + + .pmr_info + h3 = t("stop_areas.stop_area.accessibility") + - if !manage_itl + = f.input :mobility_restricted_suitability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true + = f.input :stairs_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true + = f.input :lift_availability, as: :select, :collection => [[t("true"), true], [t("false"), false]], :include_blank => true + + .separator + + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'stop_area_form' diff --git a/app/views/stop_areas/edit.html.slim b/app/views/stop_areas/edit.html.slim index 8005f5a08..3ffb53dec 100644 --- a/app/views/stop_areas/edit.html.slim +++ b/app/views/stop_areas/edit.html.slim @@ -1,4 +1,11 @@ - breadcrumb :stop_area, @stop_area_referential, @stop_area -= title_tag t('stop_areas.edit.title', stop_area: @stop_area.name ) +/ PageHeader += pageheader 'jeux-de-controle', + t('stop_areas.edit.title', stop_area: @stop_area.name ) -== render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form'
\ No newline at end of file diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index 4e880f7a3..6bffbd1a0 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -12,7 +12,7 @@ - if params[:q].present? or @stop_areas.any? .row .col-lg-12 - = render 'filters' + = render 'filters' - if @stop_areas.any? .row diff --git a/app/views/stop_areas/new.html.slim b/app/views/stop_areas/new.html.slim index e0c5b7a61..10e33d5cc 100644 --- a/app/views/stop_areas/new.html.slim +++ b/app/views/stop_areas/new.html.slim @@ -1,4 +1,11 @@ - breadcrumb :stop_areas, @stop_area_referential -= title_tag t('stop_areas.new.title') +/ PageHeader += pageheader 'jeux-de-controle', + t('stop_areas.new.title') -== render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = render 'form'
\ No newline at end of file diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb index d90ea6398..4b9bd320d 100644 --- a/config/initializers/simple_form_bootstrap.rb +++ b/config/initializers/simple_form_bootstrap.rb @@ -132,6 +132,17 @@ SimpleForm.setup do |config| ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' } end end + + config.wrappers :multi_select_inline, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + b.use :label, class: 'control-label' + b.wrapper tag: 'div', class: 'form-inline col-sm-8 col-xs-7' do |ba| + ba.use :input, class: 'form-control' + ba.use :error, wrap_with: {tag: 'span', class: 'help-block small'} + ba.use :hint, wrap_with: {tag: 'p', class: 'help-block small'} + end + end # Wrappers for forms and inputs using the Bootstrap toolkit. # Check the Bootstrap docs (http://getbootstrap.com) # to learn about the different styles for forms and inputs, |
