-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new filter option and delete view patch
Global changes for issue range plugin. Delete view patch for compatibility with new redmine versions.
- Loading branch information
Showing
5 changed files
with
51 additions
and
128 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
en: | ||
# query selectors strings | ||
label_issue_list: Issue list | ||
field_id: Issue_id | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
ru: | ||
label_issue_list: Список задач | ||
field_id: Номер задачи |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,47 @@ | ||
module IssueQuery | ||
module Patches | ||
module QueryModelPatch | ||
def self.included(base) # :nodoc: | ||
base.extend(ClassMethods) | ||
base.send(:include, InstanceMethods) | ||
module IssueQuery | ||
module Patches | ||
module QueryModelPatch | ||
def self.included(base) # :nodoc: | ||
base.extend(ClassMethods) | ||
base.send(:include, InstanceMethods) | ||
|
||
base.class_eval do | ||
alias_method_chain :sql_for_field, :issue_range | ||
alias_method_chain :available_filters, :issue_range | ||
|
||
class << self | ||
alias_method_chain :operators_by_filter_type, :issue_range | ||
alias_method_chain :operators, :issue_range | ||
end | ||
end | ||
end | ||
|
||
module ClassMethods | ||
def operators_with_issue_range | ||
o=operators_without_issue_range | ||
if o[":"].blank? | ||
o[":"]=:label_issue_list | ||
end | ||
o # return | ||
end | ||
|
||
def operators_by_filter_type_with_issue_range | ||
o = operators_by_filter_type_without_issue_range | ||
#unless o[:list_issue].include?(":") | ||
o[:list_issue] = ":" | ||
#end | ||
o # return | ||
end | ||
end | ||
base.class_eval do | ||
alias_method_chain :available_filters, :issue_range | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def available_filters_with_issue_range | ||
f = available_filters_without_issue_range | ||
f["id"] = { :type => :list_issue, :order => 15 } | ||
f # return | ||
end | ||
|
||
def get_issue_range_from_string(issue_str) | ||
format_issue = issue_str.to_s.gsub(/\s+/, '') | ||
issue_str.split(",") # return | ||
end | ||
|
||
def sql_for_field_with_issue_range(field, operator, value, db_table, db_field, is_custom_filter=false) | ||
sql=case operator | ||
when ":" | ||
case type_for(field) | ||
when :list_issue | ||
value = get_issue_range_from_string(value.first.strip) | ||
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | ||
else | ||
# IN an empty set | ||
sql = "1=0" | ||
module ClassMethods | ||
#dummy | ||
end | ||
else | ||
sql_for_field_without_issue_range(field, operator, value, db_table, db_field, is_custom_filter) | ||
end | ||
sql | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
module InstanceMethods | ||
def available_filters_with_issue_range | ||
f = available_filters_without_issue_range | ||
f["id"] = { :type => :text, :order => 15 } | ||
f # return | ||
end | ||
|
||
def get_issue_range_from_string(issue_str) | ||
format_issue = issue_str.to_s.gsub(/\s+/, '') | ||
issue_str.split(",") # return | ||
end | ||
|
||
def sql_for_id_field(field, operator, value) | ||
case operator | ||
when ":", "~" | ||
value = get_issue_range_from_string(value.first.strip) | ||
sql = "#{Issue.table_name}.id IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | ||
when "!~" | ||
value = get_issue_range_from_string(value.first.strip) | ||
sql = "#{Issue.table_name}.id NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | ||
else | ||
# IN an empty set | ||
sql = "1=0" | ||
end | ||
|
||
sql #return | ||
end | ||
end | ||
end #module QueryModelPatch | ||
end #module Patches | ||
end |