Patch #1898 » watcher_filter.diff
| app/models/query.rb | ||
|---|---|---|
|
"<t-" => :label_more_than_ago,
|
||
|
"t-" => :label_ago,
|
||
|
"~" => :label_contains,
|
||
|
"!~" => :label_not_contains }
|
||
|
"!~" => :label_not_contains,
|
||
|
"<w" => :label_equals,
|
||
|
">w" => :label_not_equals}
|
||
|
cattr_reader :operators
|
||
|
|
||
|
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
||
|
:list_watcher => [ "<w", ">w" ],
|
||
|
:list_status => [ "o", "=", "!", "c", "*" ],
|
||
|
:list_optional => [ "=", "!", "!*", "*" ],
|
||
|
:list_subprojects => [ "*", "!*", "=" ],
|
||
| ... | ... | |
|
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
|
||
|
QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"),
|
||
|
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:watcher),
|
||
|
]
|
||
|
cattr_reader :available_columns
|
||
|
|
||
| ... | ... | |
|
end
|
||
|
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
|
||
|
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
||
|
@available_filters["watcher_id"] = { :type => :list_watcher, :order => 15, :values => user_values } unless user_values.empty?
|
||
|
|
||
|
if project
|
||
|
# project specific filters
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
# "me" value subsitution
|
||
|
if %w(assigned_to_id author_id).include?(field)
|
||
|
if %w(assigned_to_id author_id watcher_id).include?(field)
|
||
|
v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'"
|
||
|
when "!~"
|
||
|
sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
||
|
when "<w"
|
||
|
sql = sql + "#{Issue.table_name}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
when ">w"
|
||
|
sql = sql + "#{Issue.table_name}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
end
|
||
|
sql << ')'
|
||
|
filters_clauses << sql
|
||
| app/views/queries/_filters.rhtml | ||
|---|---|---|
|
<td>
|
||
|
<div id="div_values_<%= field %>" style="display:none;">
|
||
|
<% case options[:type]
|
||
|
when :list, :list_optional, :list_status, :list_subprojects %>
|
||
|
when :list, :list_optional, :list_status, :list_subprojects, :list_watcher %>
|
||
|
<select <%= "multiple=true" if query.values_for(field) and query.values_for(field).length > 1 %> name="values[<%= field %>][]" id="values_<%= field %>" class="select-small" style="vertical-align: top;">
|
||
|
<%= options_for_select options[:values], query.values_for(field) %>
|
||
|
</select>
|
||
| lang/en.yml | ||
|---|---|---|
|
field_default_value: Default value
|
||
|
field_comments_sorting: Display comments
|
||
|
field_parent_title: Parent page
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Application title
|
||
|
setting_app_subtitle: Application subtitle
|
||
|
-
|
||
| lang/bg.yml | ||
|---|---|---|
|
field_redirect_existing_links: Пренасочване на съществуващи линкове
|
||
|
field_estimated_hours: Изчислено време
|
||
|
field_default_value: Стойност по подразбиране
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Заглавие
|
||
|
setting_app_subtitle: Описание
|
||
| lang/cs.yml | ||
|---|---|---|
|
field_searchable: Umožnit vyhledávání
|
||
|
field_default_value: Výchozí hodnota
|
||
|
field_comments_sorting: Zobrazit komentáře
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Název aplikace
|
||
|
setting_app_subtitle: Podtitulek aplikace
|
||
| lang/da.yml | ||
|---|---|---|
|
field_time_zone: Tids zone
|
||
|
field_searchable: Søgbar
|
||
|
field_default_value: Standard værdi
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Applikations titel
|
||
|
setting_app_subtitle: Applikations undertekst
|
||
| lang/de.yml | ||
|---|---|---|
|
field_searchable: Durchsuchbar
|
||
|
field_default_value: Standardwert
|
||
|
field_comments_sorting: Kommentare anzeigen
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Applikations-Titel
|
||
|
setting_app_subtitle: Applikations-Untertitel
|
||
| lang/es.yml | ||
|---|---|---|
|
field_issue_to_id: Petición Relacionada
|
||
|
field_delay: Retraso
|
||
|
field_default_value: Estado por defecto
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Título de la aplicación
|
||
|
setting_app_subtitle: Subtítulo de la aplicación
|
||
| lang/fi.yml | ||
|---|---|---|
|
field_time_zone: Aikavyöhyke
|
||
|
field_searchable: Haettava
|
||
|
field_default_value: Vakioarvo
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Ohjelman otsikko
|
||
|
setting_app_subtitle: Ohjelman alaotsikko
|
||
| lang/fr.yml | ||
|---|---|---|
|
field_default_value: Valeur par défaut
|
||
|
field_comments_sorting: Afficher les commentaires
|
||
|
field_parent_title: Page parent
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Titre de l'application
|
||
|
setting_app_subtitle: Sous-titre de l'application
|
||
| lang/he.yml | ||
|---|---|---|
|
field_estimated_hours: זמן משוער
|
||
|
field_column_names: עמודות
|
||
|
field_default_value: ערך ברירת מחדל
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: כותרת ישום
|
||
|
setting_app_subtitle: תת-כותרת ישום
|
||
| lang/hu.yml | ||
|---|---|---|
|
field_searchable: Kereshető
|
||
|
field_default_value: Alapértelmezett érték
|
||
|
field_comments_sorting: Feljegyzések megjelenítése
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Alkalmazás címe
|
||
|
setting_app_subtitle: Alkalmazás alcíme
|
||
| lang/it.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirige i collegamenti esistenti
|
||
|
field_estimated_hours: Tempo stimato
|
||
|
field_default_value: Stato predefinito
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Titolo applicazione
|
||
|
setting_app_subtitle: Sottotitolo applicazione
|
||
| lang/ja.yml | ||
|---|---|---|
|
field_redirect_existing_links: 既存のリンクをリダイレクトする
|
||
|
field_estimated_hours: 予定工数
|
||
|
field_default_value: デフォルトのステータス
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: アプリケーションのタイトル
|
||
|
setting_app_subtitle: アプリケーションのサブタイトル
|
||
| lang/ko.yml | ||
|---|---|---|
|
field_estimated_hours: 추정시간
|
||
|
field_column_names: 컬럼
|
||
|
field_default_value: 기본값
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: 레드마인 제목
|
||
|
setting_app_subtitle: 레드마인 부제목
|
||
| lang/lt.yml | ||
|---|---|---|
|
field_time_zone: Laiko juosta
|
||
|
field_searchable: Randamas
|
||
|
field_default_value: Numatytoji vertė
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Programos pavadinimas
|
||
|
setting_app_subtitle: Programos paantraštė
|
||
|
setting_welcome_text: Pasveikinimas
|
||
| lang/no.yml | ||
|---|---|---|
|
field_searchable: Søkbar
|
||
|
field_default_value: Standardverdi
|
||
|
field_comments_sorting: Vis kommentarer
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Applikasjonstittel
|
||
|
setting_app_subtitle: Applikasjonens undertittel
|
||
| lang/pl.yml | ||
|---|---|---|
|
field_issue_to_id: Powiązania zagadnienia
|
||
|
field_delay: Opóźnienie
|
||
|
field_default_value: Domyślny
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Tytuł aplikacji
|
||
|
setting_app_subtitle: Podtytuł aplikacji
|
||
| lang/pt-br.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirecionar links existentes
|
||
|
field_estimated_hours: Tempo estimado
|
||
|
field_default_value: Padrão
|
||
|
field_watcher: Watcher
|
||
|
|
||
|
setting_app_title: Título da aplicação
|
||
|
setting_app_subtitle: Sub-título da aplicação
|
||
| lang/pt.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirect existing links
|
||
|
field_estimated_hours: Estimated time
|
||
|
field_default_value: Padrão
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Título da aplicação
|
||
|
setting_app_subtitle: Sub-título da aplicação
|
||
| lang/ro.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirectare linkuri existente
|
||
|
field_estimated_hours: Timpul estimat
|
||
|
field_default_value: Default value
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Titlul aplicatiei
|
||
|
setting_app_subtitle: Subtitlul aplicatiei
|
||
| lang/ru.yml | ||
|---|---|---|
|
field_default_value: Значение по умолчанию
|
||
|
field_time_zone: Часовой пояс
|
||
|
field_searchable: Доступно для поиска
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Название приложения
|
||
|
setting_app_subtitle: Подзаголовок приложения
|
||
| lang/sr.yml | ||
|---|---|---|
|
field_estimated_hours: Procenjeno vreme
|
||
|
field_column_names: Kolone
|
||
|
field_default_value: Default value
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Naziv aplikacije
|
||
|
setting_app_subtitle: Podnaslov aplikacije
|
||
| lang/sv.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirect existing links
|
||
|
field_estimated_hours: Estimated time
|
||
|
field_default_value: Default value
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Applikationstitel
|
||
|
setting_app_subtitle: Applicationsunderrubrik
|
||
| lang/th.yml | ||
|---|---|---|
|
field_searchable: ค้นหาได้
|
||
|
field_default_value: ค่าเริ่มต้น
|
||
|
field_comments_sorting: แสดงความเห็น
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: ชื่อโปรแกรม
|
||
|
setting_app_subtitle: ชื่อโปรแกรมรอง
|
||
| lang/uk.yml | ||
|---|---|---|
|
field_column_names: Колонки
|
||
|
field_time_zone: Часовий пояс
|
||
|
field_searchable: Вживається у пошуку
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Назва додатку
|
||
|
setting_app_subtitle: Підзаголовок додатку
|
||
| lang/zh-tw.yml | ||
|---|---|---|
|
field_searchable: 可用做搜尋條件
|
||
|
field_default_value: 預設值
|
||
|
field_comments_sorting: 註解排序
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: 標題
|
||
|
setting_app_subtitle: 副標題
|
||
| lang/zh.yml | ||
|---|---|---|
|
field_default_value: 默认值
|
||
|
field_comments_sorting: 显示注释
|
||
|
field_parent_title: 上级页面
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: 应用程序标题
|
||
|
setting_app_subtitle: 应用程序子标题
|
||
|
-
|
||
| lang/nl.yml | ||
|---|---|---|
|
field_redirect_existing_links: Redirect existing links
|
||
|
field_estimated_hours: Estimated time
|
||
|
field_default_value: Default value
|
||
|
field_watcher: Watcher
|
||
|
setting_app_title: Applicatie titel
|
||
|
setting_app_subtitle: Applicatie ondertitel
|
||
|
-
|
||
| app/models/query.rb | ||
|---|---|---|
|
when "!~"
|
||
|
sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
||
|
when "<w"
|
||
|
sql = sql + "#{Issue.table_name}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
sql = sql + "#{db_table}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
when ">w"
|
||
|
sql = sql + "#{Issue.table_name}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
sql = sql + "#{db_table}.id NOT IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" if field == "watcher_id"
|
||
|
end
|
||
|
sql << ')'
|
||
|
filters_clauses << sql
|
||
|
-
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
find_issues_with_query(query)
|
||
|
end
|
||
|
|
||
|
def test_operator_equals_watcher
|
||
|
query = Query.new(:project => Project.find(1), :name => '_')
|
||
|
user = User.find(1)
|
||
|
query.add_filter('watcher_id', '<w', [user.id.to_s])
|
||
|
assert query.statement.include?("#{Issue.table_name}.id IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN ('" + user.id.to_s + "'))")
|
||
|
find_issues_with_query(query)
|
||
|
end
|
||
|
|
||
|
def test_operator_not_equals_watcher
|
||
|
query = Query.new(:project => Project.find(1), :name => '_')
|
||
|
user = User.find(1)
|
||
|
query.add_filter('watcher_id', '>w', [user.id.to_s])
|
||
|
assert query.statement.include?("#{Issue.table_name}.id NOT IN (SELECT #{Watcher.table_name}.watchable_id FROM #{Watcher.table_name} WHERE #{Watcher.table_name}.watchable_type = 'Issue' AND #{Watcher.table_name}.user_id IN ('" + user.id.to_s + "'))")
|
||
|
find_issues_with_query(query)
|
||
|
end
|
||
|
|
||
|
def test_default_columns
|
||
|
q = Query.new
|
||
|
assert !q.columns.empty?
|
||