OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[30926] Display info instead of error when toc is empty
Oliver Güntherd1dcb37cb4f5
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 22628f577b1..c10184773eb 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1628,6 +1628,7 @@ en:label_wiki_content_added: "Wiki page added"label_wiki_content_updated: "Wiki page updated"label_wiki_toc: "Table of Contents"+ label_wiki_toc_empty: "Table of Contents is empty as no headings are present."label_wiki_dont_show_menu_item: "Do not show this wikipage in project navigation"label_wiki_edit: "Wiki edit"label_wiki_edit_plural: "Wiki edits"diff --git a/lib/open_project/text_formatting/filters/table_of_contents_filter.rb b/lib/open_project/text_formatting/filters/table_of_contents_filter.rbindex 7d3e1ac7197..9acc72d77bb 100644--- a/lib/open_project/text_formatting/filters/table_of_contents_filter.rb+++ b/lib/open_project/text_formatting/filters/table_of_contents_filter.rb@@ -117,9 +117,13 @@ module OpenProject::TextFormattingenddef process!- return if headings.empty?+ result[:toc] =+ if headings.empty?+ I18n.t(:label_wiki_toc_empty)+ else+ content_tag(:ul, render_nested(nil), class: 'toc')+ end- result[:toc] = content_tag(:ul, render_nested(nil), class: 'toc')rescue StandardError => eRails.logger.error { "Failed to render table of contents: #{e} #{e.message}" }end