From: Julien Lancelot Date: Thu, 16 May 2013 16:47:34 +0000 (+0200) Subject: SONAR-4301 Add project and creation date filters on issues search page X-Git-Tag: 3.6~346^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d1319cbdaa1f317975c09459e7318851aac1eab0;p=sonarqube.git SONAR-4301 Add project and creation date filters on issues search page --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 4b0dda7fe08..92b4a6af2c2 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -569,7 +569,9 @@ issue_filter.criteria.project=Project issue_filter.criteria.status=Status issue_filter.criteria.assignee=Assignee issue_filter.criteria.reporter=Reporter -issue_filter.criteria.creation_date=Creation date +issue_filter.criteria.created_after=Created since +issue_filter.criteria.created_before=Created before +issue_filter.criteria.date_format=year-month-day (2013-01-31) #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java b/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java index 69870669f05..45257af5844 100644 --- a/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java +++ b/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java @@ -25,6 +25,7 @@ import com.google.common.primitives.Ints; import org.sonar.api.utils.DateUtils; import javax.annotation.Nullable; + import java.util.Date; import java.util.List; @@ -80,7 +81,11 @@ public class RubyUtils { return (Date) o; } if (o instanceof String) { - return DateUtils.parseDateTime((String) o); + Date date = DateUtils.parseDateTimeQuietly((String) o); + if (date != null) { + return date; + } + return DateUtils.parseDate((String) o); } return null; } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index bd091c18290..dbccdec21b0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -21,10 +21,15 @@ class Api::ResourcesController < Api::ApiController # since version 3.3 # Exemple : /api/resources/search?s=sonar + # + # -- Optional parameters + # 'display_key' is used to return the resource key instead of the resource id. Default is false + # def search search_text = params[:s]||'' page=(params[:p] ? params[:p].to_i : 1) page_size=(params[:ps] ? params[:ps].to_i : 10) + display_key=params[:display_key]||false if params[:q] qualifiers=params[:q].split(',') elsif params[:qp] @@ -74,12 +79,13 @@ class Api::ResourcesController < Api::ApiController resources_by_qualifier = resources.group_by(&:qualifier) json = { :more => false, - :results => resources_by_qualifier.map { |qualifier, grouped_resources| {:text => message("qualifiers.#{qualifier}"), :children => grouped_resources.map { |r| {:id => r.id, :text => r.name(true)} }} } + :results => resources_by_qualifier.map { |qualifier, grouped_resources| {:text => message("qualifiers.#{qualifier}"), + :children => grouped_resources.map { |r| {:id => display_key ? r.key : r.id, :text => r.name(true)} }} } } else json = { :more => (page * page_size) resources.map { |resource| {:id => resource.id, :text => resource.name(true)} } + :results => resources.map { |resource| {:id => display_key ? resource.key : resource.id, :text => resource.name(true)} } } end else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb index 5cd8168322e..c10e77552b6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb @@ -31,6 +31,9 @@ class IssuesController < ApplicationController @filter = IssueFilter.new @filter.criteria=criteria_params @filter.execute + + # TODO replace by project from issues result API + @project = Project.by_key(@filter.criteria('componentRoots')).root_project if @filter.criteria('componentRoots') end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 28cec85c0a1..4679d64df77 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -611,6 +611,7 @@ module ApplicationHelper # * :placeholder - the label to display when nothing is selected # * :allow_clear - true if resource can be de-selected. Default is false. # * :open - true if the select-box must be open. Default is false. + # * :display_key - true if the resource key should be used instead of the resource id. Default is false. # * :select2_options - hash of select2 options # def resource_select_tag(name, options={}) @@ -624,9 +625,13 @@ module ApplicationHelper ws_url+="qp=#{options[:resource_type_property]}" end + if options[:display_key] + ws_url+='&display_key=true' + end + selected_resource = options[:selected_resource] if selected_resource - options[:selected_id]=selected_resource.id + options[:selected_id]= options[:display_key] ? "'" + selected_resource.key + "'" : selected_resource.id options[:selected_text]=selected_resource.name(true) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb index 61824824979..21c332a60c2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb @@ -3,6 +3,18 @@ +
  • + + <% selected_project = @project if @filter.criteria('componentRoots') %> + <%= message 'issue_filter.criteria.project' -%>: + <%= resource_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%', + :selected_resource => selected_project, + :display_key => true, + :placeholder => message('issue_filter.criteria.project'), + :html_id => 'select-project', + :allow_clear => true + -%> +
  • <%= message 'issue_filter.criteria.severities' -%>: <%= dropdown_tag 'severities[]', options_for_select(RulesConfigurationController::RULE_PRIORITIES, @filter.criteria('severities')), @@ -17,10 +29,24 @@
  • <%= message 'issue_filter.criteria.assignee' -%>: - <% selected_user = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %> - <%= user_select_tag('assignees', {:selected_user => selected_user, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'), + <% selected_assignee = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %> + <%= user_select_tag('assignees', {:selected_user => selected_assignee, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'), :html_id => 'select-assignee', :open => false, :allow_clear => true}) -%>
  • +
  • + <%= message 'issue_filter.criteria.reporter' -%>: + <% selected_reporter = @filter.issues_result.user(@filter.criteria('reporters')) if @filter.issues_result %> + <%= user_select_tag('reporters', {:selected_user => selected_reporter, :width => '100%', :placeholder => message('issue_filter.criteria.reporter'), + :html_id => 'select-reporter', :open => false, :allow_clear => true}) -%> +
  • +
  • + <%= message('issue_filter.criteria.created_after') -%>:
    + +
    + <%= message 'issue_filter.criteria.created_before' -%>:
    +
    + <%= message 'issue_filter.criteria.date_format' -%> +
  • <%= message 'issue_filter.new_search' -%>