aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/exports_helper.rb2
-rw-r--r--app/helpers/imports_helper.rb26
-rw-r--r--app/helpers/menus_helper.rb20
-rw-r--r--app/helpers/stop_areas_helper.rb21
-rw-r--r--app/helpers/table_builder_helper.rb26
-rw-r--r--app/helpers/vehicle_journeys_helper.rb12
6 files changed, 88 insertions, 19 deletions
diff --git a/app/helpers/exports_helper.rb b/app/helpers/exports_helper.rb
index 2e784ad35..f30a80ed9 100644
--- a/app/helpers/exports_helper.rb
+++ b/app/helpers/exports_helper.rb
@@ -17,7 +17,7 @@ module ExportsHelper
message.message_attributes["text"]
else
t([message.class.name.underscore.gsub('/', '_').pluralize, message.message_key].join('.'), message.message_attributes&.symbolize_keys || {})
- end
+ end.html_safe
end
def fields_for_export_task_format(form)
diff --git a/app/helpers/imports_helper.rb b/app/helpers/imports_helper.rb
index 140660153..f06d77eca 100644
--- a/app/helpers/imports_helper.rb
+++ b/app/helpers/imports_helper.rb
@@ -2,33 +2,49 @@
module ImportsHelper
# Import statuses helper
- def import_status(status)
- if %w[new running pending].include? status
+ def import_status(status, verbose: false, default_status: nil)
+ status ||= default_status
+ return unless status
+ status = status.to_s.downcase
+ out = if %w[new running pending].include? status
content_tag :span, '', class: "fa fa-clock-o"
else
cls =''
cls = 'success' if status == 'successful'
+ cls = 'success' if status == 'ok'
cls = 'warning' if status == 'warning'
- cls = 'danger' if %w[failed aborted canceled].include? status
+ cls = 'danger' if %w[failed aborted canceled error].include? status
content_tag :span, '', class: "fa fa-circle text-#{cls}"
end
+ if verbose
+ out += content_tag :span do
+ txt = "imports.status.#{status}".t(fallback: "")
+ end
+ end
+ out
end
# Compliance check set messages
def bootstrap_class_for_message_criticity message_criticity
- case message_criticity
- when "error"
+ case message_criticity.downcase
+ when "error", "aborted"
"alert alert-danger"
when "warning"
"alert alert-warning"
when "info"
"alert alert-info"
+ when "ok", "success"
+ "alert alert-success"
else
message_criticity.to_s
end
end
+ def import_message_content message
+ export_message_content message
+ end
+
##############################
#      TO CLEAN!!!
##############################
diff --git a/app/helpers/menus_helper.rb b/app/helpers/menus_helper.rb
new file mode 100644
index 000000000..81d55a944
--- /dev/null
+++ b/app/helpers/menus_helper.rb
@@ -0,0 +1,20 @@
+module MenusHelper
+ def main_nav_menu_item label, &block
+ @current_menu_item_count ||= 0
+ @current_menu_item_count += 1
+ content_tag :div, class: "menu-item panel" do
+ out = ""
+ out += content_tag(:div, class: "panel-heading") do
+ content_tag :h4, class: "panel-title" do
+ link_to label, "#menu-item-#{@current_menu_item_count}", data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false'
+ end
+ end
+ out += content_tag(:div, class: "panel-collapse collapse", id: "menu-item-#{@current_menu_item_count}") do
+ content_tag :div, class: "list-group" do
+ capture(&block)
+ end
+ end
+ out.html_safe
+ end
+ end
+end
diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb
index 314154fb7..d3e7dd2a4 100644
--- a/app/helpers/stop_areas_helper.rb
+++ b/app/helpers/stop_areas_helper.rb
@@ -75,16 +75,17 @@ module StopAreasHelper
t "formtastic.hints.stop_area.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')
+ def stop_area_status(status)
+ case status
+ when :confirmed
+ content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') +
+ t('activerecord.attributes.stop_area.confirmed')
+ when :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
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index e2aa2e9ea..0b24a9c05 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -153,7 +153,17 @@ module TableBuilderHelper
i = columns.index(column)
if overhead[i].blank?
- if (i > 0) && (overhead[i - 1][:width] > 1)
+ prev = nil
+ if i > 0
+ (i-1..0).each do |j|
+ o = overhead[j]
+ if (j + o[:width].to_i) >= i
+ prev = o
+ break
+ end
+ end
+ end
+ if prev
clsArrayH = overhead[i - 1][:cls].split
hcont << content_tag(:th, build_column_header(
@@ -225,7 +235,7 @@ module TableBuilderHelper
if column.linkable?
path = column.link_to(item)
- link = value.present? && path.present? ? link_to(value, path) : ""
+ link = value.present? && path.present? ? link_to(value, path) : value
if overhead.empty?
bcont << content_tag(:td, link, title: 'Voir', class: extra_class)
@@ -234,7 +244,17 @@ module TableBuilderHelper
i = columns.index(column)
if overhead[i].blank?
- if (i > 0) && (overhead[i - 1][:width] > 1)
+ prev = nil
+ if i > 0
+ (i-1..0).each do |j|
+ o = overhead[j]
+ if (j + o[:width].to_i) >= i
+ prev = o
+ break
+ end
+ end
+ end
+ if prev
clsArrayAlt = overhead[i - 1][:cls].split
bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArrayAlt, extra_class))
diff --git a/app/helpers/vehicle_journeys_helper.rb b/app/helpers/vehicle_journeys_helper.rb
index 1cc865c62..4d7eb7002 100644
--- a/app/helpers/vehicle_journeys_helper.rb
+++ b/app/helpers/vehicle_journeys_helper.rb
@@ -69,4 +69,16 @@ module VehicleJourneysHelper
)
end
+ def vehicle_journey_stop_headline prev_sp, sp
+ if has_feature?(:long_distance_routes)
+ headline = prev_sp && prev_sp.stop_area.country_code
+ headline = sp.stop_area.country_code != headline
+ headline && sp.stop_area.country_name
+ else
+ headline = prev_sp && prev_sp.stop_area.city_name
+ headline = sp.stop_area.city_name != headline
+ headline && sp.stop_area.city_name
+ end
+ end
+
end