Skip to content

Commit

Permalink
Merge pull request #8 from AllTaken/Redmine_3.0.1
Browse files Browse the repository at this point in the history
Update to Redmine 3.0.1 + Misc
  • Loading branch information
alexwais committed Apr 1, 2015
2 parents 4b58ebe + ba3d651 commit df01eff
Show file tree
Hide file tree
Showing 17 changed files with 884 additions and 1,207 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ Corresponding issue on redmine.org: [#12005](http://www.redmine.org/issues/12005

- Configure hidden fields in workflows, thus per status and roles.

- Hidden fields don't show up for respective users on issues (views, table, forms, history), available columns & filters, exported .csv and .pdf files.
- Hidden fields don't show up for respective users on issues (views, table, forms, history), exported .csv and .pdf files.

- Completely hidden fields (fields that are configured to not be visible anywhere for the user) are removed from available columns & filters.


###Compatibility

The plugin was developed and tested with Redmine version 2.5.2.
The plugin was developed and tested with Redmine version 3.0.1.


###Installation
Expand Down
43 changes: 20 additions & 23 deletions app/views/issues/_history.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<% reply_links = authorize_for('issues', 'edit') -%>
<% for journal in journals %>
<% if details_to_strings(journal.details).any? || journal.notes.blank? == false %>
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
<div id="note-<%= journal.indice %>">
<h4><a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
<%= avatar(journal.user, :size => "24") %>
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
<%= content_tag('span', l(:field_is_private), :class => 'private') if journal.private_notes? %></h4>

<% if details_to_strings(journal.details).any? || journal.notes.blank? == false %>

<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
<div id="note-<%= journal.indice %>">
<h4><%= link_to "##{journal.indice}", {:anchor => "note-#{journal.indice}"}, :class => "journal-link" %>
<%= avatar(journal.user, :size => "24") %>
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></h4>

<% if journal.details.any? %>
<ul class="details">
<% details_to_strings(journal.visible_details).each do |string| %>
<li><%= string %></li>
<% end %>
</ul>
<% end %>
<%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
</div>
</div>
<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
<% if journal.details.any? %>
<ul class="details">
<% details_to_strings(journal.visible_details).each do |string| %>
<li><%= string %></li>
<% end %>
</ul>
<% end %>
<%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
</div>
</div>
<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
<% end %>
<% end %>

<% end %>

<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
85 changes: 68 additions & 17 deletions app/views/issues/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
<%= link_to_if @prev_issue_id,
"\xc2\xab #{l(:label_previous)}",
(@prev_issue_id ? issue_path(@prev_issue_id) : nil),
:title => "##{@prev_issue_id}" %> |
:title => "##{@prev_issue_id}",
:accesskey => accesskey(:previous) %> |
<% if @issue_position && @issue_count %>
<span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
<% end %>
<%= link_to_if @next_issue_id,
"#{l(:label_next)} \xc2\xbb",
(@next_issue_id ? issue_path(@next_issue_id) : nil),
:title => "##{@next_issue_id}" %>
:title => "##{@next_issue_id}",
:accesskey => accesskey(:next) %>
</div>
<% end %>

Expand All @@ -32,39 +34,88 @@
</p>

<table class="attributes">
<%= issue_fields_rows do |rows|

#adding unless stmts to hide 'hidden' fields

rows.left l(:field_status), h(@issue.status.name), :class => 'status' unless @issue.hidden_attribute?('status')
rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority' unless @issue.hidden_attribute?('priority_id')

<%= issue_fields_rows do |rows|
i = 0
unless @issue.hidden_attribute?('status')
rows.left l(:field_status), h(@issue.status.name), :class => 'status'
i += 1
end

unless @issue.hidden_attribute?('priority_id')
if i % 2 == 0
rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority'
else
rows.right l(:field_priority), h(@issue.priority.name), :class => 'priority'
end
i += 1
end
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'
if i % 2 == 0
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'
else
rows.right 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
i += 1
end

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'
if i % 2 == 0
rows.left l(:field_category), h(@issue.category ? @issue.category.name : "-"), :class => 'category'
else
rows.right l(:field_category), h(@issue.category ? @issue.category.name : "-"), :class => 'category'
end
i += 1
end
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'
if i % 2 == 0
rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
else
rows.right l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
end
i += 1
end

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'
if i % 2 == 0
rows.left l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
else
rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
end
i += 1
end
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'
if i % 2 == 0
rows.left l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
else
rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
end
i += 1
end
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'
if i % 2 == 0
rows.left l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress'
else
rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress'
end
i += 1
end

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'
if i % 2 == 0
rows.left l(:field_estimated_hours), l_hours(@issue.estimated_hours), :class => 'estimated-hours'
else
rows.right l(:field_estimated_hours), l_hours(@issue.estimated_hours), :class => 'estimated-hours'
end
i += 1
end
end
if User.current.allowed_to?(:view_time_entries, @project)
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), project_issue_time_entries_path(@project, @issue)) : "-"), :class => 'spent-time'
if i % 2 == 0
rows.left l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), issue_time_entries_path(@issue)) : "-"), :class => 'spent-time'
else
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), issue_time_entries_path(@issue)) : "-"), :class => 'spent-time'
end
end
end %>
<%= render_custom_fields_rows(@issue) %>
Expand Down
87 changes: 87 additions & 0 deletions app/views/queries/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<%= error_messages_for 'query' %>

<div class="box">
<div class="tabular">
<%= hidden_field_tag 'gantt', '1' if params[:gantt] %>

<p><label for="query_name"><%=l(:field_name)%></label>
<%= text_field 'query', 'name', :size => 80 %></p>

<% if User.current.admin? || User.current.allowed_to?(:manage_public_queries, @project) %>
<p><label><%=l(:field_visible)%></label>
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_PRIVATE %> <%= l(:label_visibility_private) %></label>
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_ROLES %> <%= l(:label_visibility_roles) %>:</label>
<% Role.givable.sorted.each do |role| %>
<label class="block role-visibility"><%= check_box_tag 'query[role_ids][]', role.id, @query.roles.include?(role), :id => nil %> <%= role.name %></label>
<% end %>
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_PUBLIC %> <%= l(:label_visibility_public) %></label>
<%= hidden_field_tag 'query[role_ids][]', '' %>
</p>
<% end %>

<p><label for="query_is_for_all"><%=l(:field_is_for_all)%></label>
<%= check_box_tag 'query_is_for_all', 1, @query.project.nil?,
:disabled => (!@query.new_record? && (@query.project.nil? || (@query.is_public? && !User.current.admin?))) %></p>

<% unless params[:gantt] %>
<fieldset><legend><%= l(:label_options) %></legend>
<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',
:onclick => 'if (this.checked) {$("#columns").hide();} else {$("#columns").show();}' %></p>

<p><label for="query_group_by"><%= l(:field_group_by) %></label>
<%= select 'query', 'group_by', @query.groupable_columns.collect {|c| [c.caption, c.name.to_s]}, :include_blank => true %></p>

<p><label><%= l(:button_show) %></label>
<%= available_block_columns_tags(@query) %></p>
</fieldset>
<% else %>
<fieldset><legend><%= l(:label_options) %></legend>
<p><label><%= l(:button_show) %></label>
<label class="inline"><%= check_box_tag "query[draw_relations]", "1", @query.draw_relations %> <%= l(:label_related_issues) %></label>
<label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
</p>
</fieldset>
<% end %>
</div>

<fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend>
<%= render :partial => 'queries/filters', :locals => {:query => query}%>
</fieldset>

<% unless params[:gantt] %>
<fieldset><legend><%= l(:label_sort) %></legend>
<% 3.times do |i| %>
<%= i+1 %>:
<%= label_tag "query_sort_criteria_attribute_" + i.to_s,
l(:description_query_sort_criteria_attribute), :class => "hidden-for-sighted" %>
<%= select_tag("query[sort_criteria][#{i}][]",
options_for_select([[]] + query.available_and_visible_columns.select(&:sortable?).collect {|column| [column.caption, column.name.to_s]}, @query.sort_criteria_key(i)),
:id => "query_sort_criteria_attribute_" + i.to_s)%>
<%= label_tag "query_sort_criteria_direction_" + i.to_s,
l(:description_query_sort_criteria_direction), :class => "hidden-for-sighted" %>
<%= select_tag("query[sort_criteria][#{i}][]",
options_for_select([[], [l(:label_ascending), 'asc'], [l(:label_descending), 'desc']], @query.sort_criteria_order(i)),
:id => "query_sort_criteria_direction_" + i.to_s) %>
<br />
<% end %>
</fieldset>
<% end %>

<% unless params[:gantt] %>
<%= content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %>
<legend><%= l(:field_column_names) %></legend>
<%= render_query_columns_selection(query) %>
<% end %>
<% end %>

</div>

<%= javascript_tag do %>
$(document).ready(function(){
$("input[name='query[visibility]']").change(function(){
var checked = $('#query_visibility_1').is(':checked');
$("input[name='query[role_ids][]'][type=checkbox]").attr('disabled', !checked);
}).trigger('change');
});
<% end %>
10 changes: 6 additions & 4 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'redmine'
require 'pdf'

ActionDispatch::Callbacks.to_prepare do
require_dependency 'issue'
Expand All @@ -15,19 +14,22 @@
require_dependency 'query'
Query.send(:include, RedmineWorkflowHiddenFields::QueryPatch)
QueryColumn.send(:include, RedmineWorkflowHiddenFields::QueryColumnPatch)
QueryCustomFieldColumn.send(:include, RedmineWorkflowHiddenFields::QueryCustomFieldColumnPatch)
require_dependency 'workflow_permission'
WorkflowPermission.send(:include, RedmineWorkflowHiddenFields::WorkflowPermissionPatch)
require_dependency 'workflows_helper'
WorkflowsHelper.send(:include, RedmineWorkflowHiddenFields::WorkflowsHelperPatch)
require_dependency 'redmine/export/pdf/issues_pdf_helper'
Redmine::Export::PDF::IssuesPdfHelper.send(:include, RedmineWorkflowHiddenFields::IssuesPdfHelperPatch)
end

Redmine::Plugin.register :redmine_workflow_hidden_fields do
requires_redmine :version_or_higher => '2.5.2'
requires_redmine :version_or_higher => '3.0.1'

name 'Redmine Workflow Hidden Fields plugin'
author 'Alexander Wais, et al.'
author 'Alexander Wais, David Robinson, et al.'
description "Provides a 'hidden' issue field permission for workflows"
version '0.1.2'
version '0.2.0'
url 'https://github.com/alexwais/redmine_workflow_hidden_fields'
author_url 'http://www.redmine.org/issues/12005'
end
Loading

0 comments on commit df01eff

Please sign in to comment.