aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2018-01-11 12:02:25 +0100
committerAlban Peignier2018-01-11 12:30:43 +0100
commit4f74779e9732c5dd45bd8c3cd1ae67f74d1faa28 (patch)
tree45b0d0aba91a04acc759422ffb5d6072ca068d07
parenta9cd4e4c90f90ca68292febbd88d5cdf4c7c109f (diff)
downloadchouette-core-4f74779e9732c5dd45bd8c3cd1ae67f74d1faa28.tar.bz2
Create Referential#full_name and try to use it (to be completed). Refs #5546
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--app/helpers/breadcrumb_helper.rb9
-rw-r--r--app/models/referential.rb8
-rw-r--r--app/views/referentials/show.html.slim11
-rw-r--r--config/locales/referentials.fr.yml2
5 files changed, 28 insertions, 7 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 713542ff4..0058c210d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -14,6 +14,11 @@ module ApplicationHelper
def page_header_title(object)
# Unwrap from decorator, we want to know the object model name
object = object.object if object.try(:object)
+
+ if Referential === object
+ return object.full_name
+ end
+
local = "#{object.model_name.name.underscore.pluralize}.#{params[:action]}.title"
if object.try(:name)
t(local, name: object.name || object.id)
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 3da119247..2175e0be4 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -1,5 +1,12 @@
module BreadcrumbHelper
def breadcrumb_name(object, prop='name')
- "#{object.class.model_name.human} #{object.public_send(prop)}".truncate(50)
+ name =
+ if prop == 'name' && object.respond_to?(:full_name)
+ object.full_name
+ else
+ "#{object.class.model_name.human} #{object.public_send(prop)}"
+ end
+
+ name.truncate(40)
end
end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 2b7866d9f..718f60ffd 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -105,6 +105,14 @@ class Referential < ActiveRecord::Base
self.class.human_attribute_name(*args)
end
+ def full_name
+ if in_referential_suite?
+ name
+ else
+ "#{self.class.model_name.human.capitalize} #{name}"
+ end
+ end
+
def stop_areas
Chouette::StopArea.all
end
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 51041198c..305d04f6b 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -21,11 +21,12 @@
.container-fluid
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
- = definition_list t('metadatas'),
- { t('activerecord.attributes.referential.status') => @referential.referential_read_only? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe,
- @referential.human_attribute_name(:validity_period) => (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin), format: :short), end: l(@referential.try(:validity_period).try(:end), format: :short)) : '-'),
- @referential.human_attribute_name(:organisation) => @referential.organisation.name,
- @referential.human_attribute_name(:published_at) => '-' }
+ - attributes = {}
+ - attributes[@referential.human_attribute_name(:status)] = @referential.referential_read_only? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe unless @referential.in_referential_suite?
+ - attributes[@referential.human_attribute_name(:validity_period)] = (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin), format: :short), end: l(@referential.try(:validity_period).try(:end), format: :short)) : '-')
+ - attributes[@referential.human_attribute_name(:organisation)] = @referential.organisation.name
+ - attributes[@referential.human_attribute_name(:published_at)] = '-' unless @referential.in_referential_suite?
+ = definition_list t('metadatas'), attributes
- if params[:q].present? or @reflines.any?
.row
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index 38a8c2231..0f6e71520 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -11,11 +11,11 @@ fr:
edit:
title: "Editer le jeu de données"
show:
+ title: "Jeu de données %{name}"
lines: "lignes"
networks: "réseaux"
vehicle_journeys: "courses"
time_tables: "calendriers"
- title: "Jeu de données"
clean_up: "Purge des données obsolètes"
api_keys: "Clés d'authentification pour un accès à l'API REST"
show_all_referentials: Voir tous les jeux de données