Feature #8050 » workflow_hidden_field_v0.03.diff
| app/helpers/issues_helper.rb (working copy) | ||
|---|---|---|
|
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 = "<tr>\n"
|
||
|
n = 0
|
||
| app/helpers/workflows_helper.rb (working copy) | ||
|---|---|---|
|
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]))
|
||
| app/models/workflow_permission.rb (working copy) | ||
|---|---|---|
|
# 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)
|
||
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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:
|
||
| app/views/issues/show.html.erb (working copy) | ||
|---|---|---|
|
<table class="attributes">
|
||
|
<%= 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
|
||
| app/views/issues/_form_custom_fields.html.erb (working copy) | ||
|---|---|---|
|
<div class="splitcontent">
|
||
|
<div class="splitcontentleft">
|
||
|
<% 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| %>
|
||
|
<p><%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %></p>
|
||
|
<% if i == split_on -%>
|
||
| config/locales/en.yml (working copy) | ||
|---|---|---|
|
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}"
|
||
| public/stylesheets/application.css (working copy) | ||
|---|---|---|
|
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%}
|
||
- « Previous
- 1
- …
- 5
- 6
- 7
- Next »