workflow_hidden_field.diff

Gurvan Le Dromaguet, 2012-09-28 12:29

Download (4.79 KB)

View differences:

app/helpers/issues_helper.rb (working copy)
135 135
  end
136 136

  
137 137
  def render_custom_fields_rows(issue)
138
    return if issue.custom_field_values.empty?
138
    local_viewablecf=issue.viewable_custom_field_values
139
    return if local_viewablecf.empty?
139 140
    ordered_values = []
140
    half = (issue.custom_field_values.size / 2.0).ceil
141
    half = (local_viewablecf.size / 2.0).ceil
141 142
    half.times do |i|
142
      ordered_values << issue.custom_field_values[i]
143
      ordered_values << issue.custom_field_values[i + half]
143
      ordered_values << local_viewablecf[i]
144
      ordered_values << local_viewablecf[i + half]
144 145
    end
145 146
    s = "<tr>\n"
146 147
    n = 0
app/helpers/workflows_helper.rb (working copy)
25 25
  def field_permission_tag(permissions, status, field)
26 26
    name = field.is_a?(CustomField) ? field.id.to_s : field
27 27
    options = [["", ""], [l(:label_readonly), "readonly"]]
28
    options << [l(:label_hidden), "hidden"] unless field_required?(field)
28 29
    options << [l(:label_required), "required"] unless field_required?(field)
29 30

  
30 31
    select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
app/models/workflow_permission.rb (working copy)
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class WorkflowPermission < WorkflowRule
19
  validates_inclusion_of :rule, :in => %w(readonly required)
19
  validates_inclusion_of :rule, :in => %w(readonly required hidden)
20 20
  validate :validate_field_name
21 21

  
22 22
  # Replaces the workflow permissions for the given tracker and role
23 23
  #
24 24
  # Example:
25
  #   WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required'}}
25
  #   WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required', '3' => 'hidden'}}
26 26
  def self.replace_permissions(tracker, role, permissions)
27 27
    destroy_all(:tracker_id => tracker.id, :role_id => role.id)
28 28

  
app/models/issue.rb (working copy)
416 416
    end
417 417
  end
418 418

  
419
  # Returns the custom_field_values that can be viewed by the given user
420
  # For now: just exclude Fix Info and RNs, as it is printed seperately below description.
421
  def viewable_custom_field_values(user=nil)
422
    custom_field_values.reject do |value|
423
      hidden_attribute_names(user).include?(value.custom_field_id.to_s)
424
    end
425
  end
426

  
419 427
  # Returns the names of attributes that are read-only for user or the current user
420 428
  # For users with multiple roles, the read-only fields are the intersection of
421 429
  # read-only fields of each role
......
428 436
    workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
429 437
  end
430 438

  
439
  # Same as above, but for hidden fields
440
  def hidden_attribute_names(user=nil)
441
    workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'hidden'}.keys
442
  end
443

  
431 444
  # Returns the names of required attributes for user or the current user
432 445
  # For users with multiple roles, the required fields are the intersection of
433 446
  # required fields of each role
app/views/issues/_form_custom_fields.html.erb (working copy)
1 1
<div class="splitcontent">
2 2
<div class="splitcontentleft">
3 3
<% i = 0 %>
4
<% split_on = (@issue.custom_field_values.size / 2.0).ceil - 1 %>
4
<% split_on = (@issue.editable_custom_field_values.size / 2.0).ceil - 1 %>
5 5
<% @issue.editable_custom_field_values.each do |value| %>
6 6
  <p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
7 7
<% if i == split_on -%>
config/locales/en.yml (working copy)
867 867
  label_fields_permissions: Fields permissions
868 868
  label_readonly: Read-only
869 869
  label_required: Required
870
  label_hidden: " Hidden "
870 871
  label_attribute_of_project: "Project's %{name}"
871 872
  label_attribute_of_author: "Author's %{name}"
872 873
  label_attribute_of_assigned_to: "Assignee's %{name}"