Filter issues by file description (#34715).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@21034 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2021-06-14 07:01:27 +00:00
parent 9e3d772e15
commit a0bf4e5cd3
4 changed files with 66 additions and 0 deletions

View File

@@ -202,6 +202,10 @@ class IssueQuery < Query
"attachment",
:type => :text, :name => l(:label_attachment)
)
add_available_filter(
"attachment_description",
:type => :text, :name => l(:label_attachment_description)
)
if User.current.logged?
add_available_filter(
"watcher_id",
@@ -597,6 +601,23 @@ class IssueQuery < Query
end
end
def sql_for_attachment_description_field(field, operator, value)
cond_description = "a.description IS NOT NULL AND a.description <> ''"
c =
case operator
when '*', '!*'
(operator == '*' ? cond_description : "NOT (#{cond_description})")
when '~', '!~'
(operator == '~' ? '' : "#{cond_description} AND ") +
sql_contains('a.description', value.first, :match => (operator == '~'))
when '^', '$'
sql_contains('a.description', value.first, (operator == '^' ? :starts_with : :ends_with) => true)
else
'1=0'
end
"EXISTS (SELECT 1 FROM #{Attachment.table_name} a WHERE a.container_type = 'Issue' AND a.container_id = #{Issue.table_name}.id AND #{c})"
end
def sql_for_parent_id_field(field, operator, value)
case operator
when "="