@query.column_names = nil if params[:default_columns]
@query.sort_criteria = (params[:query] && params[:query][:sort_criteria]) || @query.sort_criteria
@query.name = params[:query] && params[:query][:name]
+ @query.description = params[:query] && params[:query][:description]
if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin?
@query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE
@query.role_ids = params[:query] && params[:query][:role_ids]
content_tag('li',
link_to(query.name,
url_params.merge(:query_id => query),
- :class => css) +
+ :class => css,
+ :title => query.description) +
clear_link.html_safe)
end.join("\n").html_safe,
:class => 'queries'
validates_presence_of :name
validates_length_of :name, :maximum => 255
+ validates_length_of :description, :maximum => 255
validates :visibility, :inclusion => {:in => [VISIBILITY_PUBLIC, VISIBILITY_ROLES, VISIBILITY_PRIVATE]}
validate :validate_query_filters
validate do |query|
</div>
<h2><%= @query.new_record? ? l(:label_project_plural) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag(admin_projects_path(@project, nil), :method => :get, :id => 'query_form') do %>
<%= hidden_field_tag 'admin_projects', '1' %>
<h2><%= @query.new_record? ? l(:label_calendar) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag({:controller => 'calendars', :action => 'show', :project_id => @project},
:method => :get, :id => 'query_form') do %>
</div>
<h2><%= @query.new_record? ? l(:label_gantt) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag({:controller => 'gantts', :action => 'show',
:project_id => @project, :month => params[:month],
<h2><%= @query.new_record? ? l(:label_issue_plural) : @query.name %></h2>
<% html_title(@query.new_record? ? l(:label_issue_plural) : @query.name) %>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag(_project_issues_path(@project), :method => :get, :id => 'query_form') do %>
<%= render :partial => 'queries/query_form' %>
</div>
<h2><%= @query.new_record? ? l(:label_project_plural) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag(projects_path(@project, nil), :method => :get, :id => 'query_form') do %>
<%= render :partial => 'queries/query_form' %>
<p><label for="query_name"><%=l(:field_name)%></label>
<%= text_field 'query', 'name', :size => 80 %></p>
+<p><label for="query_description"><%=l(:field_description)%></label>
+<%= text_field 'query', 'description', :size => 80 %></p>
<% if User.current.admin? ||
User.current.allowed_to?(:manage_public_queries, @query.project) %>
</div>
<h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag(_time_entries_path(@project, nil), :method => :get, :id => 'query_form') do %>
<%= render :partial => 'date_range' %>
</div>
<h2><%= @query.new_record? ? l(:label_user_plural) : @query.name %></h2>
+<%= @query.persisted? && @query.description.present? ? content_tag('p', @query.description, class: 'subtitle') : '' %>
<%= form_tag(users_path, method: :get, id: 'query_form') do %>
<%= render partial: 'queries/query_form' %>
--- /dev/null
+class AddQueriesDescription < ActiveRecord::Migration[6.1]
+ def up
+ add_column :queries, :description, :string, :after => :name
+ end
+
+ def down
+ remove_column :queries, :description
+ end
+end
project_id: 1
visibility: 2
name: Multiple custom fields query
+ description: Description for Multiple custom fields query
filters: |
---
cf_1:
project_id: 1
visibility: 0
name: Private query for cookbook
+ description: Description for Private query for cookbook
filters: |
---
tracker_id:
project_id:
visibility: 0
name: Private query for all projects
+ description: Description for Private query for all projects
filters: |
---
tracker_id:
project_id:
visibility: 2
name: Public query for all projects
+ description: Description for Public query for all projects
filters: |
---
tracker_id:
project_id:
visibility: 2
name: Open issues by priority and tracker
+ description: Description for Oepn issues by priority and tracker
filters: |
---
status_id:
project_id:
visibility: 2
name: Open issues grouped by tracker
+ description: Description for Open issues grouped by tracker
filters: |
---
status_id:
project_id: 2
visibility: 2
name: Public query for project 2
+ description: Description for Public query for project 2
filters: |
---
tracker_id:
project_id: 2
visibility: 0
name: Private query for project 2
+ description: Description for Private query for project 2
filters: |
---
tracker_id:
project_id:
visibility: 2
name: Open issues grouped by list custom field
+ description: Description for Open issues grouped by list custom field
filters: |
---
status_id:
project_id: 1
visibility: 2
name: My spent time
+ description: Description for My spent time
filters: |
---
user_id:
type: ProjectQuery
visibility: 2
name: Projects as list
+ description: Description for Projects as list
filters: |
---
id:
type: ProjectQuery
visibility: 1
name: My bookmarks
+ description: Description for My bookmarks
filters: |
---
id:
end
def test_show_should_run_custom_queries
- @query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
+ query = IssueQuery.create!(:name => 'Calendar Query', :description => 'Description for Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
get(
:show,
:params => {
- :query_id => @query.id
+ :query_id => query.id
}
)
assert_response :success
- assert_select 'h2', :text => 'Calendar Query'
+ assert_select 'h2', :text => query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
end
def test_cross_project_calendar
assert_response :success
end
+ def test_show_should_run_custom_query
+ query = IssueQuery.create!(:name => 'Gantt Query', :description => 'Description for Gantt Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
+ get(
+ :show,
+ :params => {
+ :query_id => query.id
+ }
+ )
+ assert_response :success
+ assert_select 'h2', :text => query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
+ end
+
def test_gantt_should_work_cross_project
get :show
assert_response :success
assert_select 'a.query.selected', 1
# assert link properties
assert_select(
- 'a.query.selected[href=?]',
+ 'a.query.selected[title=?][href=?]',
+ 'Description for Oepn issues by priority and tracker',
'/projects/ecookbook/issues?query_id=5',
:text => "Open issues by priority and tracker"
)
assert_select 'tr#project-4 td.last_activity_date', :text => ''
end
+ def test_index_with_query
+ query = ProjectQuery.find(11)
+ get :index, :params => { :query_id => query.id }
+ assert_response :success
+ assert_select 'h2', :text => query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
+ end
+
def test_index_should_retrieve_default_query
query = ProjectQuery.find(11)
ProjectQuery.stubs(:default).returns query
@request.session[:user_id] = user_id
get :index
assert_select 'h2', text: query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
end
end
assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria
end
+ def test_create_with_description
+ @request.session[:user_id] = 2
+ assert_difference '::Query.count', 1 do
+ post(
+ :create,
+ :params => {
+ :project_id => 'ecookbook',
+ :query => {
+ :name => 'test_new_with_description', :description => 'Description for test_new_with_description'
+ }
+ }
+ )
+ end
+ q = Query.find_by_name("test_new_with_description")
+ assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
+
+ assert_equal 'Description for test_new_with_description', q.description
+ end
+
def test_create_with_failure
@request.session[:user_id] = 2
assert_no_difference '::Query.count' do
end
end
+ def test_edit_description
+ @request.session[:user_id] = 1
+ get(:edit, :params => {:id => 5})
+ assert_response :success
+
+ assert_select 'input[name="query[description]"][value=?]', 'Description for Oepn issues by priority and tracker'
+ end
+
def test_edit_invalid_query
@request.session[:user_id] = 2
get(:edit, :params => {:id => 99})
assert Query.find_by_name('test_project_query_updated')
end
+ def test_update_description
+ @request.session[:user_id] = 1
+ q = Query.find(5)
+ put(
+ :update,
+ :params => {
+ :id => q.id,
+ :query => {
+ :name => q.name,
+ :description => 'query description updated'
+ }
+ }
+ )
+ assert_redirected_to :controller => 'issues', :action => 'index', :query_id => q.id
+ assert_equal 'query description updated', Query.find(5).description
+ end
+
def test_update_with_failure
@request.session[:user_id] = 1
put(
end
def test_index_with_query
- query = TimeEntryQuery.new(:project_id => 1, :name => 'Time Entry Query', :visibility => 2)
+ query = TimeEntryQuery.new(:project_id => 1, :name => 'Time Entry Query', :description => 'Description for Time Entry Query', :visibility => 2)
query.save!
@request.session[:user_id] = 2
get :index, :params => {:project_id => 'ecookbook', :query_id => query.id}
assert_response :success
assert_select 'h2', :text => query.name
- assert_select '#sidebar a.selected', :text => query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
end
def test_index_atom_feed
assert_select 'tr#user-1', 1
end
+ def test_index_with_query
+ query = UserQuery.create!(:name => 'My User Query', :description => 'Description for My User Query', :visibility => UserQuery::VISIBILITY_PUBLIC)
+ get :index, :params => { :query_id => query.id }
+ assert_response :success
+
+ assert_select 'h2', :text => query.name
+ assert_select '#sidebar a.query.selected[title=?]', query.description, :text => query.name
+ end
+
def test_index_csv
with_settings :default_language => 'en' do
user = User.logged.status(1).first