Feature #20081

Filter issues and time entries by project status

Added by Zer Guz over 3 years ago. Updated 3 months ago.

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

0%

Category:Projects
Target version:4.0.0
Resolution:Fixed

Description

When filtering (issues, spent time, etc) by project, the filter shows a list of all non-archived projects. This list becomes very long (in our case) as the closed projects are accumulating. We don't want to archive these closed projects, as we need occasionally to find data related to them.

It is good to choose whether the filter list includes only active project (default) or all (excluding archived, as it is now).

For example, currently the filter consists of two lists:
  • is, is not
  • project names
It could be changed to:
  • is (active), is, is not
  • project names
Or add additional list:
  • active, all, closed
  • is, is not
  • project names

So that if "active" is selected, only active projects are shown in the combo list. "Active" should be used by default (rather than "all") - this way it should cover the most used cases without additional effort.

0002-Filter-time-entries-after-project-status.patch Magnifier (3.62 KB) Marius BALTEANU, 2018-10-22 00:03

0001-Filter-issues-after-project-status.patch Magnifier (5.55 KB) Marius BALTEANU, 2018-10-28 16:38

Screenshot from 2018-11-30 10-44-08.png - traslation missing error (6.32 KB) Rang Tang, 2018-11-30 04:28


Related issues

Related to Redmine - Patch #29482: Query system for Projects page New
Related to Redmine - Feature #12066: Don't show issues for closed projects in all issues list New
Related to Redmine - Defect #30718: Translation missing for filter by project status Closed
Duplicated by Redmine - Feature #22107: Add "Project status" to issues list's filters Closed
Blocks Redmine - Feature #29449: Filter out issues from closed projects in My Page blocks Closed

Associated revisions

Revision 17607
Added by Go MAEDA 4 months ago

Filter issues after project status (#20081).

Patch by Marius BALTEANU.

Revision 17608
Added by Go MAEDA 4 months ago

Filter time entries after project status (#20081).

Patch by Marius BALTEANU.

Revision 17609
Added by Go MAEDA 4 months ago

Revert unwanted changes in r17607 (#20081).

History

#1 Updated by Go MAEDA almost 2 years ago

  • Duplicated by Feature #22107: Add "Project status" to issues list's filters added

#2 Updated by Marius BALTEANU 4 months ago

Attached two patches that add the "Project's status" filter to issues and time entries. Beside the filter itself utility, if we add this feature, will allow us to implement #29449 and also, to discuss (I'll add another ticket) the possibility to hide the issues/time entries from closed projects by default (as the closed projects are hidden by default in Projects page).

#3 Updated by Marius BALTEANU 4 months ago

  • Related to Patch #29482: Query system for Projects page added

#4 Updated by Marius BALTEANU 4 months ago

  • Related to Feature #29449: Filter out issues from closed projects in My Page blocks added

#5 Updated by Marius BALTEANU 4 months ago

  • Related to deleted (Feature #29449: Filter out issues from closed projects in My Page blocks)

#6 Updated by Marius BALTEANU 4 months ago

  • Blocks Feature #29449: Filter out issues from closed projects in My Page blocks added

#7 Updated by Marius BALTEANU 4 months ago

  • Related to Feature #12066: Don't show issues for closed projects in all issues list added

#8 Updated by Go MAEDA 4 months ago

Marius, thank you for writing the patch.

It seems working fine but I came across the following error while running tests after applying
0001-Filter-issues-after-project-status.patch. Could you look into this?

Failure:
QueriesHelperTest#test_filters_options_for_select_should_group_associations_filters [/Users/maeda/redmines/redmine-trunk/test/helpers/queries_helper_test.rb:78]:
Expected exactly 2 elements matching "optgroup[label="Project"] > option", found 3..
Expected: 2
  Actual: 3

#9 Updated by Marius BALTEANU 4 months ago

  • File deleted (0001-Filter-issues-after-project-status.patch)

#10 Updated by Marius BALTEANU 4 months ago

Fixed in the attached patch.

Sorry for not catching this test fail from the beginning.

#11 Updated by Go MAEDA 4 months ago

  • Subject changed from Show only active projects in the filter to Filter issues and time entries by project status
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 4.0.0
  • Resolution set to Fixed

Committed. Thank you for improving Redmine.

#12 Updated by Rang Tang 3 months ago

Hi,
I came from #29449 and just applied these patches to my redmine 3.4 instance:

  • 0001-Filter-issues-after-project-status.patch
  • 0002-Filter-time-entries-after-project-status.patch
  • 0003-Filter-our-issues-from-closed-projects-in-the-follow.patch (from #29449)
  • use_status_active_constant.diff (from #29449)

Now that issues from closed project are filtered out from my page as I expected.
However, a "translation missing" error now appears in the filter on the query page:

I find it's because Project::LABEL_BY_STATUS (patch 0001) is not working as expected. (I think I18n is not loaded yet when this hash value gets evaluated)

I can fix this by putting the labels hash into query.rb instead of calling Project::LABEL_BY_STATUS. But is there a way to keep the labels inside the Project model and still be able to use the translations? I'm new to ruby and rails and looking forward to some advice.

diff --git a/app/models/query.rb b/app/models/query.rb
index dc84402..218c560 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -573,7 +573,11 @@ class Query < ActiveRecord::Base

   # Returns a scope of project statuses that are available as columns or filters
   def project_statuses_values
-    project_statuses =  Project::LABEL_BY_STATUS
+    project_statuses = {
+      1 => l(:project_status_active),
+      5 => l(:project_status_closed),
+      9 => l(:project_status_archived),
+    }
     # Remove archived status from filters
     project_statuses.delete(9)
     project_statuses.stringify_keys.invert.to_a

#13 Updated by Marius BALTEANU 5 days ago

  • Related to Defect #30718: Translation missing for filter by project status added

Also available in: Atom PDF