]> source.dussan.org Git - redmine.git/commitdiff
Added a checkbox on custom query form to explicitly say if the query uses default...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 1 Oct 2007 10:44:45 +0000 (10:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 1 Oct 2007 10:44:45 +0000 (10:44 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@783 e93f8b46-1217-0410-a6f0-8f06a7374b81

19 files changed:
app/controllers/queries_controller.rb
app/models/query.rb
app/views/queries/_columns.rhtml [new file with mode: 0644]
app/views/queries/_form.rhtml
lang/bg.yml
lang/cs.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fr.yml
lang/it.yml
lang/ja.yml
lang/nl.yml
lang/pl.yml
lang/pt-br.yml
lang/pt.yml
lang/ro.yml
lang/sv.yml
lang/zh.yml

index fce001cd8e35f215fc57f82e7ebdf88aec777d4b..7c8460dd7fe44a260c03128ce652b3457a3c5e1d 100644 (file)
@@ -31,6 +31,7 @@ class QueriesController < ApplicationController
     @query.user = logged_in_user
     @query.executed_by = logged_in_user
     @query.is_public = false unless current_role.allowed_to?(:manage_public_queries)
+    @query.column_names = nil if params[:default_columns]
     
     params[:fields].each do |field|
       @query.add_filter(field, params[:operators][field], params[:values][field])
@@ -52,7 +53,8 @@ class QueriesController < ApplicationController
       end if params[:fields]
       @query.attributes = params[:query]
       @query.is_public = false unless current_role.allowed_to?(:manage_public_queries)
-          
+      @query.column_names = nil if params[:default_columns]
+      
       if @query.save
         flash[:notice] = l(:notice_successful_update)
         redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
index c3d9d56e3c2a8b7367c567233b823233e4cad70f..400572eb274f9b35ee57287b96c380e6dc9104e9 100644 (file)
@@ -208,11 +208,10 @@ class Query < ActiveRecord::Base
   end
   
   def columns
-    if column_names && !column_names.empty?
-      available_columns.select {|c| column_names.include?(c.name) }
-    else
-      # default columns
+    if has_default_columns?
       available_columns.select {|c| c.default? }
+    else
+      available_columns.select {|c| column_names.include?(c.name) }
     end
   end
   
@@ -225,6 +224,10 @@ class Query < ActiveRecord::Base
   def has_column?(column)
     column_names && column_names.include?(column.name)
   end
+  
+  def has_default_columns?
+    column_names.nil? || column_names.empty?
+  end
 
   def statement
     # project/subprojects clause
diff --git a/app/views/queries/_columns.rhtml b/app/views/queries/_columns.rhtml
new file mode 100644 (file)
index 0000000..f233f8e
--- /dev/null
@@ -0,0 +1,7 @@
+<% content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %>
+<legend><%= l(:field_column_names) %></legend>
+<% query.available_columns.each do |column| %>
+<label><%= check_box_tag  'query[column_names][]', column.name, query.has_column?(column) %> <%= l("field_#{column.name}") %></label><br />
+<% end %>
+<%= hidden_field_tag 'query[column_names][]', '' %>
+<% end %>
index b4a4987cdf3ee661471b8ae0c9ba297b987dc2d8..a6b5a496c96ff97aa43a7069846b7740d8db1cfe 100644 (file)
   <%= check_box 'query', 'is_public' %></p>
 <% end %>
 
-<p><label for="query_column_names"><%=l(:field_column_names)%></label>
-<% @query.available_columns.each do |column| %>
-<%= check_box_tag  'query[column_names][]', column.name, @query.has_column?(column) %> <%= l("field_#{column.name}") %><br />
-<% end %>
-<%= hidden_field_tag 'query[column_names][]', '' %>
-</p>
+<p><label for="query_default_columns"><%=l(:label_default_columns)%></label>
+<%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns',
+      :onchange => 'if (this.checked) {Element.hide("columns")} else {Element.show("columns")}' %></p>
 </div>
 
+<%= render :partial => 'queries/columns', :locals => {:query => query}%>
 <%= render :partial => 'queries/filters', :locals => {:query => query}%>
 </div>
index d576142d1d87ace2389ffe06f035b2a15cd8e64b..231d593296884a7d564f84cd0f5433f0e4b20757 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Дейности (time tracking)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index 569002636c459065da54391cec2805667afcc959..3415677efb7ddcfc216a4283009f9d55c50bd438 100644 (file)
@@ -512,3 +512,4 @@ label_added_time_by: Added by %s %s ago
 field_estimated_hours: Estimated time
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index f2b5b069fe6301dc33d97c6b0befd6e642bc906b..c20cbf4e4c3512ec049212dc0bb5723e52273c65 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Aktivitäten (Zeiterfassung)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index 6e23f377fae86a747a57219496d0aa5fb8ec8b88..383b49150c8cc9d947f4de45df72db2d45e0f163 100644 (file)
@@ -423,6 +423,7 @@ label_updated_time: Updated %s ago
 label_jump_to_a_project: Jump to a project...
 label_file_plural: Files
 label_changeset_plural: Changesets
+label_default_columns: Default columns
 
 button_login: Login
 button_submit: Submit
index 82b0908a76dfb5cf58ac01bee8a55e2d1f780353..e467a5678bd07ffe7c2ee1e9c02df512eb0d9494 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Activities (time tracking)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index 68d329774f67c506ac77899676239b313d0175e5..129e91e4aab61af35d7ce2bcbd27c6bf5f289565 100644 (file)
@@ -423,6 +423,7 @@ label_updated_time: Mis à jour il y a %s
 label_jump_to_a_project: Aller à un projet...
 label_file_plural: Fichiers
 label_changeset_plural: Révisions
+label_default_columns: Colonnes par défaut
 
 button_login: Connexion
 button_submit: Soumettre
index 54b008580573e43b9f95511dafc5df1f78b87e47..3b16097e383ffad379a44f5599a54ac685e2aa31 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Attività (time tracking)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index 0e2628c609b84f07f8d9ae6adab6ca34098430ec..46c292b22b892edb9e9d0a8d9d8d81a4847444c5 100644 (file)
@@ -513,3 +513,4 @@ enumeration_activities: 作業分類 (時間トラッキング)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index 916040747f2026bb59736e4b9bb5080ec7aa9d6d..cc87f3110b4aa7da64418ce41d64ae218a45d0f5 100644 (file)
@@ -513,3 +513,4 @@ text_comma_separated: Multiple values allowed (comma separated).
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index a61974afa9d8141f5b88b2c2103b28363ba9f223..a575caf219ee18a4282f557c9045b670dfb1e644 100644 (file)
@@ -512,3 +512,4 @@ field_estimated_hours: Szacowany czas
 label_file_plural: Pliki
 label_changeset_plural: Zestawienia zmian
 field_column_names: Columns
+label_default_columns: Default columns
index e8f34b6d761ecd0c2ddce00a736af0cf69f42db1..f10a4e9b7223d4c69ef7e1734d3f31e18af13a4f 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Atividades (time tracking)
 label_file_plural: Files\r
 label_changeset_plural: Changesets\r
 field_column_names: Columns\r
+label_default_columns: Default columns\r
index f7cb5f91a5248e98c11f058b18d6fbcbb29824f5..0bab2d3f82f79688aacdde2adb1eb064be36d06c 100644 (file)
@@ -512,3 +512,4 @@ enumeration_activities: Atividades (time tracking)
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index d4cd69b37aaf4ca7eb6104a9c656bc4436eaa689..bc9100ff10457e4429b7e468f719f5859899bef4 100644 (file)
@@ -512,3 +512,4 @@ label_index_by_title: Index by title
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index ed5106a138ff2643b98df6ca796f6ed3078f438b..83488a4b9b386e974186eed191a2a80730a4d5d7 100644 (file)
@@ -513,3 +513,4 @@ field_comments: Comment
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns
index ec286878dbbf1cdd93361e8ec20b3099b0d5bee8..07d57c855534db72c8307f7cc4cceef4d3004345 100644 (file)
@@ -515,3 +515,4 @@ label_wiki_page: Wiki page
 label_file_plural: Files
 label_changeset_plural: Changesets
 field_column_names: Columns
+label_default_columns: Default columns