Project

General

Profile

Actions

Defect #13385

closed

Searchable checkbox displayed on edit form for not-searchable custom field formats.

Added by David Leimbach about 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Category:
UI
Target version:
Start date:
Due date:
% Done:

90%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When updating a custom field (issue) to be searchable the checked box is not saved.

To reproduce: go to /custom_fields?tab=IssueCustomField
Click on field name to edit.
Click the checkbox next to Searchable.
Click save.
Click on field name again to edit.
Searchable is unchecked but should be checked.

Environment:
Redmine version 2.2.3.stable
Ruby version 1.8.7 (x86_64-linux)
Rails version 3.2.12
Environment production
Database adapter MySQL
Redmine plugins:
redmine_backlogs v0.9.36
redmine_plugin_views_revisions 0.0.1
redmine_users_xls_impex 0.1.1


Files

Actions #1

Updated by Mischa The Evil about 11 years ago

  • Status changed from New to Needs feedback
  • Assignee set to David Leimbach

Please make sure to test without plugins. This might be an issue with one of them.

Actions #2

Updated by David Leimbach about 11 years ago

I removed all plugins then restarted apache. The problem still happens.

my rake about
About your application's environment
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 2.0.0
Rack version 1.4
Rails version 3.2.12
Active Record version 3.2.12
Action Pack version 3.2.12
Active Resource version 3.2.12
Action Mailer version 3.2.12
Active Support version 3.2.12
Middleware Rack::Cache, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x7f2fc8dc1848>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport, OpenIdAuthentication
Environment production
Database adapter mysql
Database schema version 20121026003537

Actions #3

Updated by Mischa The Evil about 11 years ago

  • Resolution set to Cant reproduce

David Leimbach wrote:

I removed all plugins then restarted apache. The problem still happens.

[...]

I just tried it on *.m.redmine.org, which is running Redmine 2.2.3.stable.11411 on Rails 3.2.12 and Ruby 1.9.3 using SQLite as DB, and wasn't able to reproduce the reported issue. What is in your logs?

Actions #4

Updated by David Leimbach about 11 years ago

This is my log on save.

Started PUT "/custom_fields/1" for 10.1.20.1 at Mon Mar 11 16:01:44 +0200 2013
Processing by CustomFieldsController#update as HTML
Parameters: {"commit"=>"Save", "custom_field"=>{"min_length"=>"0", "default_value"=>"", "is_required"=>"0", "is_for_all"=>"1", "tracker_ids"=>["8", "1", "2", "3", "6", "7", ""], "max_length"=>"0", "searchable"=>"1", "regexp"=>"", "is_filter"=>"1", "name"=>"TFS ID"}, "id"=>"1", "utf8"=>"✓", "authenticity_token"=>"cK031SqTPXliqKUh5BbZEuZcY/UEh4PC6TTUwK/4NhU="}
Current user: davidl (id=3)
Redirected to http://projects.********.com/custom_fields?tab=IssueCustomField
Completed 302 Found in 52ms (ActiveRecord: 13.5ms)
Started GET "/custom_fields?tab=IssueCustomField" for 10.1.20.1 at Mon Mar 11 16:01:44 +0200 2013
Processing by CustomFieldsController#index as HTML
Parameters: {"tab"=>"IssueCustomField"}
Current user: davidl (id=3)
Rendered custom_fields/_index.html.erb (218.2ms)
Rendered custom_fields/_index.html.erb (1.6ms)
Rendered custom_fields/_index.html.erb (1.6ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered custom_fields/_index.html.erb (10.0ms)
Rendered custom_fields/_index.html.erb (1.6ms)
Rendered custom_fields/_index.html.erb (1.6ms)
Rendered custom_fields/_index.html.erb (1.5ms)
Rendered custom_fields/_index.html.erb (1.6ms)
Rendered common/_tabs.html.erb (253.7ms)
Rendered custom_fields/index.html.erb within layouts/admin (254.8ms)
Rendered admin/_menu.html.erb (11.9ms)
Rendered layouts/base.html.erb (39.0ms)
Completed 200 OK in 319ms (Views: 306.6ms | ActiveRecord: 4.1ms)
Started GET "/custom_fields?tab=IssueCustomField" for 10.1.20.1 at Mon Mar 11 16:01:44 +0200 2013
Processing by CustomFieldsController#index as */*
Parameters: {"tab"=>"IssueCustomField"}
Current user: davidl (id=3)
Rendered custom_fields/_index.html.erb (78.8ms)
Rendered custom_fields/_index.html.erb (1.9ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered custom_fields/_index.html.erb (9.8ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered custom_fields/_index.html.erb (2.0ms)
Rendered custom_fields/_index.html.erb (1.7ms)
Rendered common/_tabs.html.erb (115.2ms)
Rendered custom_fields/index.html.erb within layouts/admin (116.2ms)
Rendered admin/_menu.html.erb (11.5ms)
Rendered layouts/base.html.erb (39.3ms)
Completed 200 OK in 180ms (Views: 167.3ms | ActiveRecord: 4.5ms)

It's looking like this problem may be due to one of three plugins that I installed: redmine_backlogs v0.9.36, redmine_plugin_views_revisions 0.0.1, redmine_users_xls_impex 0.1.1

Unless an answer is apparent from the above log, I'll no require anything further.

Actions #5

Updated by David Leimbach about 11 years ago

After further testing this bug seems to be related to the format of the custom field. It happens with format integer and no other format that I can tell.

Actions #6

Updated by Mischa The Evil about 11 years ago

  • Subject changed from Custom Field Issue Searchable checkbox check not saved. to Custom fields Searchable checkbox check not saved when format is integer.
  • Status changed from Needs feedback to Confirmed
  • Assignee deleted (David Leimbach)
  • Resolution deleted (Cant reproduce)

David Leimbach wrote:

After further testing this bug seems to be related to the format of the custom field. It happens with format integer and no other format that I can tell.

You are right. I was finally able to reproduce the issue you have reported on *.m.redmine.org. It happens indeed only when trying to make a custom field (type isn't relevant) of the integer format searchable. As mentioned, the checkbox value is not saved upon the save-action.

Actions #7

Updated by Mischa The Evil over 10 years ago

  • Subject changed from Custom fields Searchable checkbox check not saved when format is integer. to Searchable checkbox value not saved with several custom field formats.
  • Target version set to Candidate for next minor release

After looking at this a second time I think this is more a UI issue because custom fields of formats integer, float, date and boolean can not be made searchable by explicit design (see source:/trunk/app/models/custom_field.rb@12202#L67). Despite that, the form element is rendered without any exceptions.

In case the design is not going to be changed (considering the custom values of these custom field formats, I think the best solution), this issue can be fixed by just hiding the form element for the appropriate custom field formats with a slight change like for example:

Index: app/views/custom_fields/_form.html.erb
===================================================================
--- app/views/custom_fields/_form.html.erb    (revision 12119)
+++ app/views/custom_fields/_form.html.erb    (working copy)
@@ -63,7 +63,9 @@
     <p><%= f.check_box :is_required %></p>
     <p><%= f.check_box :is_for_all %></p>
     <p><%= f.check_box :is_filter %></p>
-    <p><%= f.check_box :searchable %></p>
+    <% unless @custom_field.format_in? 'int', 'float', 'date', 'bool' %>
+      <p><%= f.check_box :searchable %></p>
+    <% end %>
     <p>
       <label><%= l(:field_visible) %></label>
       <label class="block">
@@ -92,7 +94,9 @@
 <% when "ProjectCustomField" %>
     <p><%= f.check_box :is_required %></p>
     <p><%= f.check_box :visible %></p>
-    <p><%= f.check_box :searchable %></p>
+    <% unless @custom_field.format_in? 'int', 'float', 'date', 'bool' %>
+      <p><%= f.check_box :searchable %></p>
+    <% end %>
     <p><%= f.check_box :is_filter %></p>

 <% when "VersionCustomField" %>

I haven't tested if this change breaks any existing tests (yet). Are there any functional tests needed?

Actions #8

Updated by Mischa The Evil over 10 years ago

  • Subject changed from Searchable checkbox value not saved with several custom field formats. to Searchable checkbox displayed on edit form for not-searchable custom field formats.
  • Category changed from Custom fields to UI

Mischa The Evil wrote:

[...] Despite that, the form element is rendered without any exceptions.

This actually is a regression introduced in r10163. Before that commit the searchable element was actually hidden from the form when not-searchable custom field formats were selected.

Additionally, looking at source:/trunk/app/views/custom_fields/_form.html.erb@10162, the searchable element should be hidden for user and version custom field formats too as these are implemented in r5272 as being not-searchable despite of the fact that they are not explicitly defined as such in source:/trunk/app/models/custom_field.rb@12202#L67. At the moment the value of the searchable element is incorrectly saved for user and version custom field formats which gives the impression that these can be searched while they by design can't.

Summary: the patch I posted in note-7 should be:
  1. extended to also exclude user and version custom field formats for the searchable form element
  2. extended to include a new change to source:/trunk/app/models/custom_field.rb@12202#L67 to explicitly define the user and version formats to be not-searchable (this would prevent the actual saving of the value of the searchable element)

I'll work on an updated patch.

Actions #9

Updated by Mischa The Evil over 10 years ago

  • Assignee set to Mischa The Evil

I started working on patches for this.

Actions #10

Updated by Mischa The Evil over 10 years ago

I have fixed both issues that have been discussed in this issue and provide two separate patches (against Redmine trunk @ r12224) that include these fixes along with corresponding tests.

Mischa The Evil wrote:

[...] At the moment the value of the searchable element is incorrectly saved for user and version custom field formats which gives the impression that these can be searched while they by design can't.
[...]
[...] include a new change to source:/trunk/app/models/custom_field.rb@12202#L67 to explicitly define the user and version formats to be not-searchable (this would prevent the actual saving of the value of the searchable element)

rm13385-do_not_set_searchable_for_user_and_version_cf-trunk_r12224.diff

Mischa The Evil wrote:

Mischa The Evil wrote:

[...] Despite that, the form element is rendered without any exceptions.

This actually is a regression introduced in r10163. Before that commit the searchable element was actually hidden from the form when not-searchable custom field formats were selected.

rm13385-do_not_present_searchable_for_not_searchable_cf_formats-trunk_r12224.diff

As stated, tests (both unit and functional) have been provided and I've made sure that the existing test suite didn't break.
Please review these changes and commit them if they are good enough. Otherwise, please let me know what I can do to further improve them.

Actions #11

Updated by Matt McSweyn over 10 years ago

Hi Mischa-
I've been watching this ticket because I have been waiting for a fix that will allow these types of custom fields to be searchable. However, it appears that you are "fixing" this so they are not searchable, i.e. removing the "Searchable" element from view and you note that it is by design that they are not searchable. Can you confirm this and if so, can you tell me why these fields should not be searchable?--I would much prefer that they are; I would prefer any custom field we add to be searchable.

Thanks.

Actions #12

Updated by Jean-Philippe Lang over 10 years ago

  • Target version changed from Candidate for next minor release to 2.5.0
Actions #13

Updated by Jean-Philippe Lang over 10 years ago

  • Status changed from Confirmed to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Fixed in 2.5.0.

Matt McSweyn wrote:

can you tell me why these fields should not be searchable?--I would much prefer that they are; I would prefer any custom field we add to be searchable.

Integers, floats and bools are not searchable because it doesn't make much sense to search these values for those that contain a certain string. A better option is to use filters on the issue list for these fields.

Actions

Also available in: Atom PDF