Project

General

Profile

Feature #38527 » filter-operators-for-journal-details.patch

Go MAEDA, 2023-05-07 11:04

View differences:

app/models/issue_query.rb
155 155
    ) if project.nil?
156 156
    add_available_filter(
157 157
      "tracker_id",
158
      :type => :list, :values => trackers.collect{|s| [s.name, s.id.to_s]}
158
      :type => :list_with_history, :values => trackers.collect{|s| [s.name, s.id.to_s]}
159 159
    )
160 160
    add_available_filter(
161 161
      "priority_id",
162
      :type => :list, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s]}
162
      :type => :list_with_history, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s]}
163 163
    )
164 164
    add_available_filter(
165 165
      "author_id",
......
167 167
    )
168 168
    add_available_filter(
169 169
      "assigned_to_id",
170
      :type => :list_optional, :values => lambda {assigned_to_values}
170
      :type => :list_optional_with_history, :values => lambda {assigned_to_values}
171 171
    )
172 172
    add_available_filter(
173 173
      "member_of_group",
......
179 179
    )
180 180
    add_available_filter(
181 181
      "fixed_version_id",
182
      :type => :list_optional, :values => lambda {fixed_version_values}
182
      :type => :list_optional_with_history, :values => lambda {fixed_version_values}
183 183
    )
184 184
    add_available_filter(
185 185
      "fixed_version.due_date",
......
194 194
    )
195 195
    add_available_filter(
196 196
      "category_id",
197
      :type => :list_optional,
197
      :type => :list_with_history,
198 198
      :values => lambda {project.issue_categories.collect{|s| [s.name, s.id.to_s]}}
199 199
    ) if project
200 200
    add_available_filter "subject", :type => :text
app/models/query.rb
314 314
    "!p"  => :label_no_issues_in_project,
315 315
    "*o"  => :label_any_open_issues,
316 316
    "!o"  => :label_no_open_issues,
317
    "cf"  => :label_changed_from,
318
    "ev"  => :label_has_ever_been,
319
    "!ev" => :label_has_never_been
317 320
  }
318 321

  
319 322
  class_attribute :operators_by_filter_type
320 323
  self.operators_by_filter_type = {
321 324
    :list => [ "=", "!" ],
322
    :list_status => [ "o", "=", "!", "c", "*" ],
325
    :list_with_history =>  [ "=", "!", "cf", "ev", "!ev" ],
326
    :list_status => [ "o", "=", "!", "cf", "ev", "!ev", "c", "*" ],
323 327
    :list_optional => [ "=", "!", "!*", "*" ],
328
    :list_optional_with_history => [ "=", "!", "cf", "ev", "!ev", "!*", "*" ],
324 329
    :list_subprojects => [ "*", "!*", "=", "!" ],
325 330
    :date => [ "=", ">=", "<=", "><", "<t+", ">t+", "><t+", "t+", "nd", "t", "ld", "nw", "w", "lw", "l2w", "nm", "m", "lm", "y", ">t-", "<t-", "><t-", "t-", "!*", "*" ],
326 331
    :date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "><t-", "t-", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "!*", "*" ],
......
1438 1443
      sql = sql_contains("#{db_table}.#{db_field}", value.first, :starts_with => true)
1439 1444
    when "$"
1440 1445
      sql = sql_contains("#{db_table}.#{db_field}", value.first, :ends_with => true)
1446
    when "cf"
1447
      # changed from
1448
      subquery =
1449
        "SELECT 1 FROM journals, journal_details WHERE " +
1450
        queried_class.send(:sanitize_sql_array,
1451
        [
1452
          "(#{Journal.table_name}.journalized_type = 'Issue' AND #{db_table}.id = #{Journal.table_name}.journalized_id AND #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id AND prop_key = '#{db_field}' AND old_value IN (?)) AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})",
1453
          value
1454
        ]
1455
        )
1456
      sql = "EXISTS (#{subquery})"
1457
    when "ev", "!ev"
1458
      # has ever been / has never been
1459
      neg = (operator == '!ev' ? 'NOT' : '')
1460
      subquery =
1461
        "SELECT 1 FROM journals, journal_details WHERE " +
1462
        queried_class.send(:sanitize_sql_array,
1463
        [
1464
          "((#{Journal.table_name}.journalized_type = 'Issue' AND #{db_table}.id = #{Journal.table_name}.journalized_id AND #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id AND prop_key = '#{db_field}' AND old_value IN (?)) OR (#{db_table}.#{db_field} IN (?))) AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})",
1465
          value, value
1466
        ]
1467
        )
1468
      sql = "#{neg} EXISTS (#{subquery})"
1441 1469
    else
1442 1470
      raise QueryError, "Unknown query operator #{operator}"
1443 1471
    end
config/locales/en.yml
818 818
  label_no_issues_in_project: no issues in project
819 819
  label_any_open_issues: any open issues
820 820
  label_no_open_issues: no open issues
821
  label_changed_from: changed from
822
  label_has_ever_been: has ever been
823
  label_has_never_been: has never been
821 824
  label_day_plural: days
822 825
  label_repository: Repository
823 826
  label_repository_new: New repository
public/javascripts/application.js
180 180

  
181 181
  switch (filterOptions['type']) {
182 182
  case "list":
183
  case "list_with_history":
183 184
  case "list_optional":
185
  case "list_optional_with_history":
184 186
  case "list_status":
185 187
  case "list_subprojects":
186 188
    tr.find('td.values').append(
(1-1/9)