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
Use helper instead of repeating code
Henriette Darge393b794efda7
diff --git a/app/helpers/tabs_helper.rb b/app/helpers/tabs_helper.rbindex 64370492b4d..1b0779a622d 100644--- a/app/helpers/tabs_helper.rb+++ b/app/helpers/tabs_helper.rb@@ -28,10 +28,10 @@module TabsHelper# Renders tabs and their content- def render_tabs(tabs, form = nil)+ def render_tabs(tabs, form = nil, with_tab_nav: true)if tabs.any?selected = selected_tab(tabs)- render partial: "common/tabs", locals: { f: form, tabs:, selected_tab: selected }+ render partial: "common/tabs", locals: { f: form, tabs:, selected_tab: selected, with_tab_nav: }elsecontent_tag "p", I18n.t(:label_no_data), class: "nodata"enddiff --git a/app/views/common/_tabs.html.erb b/app/views/common/_tabs.html.erbindex 91e7cee467c..79e723bc953 100644--- a/app/views/common/_tabs.html.erb+++ b/app/views/common/_tabs.html.erb@@ -28,7 +28,9 @@ See COPYRIGHT and LICENSE files for more details.++#%><% gon.contentTabs = { tabs: tabs.to_json.html_safe, selected: selected_tab.to_json.html_safe } %>-<content-tabs></content-tabs>+<% if with_tab_nav %>+ <content-tabs></content-tabs>+<% end %><%= content_tag 'div',render(partial: selected_tab[:partial], locals: { f: f, tab: selected_tab } ),diff --git a/app/views/placeholder_users/edit.html.erb b/app/views/placeholder_users/edit.html.erbindex 6ddccd074d6..4696ae23c31 100644--- a/app/views/placeholder_users/edit.html.erb+++ b/app/views/placeholder_users/edit.html.erb@@ -31,11 +31,7 @@ See COPYRIGHT and LICENSE files for more details.<% html_title(t(:label_administration), "#{t(:label_edit)} #{PlaceholderUser.model_name.human} #{h(@placeholder_user.name)}") -%><% tabs = tabs_for_key(:placeholder_user, placeholder_user: @placeholder_user) %>-<% selected_tab = selected_tab(tabs) %><%= render partial: 'toolbar', locals: { tabs: tabs } %>-<%= content_tag 'div',- render(partial: selected_tab[:partial], locals: { tab: selected_tab } ),- id: "tab-content-#{selected_tab[:name]}",- class: 'tab-content' %>+<%= render_tabs tabs, with_tab_nav: false %>diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erbindex 209c7fd054b..ee1228ec300 100644--- a/app/views/users/edit.html.erb+++ b/app/views/users/edit.html.erb@@ -31,11 +31,7 @@ See COPYRIGHT and LICENSE files for more details.<% html_title(t(:label_administration), "#{t(:label_edit)} #{User.model_name.human} #{h(@user.name)}") -%><% tabs = tabs_for_key(:user, user: @user) %>-<% selected_tab = selected_tab(tabs) %><%= render partial: 'toolbar', locals: { tabs: tabs } %>-<%= content_tag 'div',- render(partial: selected_tab[:partial], locals: { tab: selected_tab } ),- id: "tab-content-#{selected_tab[:name]}",- class: 'tab-content' %>+<%= render_tabs tabs, with_tab_nav: false %>