aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/exports_helper.rb27
-rw-r--r--app/helpers/stop_areas_helper.rb36
-rw-r--r--app/helpers/table_builder_helper/column.rb4
3 files changed, 62 insertions, 5 deletions
diff --git a/app/helpers/exports_helper.rb b/app/helpers/exports_helper.rb
index 8ac494cfc..4e92c7e38 100644
--- a/app/helpers/exports_helper.rb
+++ b/app/helpers/exports_helper.rb
@@ -1,6 +1,25 @@
# -*- coding: utf-8 -*-
module ExportsHelper
-
+ def export_status status
+ import_status status
+ end
+
+ def export_option_input form, export, attr, option_def, type
+ opts = { required: option_def[:required], input_html: {value: export.try(attr) || option_def[:default_value]}, as: option_def[:type], selected: export.try(attr) || option_def[:default_value]}
+ opts[:collection] = option_def[:collection] if option_def.has_key?(:collection)
+ opts[:collection] = export.instance_exec(&option_def[:collection]) if option_def[:collection].is_a?(Proc)
+ opts[:label] = t "activerecord.attributes.export.#{type.name.demodulize.underscore}.#{attr}"
+ form.input attr, opts
+ end
+
+ def export_message_content message
+ if message.message_key == "full_text"
+ message.message_attributes["text"]
+ else
+ t([message.class.name.underscore.gsub('/', '_').pluralize, message.message_key].join('.'), message.message_attributes.symbolize_keys)
+ end
+ end
+
def fields_for_export_task_format(form)
begin
render :partial => export_partial_name(form), :locals => { :form => form }
@@ -8,7 +27,7 @@ module ExportsHelper
""
end
end
-
+
def export_partial_name(form)
"fields_#{form.object.format.underscore}_export"
end
@@ -22,7 +41,7 @@ module ExportsHelper
end.join.html_safe
end
end
-
+
def compliance_icon( export_task)
return nil unless export_task.compliance_check_task
export_task.compliance_check_task.tap do |cct|
@@ -33,5 +52,5 @@ module ExportsHelper
end
end
end
-
+
end
diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb
index 05ae042f5..1c9d974a1 100644
--- a/app/helpers/stop_areas_helper.rb
+++ b/app/helpers/stop_areas_helper.rb
@@ -54,4 +54,40 @@ module StopAreasHelper
end
end
+ def stop_area_registration_number_title stop_area
+ if stop_area&.stop_area_referential&.registration_number_format.present?
+ return t("formtastic.titles.stop_area.registration_number_format", registration_number_format: stop_area.stop_area_referential.registration_number_format)
+ end
+ t "formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.registration_number"
+ end
+
+ def stop_area_registration_number_is_required stop_area
+ val = format_restriction_for_locales(@referential) == '.hub'
+ val ||= stop_area&.stop_area_referential&.registration_number_format.present?
+ val
+ end
+
+ def stop_area_registration_number_value stop_area
+ stop_area&.registration_number || stop_area&.stop_area_referential&.generate_registration_number
+ end
+
+ def stop_area_status(stop_area)
+ if stop_area.activated?
+ content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') +
+ t('activerecord.attributes.stop_area.confirmed')
+ elsif stop_area.deactivated?
+ content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') +
+ t('activerecord.attributes.stop_area.deactivated')
+ else
+ content_tag(:span, nil, class: 'fa fa-pencil fa-lg text-info') +
+ t('activerecord.attributes.stop_area.in_creation')
+ end
+ end
+
+ def stop_area_status_options
+ Chouette::StopArea.statuses.map do |status|
+ [ t(status, scope: 'activerecord.attributes.stop_area'), status ]
+ end
+ end
+
end
diff --git a/app/helpers/table_builder_helper/column.rb b/app/helpers/table_builder_helper/column.rb
index f930eb9fd..f16fc66be 100644
--- a/app/helpers/table_builder_helper/column.rb
+++ b/app/helpers/table_builder_helper/column.rb
@@ -29,7 +29,9 @@ module TableBuilderHelper
return @name if @name.present?
# Transform `Chouette::Line` into "line"
- model_key = model.to_s.demodulize.underscore
+ model_key = model.to_s.underscore
+ model_key.gsub! 'chouette/', ''
+ model_key.gsub! '/', '.'
I18n.t("activerecord.attributes.#{model_key}.#{@key}")
end