Feature #34715

Filter issues by file description

Added by Go MAEDA 8 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Filters
Target version:5.0.0
Resolution:Fixed

Description

Currently, Redmine has a feature to filter issues by attachment file name (#2783).

I think it would be even useful if it is possible to filter issues by attachment file description. Using both file name and description makes it much easier to find files or issues.

34715.patch Magnifier (4.42 KB) Yuichi HARADA, 2021-03-30 10:11

34715-v2.patch Magnifier (4.95 KB) Go MAEDA, 2021-06-11 11:27

file-group.png (64.7 KB) Go MAEDA, 2021-06-11 11:29

Associated revisions

Revision 21033
Added by Go MAEDA 4 months ago

Fix typo in test/fixtures/attachments.yml (#34715).

Revision 21034
Added by Go MAEDA 4 months ago

Filter issues by file description (#34715).

Patch by Yuichi HARADA.

Revision 21035
Added by Go MAEDA 4 months ago

Update locales (#34715).

History

#1 Updated by Yuichi HARADA 7 months ago

Go MAEDA wrote:

I think it would be even useful if it is possible to filter issues by attachment file description.

+1
Added "File description" to the Issues Filters.
I have attached a patch.

diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 5ff0e5530..92da7ec2f 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -201,6 +201,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",
@@ -588,6 +592,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 "=" 
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9d779a2fe..cf91a0447 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -698,6 +698,7 @@ en:
   label_attachment_delete: Delete file
   label_attachment_plural: Files
   label_file_added: File added
+  label_attachment_description: File description
   label_report: Report
   label_report_plural: Reports
   label_news: News

#2 Updated by Go MAEDA 7 months ago

  • Target version set to Candidate for next major release

#3 Updated by Go MAEDA 5 months ago

  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

#4 Updated by Go MAEDA 4 months ago

Since there are already many items in the dropdown, added a new group "Files" and put "File" and "File description" there for usability.

#5 Updated by Go MAEDA 4 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for your contribution.

Also available in: Atom PDF