Files
Runar Ingebrigtsen 530021960e
CI / scan_ruby (push) Failing after 12s
CI / scan_js (push) Successful in 11s
CI / lint (push) Failing after 19s
CI / test (push) Successful in 34s
add entry requests, invite new users
2026-01-30 01:28:53 +01:00

43 lines
1.2 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module EntriesHelper
def alphabet_letters(language_code)
return ("A".."Z").to_a if language_code.blank?
case language_code.to_s
when "ru"
%w[
А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
]
when "no"
("A".."Z").to_a + %w[Æ Ø Å]
when "sv"
("A".."Z").to_a + %w[Å Ä Ö]
when "fi"
("A".."Z").to_a + %w[Å Ä Ö]
else
("A".."Z").to_a
end
end
def entry_translation_for(entry, language_code)
language_column = language_code.to_s
return unless entry.has_attribute?(language_column)
entry.public_send(language_column)
end
def format_entry_category(entry)
entry.category.to_s.tr("_", " ").capitalize
end
def format_entry_status(entry)
case entry.status
when "requested"
content_tag(:span, "Requested", class: "px-2 py-1 text-xs font-semibold rounded-full bg-yellow-100 text-yellow-800")
when "approved"
content_tag(:span, "Approved", class: "px-2 py-1 text-xs font-semibold rounded-full bg-blue-100 text-blue-800")
when "active"
content_tag(:span, "Active", class: "px-2 py-1 text-xs font-semibold rounded-full bg-green-100 text-green-800")
end
end
end