Skip to content

Commit

Permalink
Avoid db queries in reused partials
Browse files Browse the repository at this point in the history
  • Loading branch information
nanego committed Oct 29, 2024
1 parent d04869c commit 4878bcf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/views/issue_comments/_new_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<%= error_messages_for 'issue' %>
<div class="box">


<%= render "issue_comments/visibility_form_fields" %>

<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', :no_label => true, :id => 'issue_comment' %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/issue_comments/_visibility_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<% disabled = "disabled" if involved.present? && @checked_roles.size == 1 %>
<% css_classes = "#{involved} #{disabled} " %>
<% if Redmine::Plugin.installed?(:redmine_limited_visibility) %>
<% @users_by_function ||= @project.users_by_function if @project.present? %>
<%= render "issue_comments/visibility_role", :function => role, styles: css_classes %>
<% end %>
<% end %>
</div>
<%= hidden_field_tag "journal[visibility]", @checked_roles.map(&:id).join('|'), id: "journal_visibility", data: { id: @journal.present? ? @journal.id : 0 } %>
<%= hidden_field_tag "journal[visibility]", @checked_roles.map(&:id).join('|'), id: "journal_visibility", data: { id: @journal.present? ? @journal.id : 0 } %>
4 changes: 2 additions & 2 deletions app/views/issue_comments/_visibility_role.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if @project.present?
users_by_function = function.users_by_project(@project)
<% if @project.present? && @users_by_function.present?
users_by_function = @users_by_function[function]
users_names = users_by_function.blank? ? "Aucun membre n'a ce rôle dans ce projet" : users_by_function.map(&:name).join(", ")
end %>
<span class="comment_role <%= styles %> <%= 'no-member' if users_by_function.blank? %>" data-role-id="<%= function.id %>" data-journal-id="<%= @journal.present? ? @journal.id : 0 %>" title="<%= users_names %>">
Expand Down

0 comments on commit 4878bcf

Please sign in to comment.