Merge pull request #4529 from okriuchykhin/ok_SCI_6943_v2

Unify tags loading order [SCI-6943]
This commit is contained in:
Alex Kriuchykhin 2022-10-17 10:21:13 +02:00 committed by GitHub
commit 63a1b35a45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 13 deletions

View file

@ -7,7 +7,7 @@ class MyModuleTagsController < ApplicationController
def index_edit
@my_module_tags = @my_module.my_module_tags.order(:id)
@unassigned_tags = @my_module.unassigned_tags
@unassigned_tags = @my_module.unassigned_tags.order(:id)
@new_mmt = MyModuleTag.new(my_module: @my_module)
@new_tag = Tag.new(project: @my_module.experiment.project)

View file

@ -188,12 +188,7 @@ class MyModule < ApplicationRecord
end
def unassigned_tags
Tag.find_by_sql(
"SELECT DISTINCT tags.id, tags.name, tags.color FROM tags " +
"INNER JOIN experiments ON experiments.project_id = tags.project_id " +
"WHERE experiments.id = #{experiment_id.to_s} AND tags.id NOT IN " +
"(SELECT DISTINCT tag_id FROM my_module_tags WHERE my_module_tags.my_module_id = #{id.to_s})"
)
experiment.project.tags.where.not(id: tags)
end
def last_activities(count = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)

View file

@ -6,7 +6,7 @@ module Reports::Docx::DrawMyModule
link_style = @link_style
scinote_url = @scinote_url
my_module = subject.my_module
tags = my_module.tags
tags = my_module.tags.order(:id)
return unless can_read_my_module?(@user, my_module)
@docx.h3 do
@ -48,10 +48,10 @@ module Reports::Docx::DrawMyModule
end
end
if tags.any?
if tags.present?
@docx.p do
text I18n.t('projects.reports.elements.module.tags_header')
my_module.tags.each do |tag|
tags.each do |tag|
text ' '
text "[#{tag.name}]", color: tag.color.delete('#')
end

View file

@ -1,5 +1,5 @@
<div class="tags-container pull-right">
<% tags2 = my_module.tags[0..3] %>
<% tags2 = my_module.tags.order(:id).take(4) %>
<% tags2.each do |tag| %>
<div style="color: <%= tag.color %>"
class="<%= "last" if tag == tags2[-1] %>"

View file

@ -39,8 +39,8 @@
<div class="pull-left">
<%= t('projects.reports.elements.module.tags_header') %>
</div>
<% if my_module.tags.present? %>
<% my_module.tags.each do |tag| %>
<% if (tags = my_module.tags.order(:id)).present? %>
<% tags.each do |tag| %>
<div class="pull-left module-tag" style="background-color: <%= tag.color %>;">
<%= tag.name %>
</div>