Skip to content

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

minor refactoring

Jonas Jabarice8a66edfc00
diff --git a/app/components/settings/project_custom_field_sections/custom_field_row_component.rb b/app/components/settings/project_custom_field_sections/custom_field_row_component.rb
index 3dc7976b6d7..1edf7fb943c 100644
--- a/app/components/settings/project_custom_field_sections/custom_field_row_component.rb
+++ b/app/components/settings/project_custom_field_sections/custom_field_row_component.rb
@@ -50,10 +50,19 @@ module Settings
end
def move_actions(menu)
- move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless @project_custom_field.first?
- move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless @project_custom_field.first?
- move_action_item(menu, :lower, t("label_agenda_item_move_down"), "chevron-down") unless @project_custom_field.last?
- unless @project_custom_field.last?
+ # TODO: these methods trigger database queries for each custom field displayed
+ # it would be nice if can eager load this information
+ first_in_list = @project_custom_field.first?
+ last_in_list = @project_custom_field.last?
+
+ unless first_in_list
+ move_action_item(menu, :highest, t("label_agenda_item_move_to_top"),
+ "move-to-top")
+ move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up")
+ end
+ unless last_in_list
+ move_action_item(menu, :lower, t("label_agenda_item_move_down"),
+ "chevron-down")
move_action_item(menu, :lowest, t("label_agenda_item_move_to_bottom"),
"move-to-bottom")
end
diff --git a/app/components/settings/project_custom_field_sections/show_component.rb b/app/components/settings/project_custom_field_sections/show_component.rb
index 00aa9ddfaa4..573cf1d4c87 100644
--- a/app/components/settings/project_custom_field_sections/show_component.rb
+++ b/app/components/settings/project_custom_field_sections/show_component.rb
@@ -64,16 +64,19 @@ module Settings
end
def move_actions(menu)
- unless @project_custom_field_section.first?
+ # TODO: these methods trigger database queries for each section displayed
+ # it would be nice if can eager load this information
+ first_in_list = @project_custom_field_section.first?
+ last_in_list = @project_custom_field_section.last?
+
+ unless first_in_list
move_action_item(menu, :highest, t("label_agenda_item_move_to_top"),
"move-to-top")
+ move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up")
end
- move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless @project_custom_field_section.first?
- unless @project_custom_field_section.last?
+ unless last_in_list
move_action_item(menu, :lower, t("label_agenda_item_move_down"),
"chevron-down")
- end
- unless @project_custom_field_section.last?
move_action_item(menu, :lowest, t("label_agenda_item_move_to_bottom"),
"move-to-bottom")
end