Index: app/helpers/issues_helper.rb =================================================================== --- app/helpers/issues_helper.rb (revision 10483) +++ app/helpers/issues_helper.rb (working copy) @@ -135,12 +135,13 @@ end def render_custom_fields_rows(issue) - return if issue.custom_field_values.empty? + local_viewablecf=issue.viewable_custom_field_values + return if local_viewablecf.empty? ordered_values = [] - half = (issue.custom_field_values.size / 2.0).ceil + half = (local_viewablecf.size / 2.0).ceil half.times do |i| - ordered_values << issue.custom_field_values[i] - ordered_values << issue.custom_field_values[i + half] + ordered_values << local_viewablecf[i] + ordered_values << local_viewablecf[i + half] end s = "\n" n = 0 Index: app/helpers/workflows_helper.rb =================================================================== --- app/helpers/workflows_helper.rb (revision 10483) +++ app/helpers/workflows_helper.rb (working copy) @@ -25,6 +25,7 @@ def field_permission_tag(permissions, status, field) name = field.is_a?(CustomField) ? field.id.to_s : field options = [["", ""], [l(:label_readonly), "readonly"]] + options << [l(:label_hidden), "hidden"] unless field_required?(field) options << [l(:label_required), "required"] unless field_required?(field) select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name])) Index: app/models/workflow_permission.rb =================================================================== --- app/models/workflow_permission.rb (revision 10483) +++ app/models/workflow_permission.rb (working copy) @@ -16,13 +16,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WorkflowPermission < WorkflowRule - validates_inclusion_of :rule, :in => %w(readonly required) + validates_inclusion_of :rule, :in => %w(readonly required hidden) validate :validate_field_name # Replaces the workflow permissions for the given tracker and role # # Example: - # WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required'}} + # WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required', '3' => 'hidden'}} def self.replace_permissions(tracker, role, permissions) destroy_all(:tracker_id => tracker.id, :role_id => role.id) Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (revision 10483) +++ app/models/issue.rb (working copy) @@ -416,6 +416,14 @@ end end + # Returns the custom_field_values that can be viewed by the given user + # For now: just exclude Fix Info and RNs, as it is printed seperately below description. + def viewable_custom_field_values(user=nil) + custom_field_values.reject do |value| + hidden_attribute_names(user).include?(value.custom_field_id.to_s) + end + end + # Returns the names of attributes that are read-only for user or the current user # For users with multiple roles, the read-only fields are the intersection of # read-only fields of each role @@ -428,6 +436,11 @@ workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys end + # Same as above, but for hidden fields + def hidden_attribute_names(user=nil) + workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'hidden'}.keys + end + # Returns the names of required attributes for user or the current user # For users with multiple roles, the required fields are the intersection of # required fields of each role @@ -445,6 +458,12 @@ required_attribute_names(user).include?(name.to_s) end + # Returns true if the attribute should be hidden for user + def hidden_attribute?(name, user=nil) + logger.info("For " + name.to_s + ", It will return " + hidden_attribute_names(user).include?(name.to_s).to_s ) + hidden_attribute_names(user).include?(name.to_s) + end + # Returns a hash of the workflow rule by attribute for the given user # # Examples: Property changes on: app/views/issues ___________________________________________________________________ Added: svn:ignore + ._attributes.html.erb.swp .show.html.erb.swp Index: app/views/issues/show.html.erb =================================================================== --- app/views/issues/show.html.erb (revision 10483) +++ app/views/issues/show.html.erb (working copy) @@ -33,29 +33,33 @@ <%= issue_fields_rows do |rows| - rows.left l(:field_status), h(@issue.status.name), :class => 'status' - rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority' + unless @issue.hidden_attribute?('status') + rows.left l(:field_status), h(@issue.status.name), :class => 'status' + end + unless @issue.hidden_attribute?('priority') + rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority' + end - unless @issue.disabled_core_fields.include?('assigned_to_id') + unless @issue.disabled_core_fields.include?('assigned_to_id') || @issue.hidden_attribute?('assigned_to_id') rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to' end - unless @issue.disabled_core_fields.include?('category_id') + unless @issue.disabled_core_fields.include?('category_id') || @issue.hidden_attribute?('category_id') rows.left l(:field_category), h(@issue.category ? @issue.category.name : "-"), :class => 'category' end - unless @issue.disabled_core_fields.include?('fixed_version_id') + unless @issue.disabled_core_fields.include?('fixed_version_id') || @issue.hidden_attribute?('fixed_version_id') rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version' end - unless @issue.disabled_core_fields.include?('start_date') + unless @issue.disabled_core_fields.include?('start_date') || @issue.hidden_attribute?('start_date') rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date' end - unless @issue.disabled_core_fields.include?('due_date') + unless @issue.disabled_core_fields.include?('due_date') || @issue.hidden_attribute?('due_date') rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date' end - unless @issue.disabled_core_fields.include?('done_ratio') + unless @issue.disabled_core_fields.include?('done_ratio') || @issue.hidden_attribute?('done_ratio') rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress' end - unless @issue.disabled_core_fields.include?('estimated_hours') + unless @issue.disabled_core_fields.include?('estimated_hours') || @issue.hidden_attribute?('estimated_hours') unless @issue.estimated_hours.nil? rows.right l(:field_estimated_hours), l_hours(@issue.estimated_hours), :class => 'estimated-hours' end Index: app/views/issues/_form_custom_fields.html.erb =================================================================== --- app/views/issues/_form_custom_fields.html.erb (revision 10483) +++ app/views/issues/_form_custom_fields.html.erb (working copy) @@ -1,7 +1,7 @@
<% i = 0 %> -<% split_on = (@issue.custom_field_values.size / 2.0).ceil - 1 %> +<% split_on = (@issue.editable_custom_field_values.size / 2.0).ceil - 1 %> <% @issue.editable_custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

<% if i == split_on -%> Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 10483) +++ config/locales/en.yml (working copy) @@ -867,6 +867,7 @@ label_fields_permissions: Fields permissions label_readonly: Read-only label_required: Required + label_hidden: " Hidden " label_attribute_of_project: "Project's %{name}" label_attribute_of_author: "Author's %{name}" label_attribute_of_assigned_to: "Assignee's %{name}" Index: public/stylesheets/application.css =================================================================== --- public/stylesheets/application.css (revision 10483) +++ public/stylesheets/application.css (working copy) @@ -442,6 +442,7 @@ table.fields_permissions select {font-size:90%} table.fields_permissions td.readonly {background:#ddd;} table.fields_permissions td.required {background:#d88;} +table.fields_permissions td.hidden {background:#6E6E6E;} textarea#custom_field_possible_values {width: 99%} input#content_comments {width: 99%}