aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/networks_controller.rb22
-rw-r--r--app/controllers/referential_networks_controller.rb54
-rw-r--r--app/helpers/breadcrumb_helper.rb38
-rw-r--r--app/models/line_referential.rb1
-rw-r--r--app/models/referential.rb5
-rw-r--r--app/views/line_referentials/show.html.slim12
-rw-r--r--app/views/networks/_form.html.slim6
-rw-r--r--app/views/networks/_network.html.slim6
-rw-r--r--app/views/networks/index.html.slim4
-rw-r--r--app/views/networks/show.html.slim8
-rw-r--r--app/views/networks/show.kml.slim4
-rw-r--r--app/views/referential_networks/_form.html.slim15
-rw-r--r--app/views/referential_networks/_network.html.slim14
-rw-r--r--app/views/referential_networks/_networks.html.slim9
-rw-r--r--app/views/referential_networks/edit.html.slim3
-rw-r--r--app/views/referential_networks/index.html.slim23
-rw-r--r--app/views/referential_networks/index.js.slim1
-rw-r--r--app/views/referential_networks/new.html.slim3
-rw-r--r--app/views/referential_networks/show.html.slim47
-rw-r--r--app/views/referential_networks/show.kml.slim10
20 files changed, 244 insertions, 41 deletions
diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb
index 239f022b3..beced7e55 100644
--- a/app/controllers/networks_controller.rb
+++ b/app/controllers/networks_controller.rb
@@ -1,4 +1,6 @@
-class NetworksController < ChouetteController
+class NetworksController < BreadcrumbController
+ include ApplicationHelper
+
defaults :resource_class => Chouette::Network
respond_to :html
respond_to :xml
@@ -6,7 +8,7 @@ class NetworksController < ChouetteController
respond_to :kml, :only => :show
respond_to :js, :only => :index
- belongs_to :referential
+ belongs_to :line_referential
def show
@map = NetworkMap.new(resource).with_helpers(self)
@@ -15,7 +17,7 @@ class NetworksController < ChouetteController
end
end
- def index
+ def index
index! do |format|
format.html {
if collection.out_of_bounds?
@@ -23,26 +25,28 @@ class NetworksController < ChouetteController
end
}
build_breadcrumb :index
- end
+ end
end
protected
- def collection
- @q = referential.networks.search(params[:q])
+ def collection
+ @q = line_referential.networks.search(params[:q])
@networks ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
end
def resource_url(network = nil)
- referential_network_path(referential, network || resource)
+ line_referential_network_path(line_referential, network || resource)
end
def collection_url
- referential_networks_path(referential)
+ line_referential_networks_path(line_referential)
end
+ alias_method :line_referential, :parent
+
def network_params
params.require(:network).permit(:objectid, :object_version, :creation_time, :creator_id, :version_date, :description, :name, :registration_number, :source_name, :source_type_name, :source_identifier, :comment )
end
-
+
end
diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb
new file mode 100644
index 000000000..2d3f4ad6b
--- /dev/null
+++ b/app/controllers/referential_networks_controller.rb
@@ -0,0 +1,54 @@
+class ReferentialNetworksController < ChouetteController
+ defaults :resource_class => Chouette::Network, :collection_name => 'networks', :instance_name => 'network'
+ respond_to :html
+ respond_to :xml
+ respond_to :json
+ respond_to :kml, :only => :show
+ respond_to :js, :only => :index
+
+ belongs_to :referential, :parent_class => Referential
+
+ def show
+ @map = NetworkMap.new(resource).with_helpers(self)
+ show! do
+ build_breadcrumb :show
+ end
+ end
+
+ def index
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ build_breadcrumb :index
+ end
+ end
+
+ protected
+
+ def build_resource
+ super.tap do |network|
+ network.line_referential = referential.line_referential
+ end
+ end
+
+ def collection
+ @q = referential.networks.search(params[:q])
+ @networks ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
+ end
+
+ def resource_url(network = nil)
+ referential_network_path(referential, network || resource)
+ end
+
+ def collection_url
+ referential_networks_path(referential)
+ end
+
+ def network_params
+ params.require(:network).permit(:objectid, :object_version, :creation_time, :creator_id, :version_date, :description, :name, :registration_number, :source_name, :source_type_name, :source_identifier, :comment )
+ end
+
+end
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 6cbeee4c9..91f3a56c0 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -74,15 +74,27 @@ module BreadcrumbHelper
end
def network_breadcrumb(action)
- referential_breadcrumb
- add_breadcrumb Chouette::Network.model_name.human(:count => 2), referential_networks_path(@referential) unless action == :index
- add_breadcrumb breadcrumb_label(@network), referential_line_path(@referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit
+ if @line_referential
+ line_referential_breadcrumb
+ add_breadcrumb Chouette::Network.model_name.human(:count => 2), line_referential_networks_path(@line_referential) unless action == :index
+ add_breadcrumb breadcrumb_label(@network), line_referential_network_path(@line_referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit
+ else
+ referential_breadcrumb
+ add_breadcrumb Chouette::Network.model_name.human(:count => 2), referential_networks_path(@referential) unless action == :index
+ add_breadcrumb breadcrumb_label(@network), referential_network_path(@referential, @network),:title => breadcrumb_tooltip(@network) if action == :edit
+ end
end
def group_of_line_breadcrumb(action)
- referential_breadcrumb
- 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
+ if @line_referential
+ line_referential_breadcrumb
+ 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
+ else
+ 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
+ end
end
def stop_area_breadcrumb(action)
@@ -131,9 +143,15 @@ module BreadcrumbHelper
end
def line_breadcrumb(action)
- referential_breadcrumb
- 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
+ if @line_referential
+ line_referential_breadcrumb
+ add_breadcrumb Chouette::Line.model_name.human(:count => 2), line_referential_lines_path(@line_referential) unless action == :index
+ add_breadcrumb breadcrumb_label(@line), line_referential_line_path(@line_referential, @line),:title => breadcrumb_tooltip(@line) if action == :edit
+ else
+ 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
+ end
end
def route_breadcrumb(action)
@@ -173,7 +191,7 @@ module BreadcrumbHelper
if @line_referential
line_referential_breadcrumb
add_breadcrumb Chouette::Company.model_name.human(:count => 2), line_referential_companies_path(@line_referential) unless action == :index
- add_breadcrumb breadcrumb_label(@company), referential_company_path(@line_referential, @company),:title => breadcrumb_tooltip(@company) if action == :edit
+ add_breadcrumb breadcrumb_label(@company), line_referential_company_path(@line_referential, @company),:title => breadcrumb_tooltip(@company) if action == :edit
else
referential_breadcrumb
add_breadcrumb Chouette::Company.model_name.human(:count => 2), referential_companies_path(@referential) unless action == :index
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 7592bb5f1..ccab5bf8a 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -5,6 +5,7 @@ class LineReferential < ActiveRecord::Base
has_many :lines, class_name: 'Chouette::Line'
has_many :group_of_lines, class_name: 'Chouette::GroupOfLine'
has_many :companies, class_name: 'Chouette::Company'
+ has_many :networks, class_name: 'Chouette::Network'
has_one :line_referential_sync
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 0063244e8..d8731a8d3 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -30,6 +30,7 @@ class Referential < ActiveRecord::Base
has_many :lines, through: :line_referential
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
+ has_many :networks, through: :line_referential
belongs_to :stop_area_referential
# validates_presence_of :stop_area_referential
@@ -59,10 +60,6 @@ class Referential < ActiveRecord::Base
self.class.human_attribute_name(*args)
end
- def networks
- Chouette::Network.all
- end
-
def stop_areas
Chouette::StopArea.all
end
diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim
index 019a0650a..68b31c6e1 100644
--- a/app/views/line_referentials/show.html.slim
+++ b/app/views/line_referentials/show.html.slim
@@ -6,6 +6,14 @@
.panel.panel-default
ul.list-group width="75%"
li.list-group-item
+ span.badge = @line_referential.companies.size
+ = link_to Referential.human_attribute_name("companies"), line_referential_companies_path(@line_referential)
+
+ li.list-group-item
+ span.badge = @line_referential.networks.size
+ = link_to Referential.human_attribute_name("networks"), line_referential_networks_path(@line_referential)
+
+ li.list-group-item
span.badge = @line_referential.group_of_lines.size
= link_to Referential.human_attribute_name("group_of_lines"), line_referential_group_of_lines_path(@line_referential)
@@ -13,10 +21,6 @@
span.badge = @line_referential.operating_lines.size
= link_to Referential.human_attribute_name("lines"), line_referential_lines_path(@line_referential)
- li.list-group-item
- span.badge = @line_referential.companies.size
- = link_to Referential.human_attribute_name("companies"), line_referential_companies_path(@line_referential)
-
- unless @line_referential.line_referential_sync.line_sync_operations.empty?
h3 Historique des synchronisations
diff --git a/app/views/networks/_form.html.slim b/app/views/networks/_form.html.slim
index e7020ef68..f7b97c27d 100644
--- a/app/views/networks/_form.html.slim
+++ b/app/views/networks/_form.html.slim
@@ -1,7 +1,7 @@
-= semantic_form_for [@referential, @network] do |form|
+= semantic_form_for [@line_referential, @network] do |form|
= form.inputs do
- = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.network.name")}
- = form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.network.registration_number")}
+ = 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
diff --git a/app/views/networks/_network.html.slim b/app/views/networks/_network.html.slim
index dc1aa6b5c..ed216c4c7 100644
--- a/app/views/networks/_network.html.slim
+++ b/app/views/networks/_network.html.slim
@@ -2,13 +2,13 @@
.panel-heading
.panel-title.clearfix
span.pull-right
- = link_to edit_referential_network_path(@referential, network), class: 'btn btn-default btn-sm' do
+ = link_to edit_line_referential_network_path(@line_referential, network), class: 'btn btn-default btn-sm' do
span.fa.fa-pencil
- = link_to referential_network_path(@referential, network), method: :delete, :data => { :confirm => t('networks.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do
+ = link_to line_referential_network_path(@line_referential, network), method: :delete, :data => { :confirm => t('networks.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do
span.fa.fa-trash-o
h5
- = link_to [@referential, network], class: 'preview', title: "#{Chouette::Network.model_name.human.capitalize} #{network.name}" do
+ = link_to [@line_referential, network], class: 'preview', title: "#{Chouette::Network.model_name.human.capitalize} #{network.name}" do
span.name
= truncate(network.name, :length => 20) \ No newline at end of file
diff --git a/app/views/networks/index.html.slim b/app/views/networks/index.html.slim
index f3ead931e..bc32d273c 100644
--- a/app/views/networks/index.html.slim
+++ b/app/views/networks/index.html.slim
@@ -1,6 +1,6 @@
= title_tag t('networks.index.title')
-= search_form_for @q, :url => referential_networks_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
+= search_form_for @q, :url => line_referential_networks_path(@line_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
.panel.panel-default
.panel-heading
.input-group.col-md-12
@@ -19,5 +19,5 @@
- content_for :sidebar do
ul.actions
li
- = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add'
+ = link_to t('networks.actions.new'), new_line_referential_network_path(@line_referential), class: 'add'
br \ No newline at end of file
diff --git a/app/views/networks/show.html.slim b/app/views/networks/show.html.slim
index 936f6a4a8..e6bf4e399 100644
--- a/app/views/networks/show.html.slim
+++ b/app/views/networks/show.html.slim
@@ -37,11 +37,11 @@
- content_for :sidebar do
ul.actions
li
- = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add'
+ = link_to t('networks.actions.new'), new_line_referential_network_path(@line_referential), class: 'add'
li
- = link_to t('networks.actions.edit'), edit_referential_network_path(@referential, @network), class: 'edit'
+ = link_to t('networks.actions.edit'), edit_line_referential_network_path(@line_referential, @network), class: 'edit'
li
- = link_to t('networks.actions.destroy'), referential_network_path(@referential, @network), method: :delete, data: { :confirm => t('networks.actions.destroy_confirm')}, class: 'remove'
+ = link_to t('networks.actions.destroy'), line_referential_network_path(@line_referential, @network), method: :delete, data: { :confirm => t('networks.actions.destroy_confirm')}, class: 'remove'
br
-
+
= creation_tag(@network) \ No newline at end of file
diff --git a/app/views/networks/show.kml.slim b/app/views/networks/show.kml.slim
index 5fd79cd47..8a5db0587 100644
--- a/app/views/networks/show.kml.slim
+++ b/app/views/networks/show.kml.slim
@@ -1,9 +1,9 @@
doctype XML
-kml xmlns="http://www.opengis.net/kml/2.2"
+kml xmlns="http://www.opengis.net/kml/2.2"
document
- @network.commercial_stop_areas.each do |stop_area|
- placemark id="#{stop_area.id}"
+ placemark id="#{stop_area.id}"
name = stop_area.name
stop_area_type = stop_area.area_type.underscore
stop_area_type_label = t("area_types.label.#{stop_area.stop_area_type}")
diff --git a/app/views/referential_networks/_form.html.slim b/app/views/referential_networks/_form.html.slim
new file mode 100644
index 000000000..e7020ef68
--- /dev/null
+++ b/app/views/referential_networks/_form.html.slim
@@ -0,0 +1,15 @@
+= semantic_form_for [@referential, @network] do |form|
+ = form.inputs do
+ = form.input :name, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.network.name")}
+ = form.input :registration_number, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@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 => Chouette::Network.source_type_names, :include_blank => true, :member_label => Proc.new { |mode| t("source_types.label.#{mode}") }
+ = form.input :source_identifier
+ = form.input :objectid, :required => !@network.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.network.objectid")}
+
+ = form.actions do
+ = form.action :submit, as: :button
+ = form.action :cancel, as: :link \ No newline at end of file
diff --git a/app/views/referential_networks/_network.html.slim b/app/views/referential_networks/_network.html.slim
new file mode 100644
index 000000000..dc1aa6b5c
--- /dev/null
+++ b/app/views/referential_networks/_network.html.slim
@@ -0,0 +1,14 @@
+#index_item.panel.panel-default.network
+ .panel-heading
+ .panel-title.clearfix
+ span.pull-right
+ = link_to edit_referential_network_path(@referential, network), class: 'btn btn-default btn-sm' do
+ span.fa.fa-pencil
+
+ = link_to referential_network_path(@referential, network), method: :delete, :data => { :confirm => t('networks.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do
+ span.fa.fa-trash-o
+
+ h5
+ = link_to [@referential, network], class: 'preview', title: "#{Chouette::Network.model_name.human.capitalize} #{network.name}" do
+ span.name
+ = truncate(network.name, :length => 20) \ No newline at end of file
diff --git a/app/views/referential_networks/_networks.html.slim b/app/views/referential_networks/_networks.html.slim
new file mode 100644
index 000000000..9143e5c16
--- /dev/null
+++ b/app/views/referential_networks/_networks.html.slim
@@ -0,0 +1,9 @@
+.page_info
+ span.search = t('will_paginate.page_entries_info.search')
+ = page_entries_info @networks
+
+.networks.paginated_content
+ = paginated_content(@networks)
+
+.pagination
+ = will_paginate @networks, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer \ No newline at end of file
diff --git a/app/views/referential_networks/edit.html.slim b/app/views/referential_networks/edit.html.slim
new file mode 100644
index 000000000..d4e088937
--- /dev/null
+++ b/app/views/referential_networks/edit.html.slim
@@ -0,0 +1,3 @@
+= title_tag t('networks.edit.title', network: @network.name)
+
+= render 'form' \ No newline at end of file
diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim
new file mode 100644
index 000000000..f3ead931e
--- /dev/null
+++ b/app/views/referential_networks/index.html.slim
@@ -0,0 +1,23 @@
+= title_tag t('networks.index.title')
+
+= search_form_for @q, :url => referential_networks_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
+ .panel.panel-default
+ .panel-heading
+ .input-group.col-md-12
+ = f.text_field :name_cont, placeholder: "#{t('.name')}", class: 'form-control'
+ .input-group-btn
+ button.btn.btn-default type="submit"
+ i.fa.fa-search
+
+ / <!-- <a data-toggle="collapse" data-parent="#search" href="#advanced_search"> -->
+ / <!-- <i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %> -->
+ / <!-- </a> -->
+
+#networks
+ = render 'networks'
+
+- content_for :sidebar do
+ ul.actions
+ li
+ = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add'
+ br \ No newline at end of file
diff --git a/app/views/referential_networks/index.js.slim b/app/views/referential_networks/index.js.slim
new file mode 100644
index 000000000..930880dfa
--- /dev/null
+++ b/app/views/referential_networks/index.js.slim
@@ -0,0 +1 @@
+| $('#networks').html("#{escape_javascript(render('networks'))}"); \ No newline at end of file
diff --git a/app/views/referential_networks/new.html.slim b/app/views/referential_networks/new.html.slim
new file mode 100644
index 000000000..7071ded33
--- /dev/null
+++ b/app/views/referential_networks/new.html.slim
@@ -0,0 +1,3 @@
+= title_tag t('networks.new.title')
+
+= render 'form' \ No newline at end of file
diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim
new file mode 100644
index 000000000..936f6a4a8
--- /dev/null
+++ b/app/views/referential_networks/show.html.slim
@@ -0,0 +1,47 @@
+= title_tag t('networks.show.title', network: @network.name)
+
+.network_show
+ = @map.to_html
+
+ .summary
+ p
+ label = "#{Chouette::Network.human_attribute_name('registration_number')} : "
+ = @network.registration_number
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('comment')} : "
+ = @network.comment
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('version_date')} : "
+ - if @network.version_date.present?
+ = l @network.version_date
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('description')} : "
+ = @network.description
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('source_name')} : "
+ = @network.source_name
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('source_type_name')} : "
+ - if @network.source_type_name.present?
+ = t("source_types.label.#{@network.source_type_name}")
+
+ p
+ label = "#{Chouette::Network.human_attribute_name('source_identifier')} : "
+ = @network.source_identifier
+
+- content_for :sidebar do
+ ul.actions
+ li
+ = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add'
+ li
+ = link_to t('networks.actions.edit'), edit_referential_network_path(@referential, @network), class: 'edit'
+ li
+ = link_to t('networks.actions.destroy'), referential_network_path(@referential, @network), method: :delete, data: { :confirm => t('networks.actions.destroy_confirm')}, class: 'remove'
+ br
+
+ = creation_tag(@network) \ No newline at end of file
diff --git a/app/views/referential_networks/show.kml.slim b/app/views/referential_networks/show.kml.slim
new file mode 100644
index 000000000..5fd79cd47
--- /dev/null
+++ b/app/views/referential_networks/show.kml.slim
@@ -0,0 +1,10 @@
+doctype XML
+
+kml xmlns="http://www.opengis.net/kml/2.2"
+ document
+ - @network.commercial_stop_areas.each do |stop_area|
+ placemark id="#{stop_area.id}"
+ name = stop_area.name
+ stop_area_type = stop_area.area_type.underscore
+ stop_area_type_label = t("area_types.label.#{stop_area.stop_area_type}")
+ = (stop_area.position or stop_area.default_position).kml_representation.html_safe \ No newline at end of file