Project

General

Profile

Actions

Feature #32311

open

Filter Issues by multiple issue_id doesn't support space character or semicolon/dash as the separator

Added by Taine Woo about 5 years ago. Updated about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Issues filter
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Issues -> Filter -> Issue
statement "is", input the filter value as multiple ids, such as "1,2,3".

It only supports comma "," as the separator of issue ids.
It doesn't support other common separators, such as space, semicolon, dash.

And actually if we copied the ids from the id column from excel, it would be multiple lines combined with also semicolon.

Actions #1

Updated by Taine Woo about 5 years ago

If the value of the issue_id is "1,2,3" in the filter, the query executes successfully.
If the value of the issue_id is "1 2 3" or "1 2 3" or "1, 2, 3", the query fails with message "•Issue is invalid"

Actions #2

Updated by Taine Woo about 5 years ago

app/models/query.rb

line 417, replace the "," as "\D" can use any non-numeric characters as separator.

Actions #3

Updated by Taine Woo about 5 years ago

/\A[+-]?\d+(\D[+-]?\d+)*\z/
digit separated by one non-digit

/\A[+-]?\d+(\D*\d+)*\z/
digit separated by any non-digit, easier for users.

Actions #4

Updated by Marius BĂLTEANU about 5 years ago

  • Tracker changed from Defect to Feature

It is the expected behaviour and I'm not sure that we should support more delimiters.

Actions #5

Updated by Taine Woo about 5 years ago

Marius BALTEANU wrote:

It is the expected behaviour and I'm not sure that we should support more delimiters.

Hi Marius,

Currently the regexp is quite strict, only support digits seperated by only comma, no other character is allowed, it's not a bug.
But according to my survey, most of the users will not want to input the Issue ID one by one manually.
Users will copy the IDs from tables such as excel, the data would be "1 2 3 ", the delimiter should be "tab", and if copied from csv, may be the delimiter would be space.

So if we loose the restrict, users may have better experience.

Actions #6

Updated by Taine Woo about 5 years ago

Here is my patch, case check added for integer.


  def validate_query_filters
    filters.each_key do |field|
      if values_for(field)
        case type_for(field)
        when :integer
          case operator_for(field)
          when "=" 
            #add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\D[+-]?\d+)*\z/) }
            add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\D*\d+)*\z/) }
          else
            add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(,[+-]?\d+)*\z/) }
          end
        when :float
          add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\.\d*)?\z/) }
        when :date, :date_past
          case operator_for(field)
          when "=", ">=", "<=", "><" 
            add_filter_error(field, :invalid) if values_for(field).detect {|v|
              v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?)
            }
          when ">t-", "<t-", "t-", ">t+", "<t+", "t+", "><t+", "><t-" 
            add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
          end
        end
      end

      add_filter_error(field, :blank) unless
          # filter requires one or more values
          (values_for(field) and !values_for(field).first.blank?) or
          # filter doesn't require any value
          ["o", "c", "!*", "*", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "*o", "!o"].include? operator_for(field)
    end if filters
  end
Actions

Also available in: Atom PDF