]> source.dussan.org Git - redmine.git/commitdiff
Add clear query icon next to selected query in sidebar (#31640).
authorGo MAEDA <maeda@farend.jp>
Sat, 14 Sep 2019 00:33:05 +0000 (00:33 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 14 Sep 2019 00:33:05 +0000 (00:33 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@18468 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/queries_helper.rb
public/stylesheets/application.css
test/functional/issues_controller_test.rb

index e08dd3003107cf3b92cdfe602aad31703945d08b..55b7d5812323e1b5126ad2f28f0144d0f9639460 100644 (file)
@@ -392,13 +392,21 @@ module QueriesHelper
       content_tag('ul',
         queries.collect {|query|
             css = +'query'
-            css << ' selected' if query == @query
-            content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
+            clear_link = +''
+            if query == @query
+              css << ' selected'
+              clear_link += link_to_clear_query
+            end
+            content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css) + clear_link.html_safe)
           }.join("\n").html_safe,
         :class => 'queries'
       ) + "\n"
   end
 
+  def link_to_clear_query
+    link_to l(:button_clear), { :set_filter => 1, :sort => '', :project_id => @project }, :class => 'icon-only icon-clear-query', :title => l(:button_clear)
+  end
+
   # Renders the list of queries for the sidebar
   def render_sidebar_queries(klass, project)
     queries = sidebar_queries(klass, project)
index 45bcc3d39e0f93f49d2a0e4aa4e9eea909b0078e..b2eb47167b24de8270f68b86c3eafa9c4f896469 100644 (file)
@@ -94,6 +94,8 @@ div#wrapper, div#wrapper2, div#wrapper3 { min-height: inherit; }
 #sidebar ul li, ul.flat li {list-style-type:none;margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;}
 #sidebar div.wiki ul {margin:inherit; padding-left:40px;}
 #sidebar div.wiki ul li {list-style-type:inherit;}
+#sidebar a.icon-only {opacity: 0.4; margin-left: 5px;}
+#sidebar a.icon-only:hover {opacity: 1;}
 
 #content { flex-grow: 1; background-color: #fff; margin: 0px; padding: 6px 10px 10px 10px; overflow-x: auto;}
 html>body #content { min-height: 600px; }
@@ -406,8 +408,6 @@ body.controller-issues .query-totals {margin-top:-2.3em;}
 td.center {text-align:center;}
 
 #watchers select {width: 95%; display: block;}
-#watchers a.delete {opacity: 0.4; margin-left: 5px;}
-#watchers a.delete:hover {opacity: 1;}
 #watchers img.gravatar {margin: 0 4px 2px 0;}
 
 span#watchers_inputs {overflow:auto; display:block;}
@@ -1515,6 +1515,7 @@ td.gantt_selected_column .gantt_hdr,.gantt_selected_column_container {
 .icon-sorted-desc { background-image: url(../images/arrow_up.png); }
 .icon-toggle-plus { background-image: url(../images/bullet_toggle_plus.png) }
 .icon-toggle-minus { background-image: url(../images/bullet_toggle_minus.png) }
+.icon-clear-query { background-image: url(../images/close_hl.png); }
 
 .icon-file { background-image: url(../images/files/default.png); }
 .icon-file.text-plain { background-image: url(../images/files/text.png); }
index 2945e8a0a3276327e38ca2edf2d434d751dbdddf..b9ef3bb278c4eff36e7baec605e4a75ede622e4f 100644 (file)
@@ -292,6 +292,17 @@ class IssuesControllerTest < Redmine::ControllerTest
         :query_id => 5
       }
     assert_response :success
+
+    assert_select '#sidebar .queries' do
+      # assert only query is selected in sidebar
+      assert_select 'a.query.selected', 1
+      # assert link properties
+      assert_select 'a.query.selected[href=?]', '/projects/ecookbook/issues?query_id=5', :text => "Open issues by priority and tracker"
+      # assert only one clear link exists
+      assert_select 'a.icon-clear-query', 1
+      # assert clear link properties
+      assert_select 'a.icon-clear-query[title=?][href=?]', 'Clear', '/projects/ecookbook/issues?set_filter=1&sort=', 1
+    end
   end
 
   def test_index_with_query_grouped_by_tracker