Support for Redmine 3.x
This commit is contained in:
parent
b91ed93a8d
commit
96d8c70ac2
12
README.md
12
README.md
@ -49,9 +49,9 @@ Restart Redmine and have a fun!
|
||||
|
||||
{{list_users(123)}} or {{list_users(identifier)}} or {{list_users(My project)}} := Lists all users of the project with project id 123 (or identifier or project name)
|
||||
|
||||
{{list_users(123, Manager)}} := Lists all users of the project with project id 123 and the role "Manager". If you want to use multiple roles as filters, you have to use a | as separator.
|
||||
{{list_users(123, title=Manager)}} := Lists all users of the project with project id 123 and the role "Manager". If you want to use multiple roles as filters, you have to use a | as separator.
|
||||
|
||||
{{list_users(123, Manager, Manager only)}} := Lists all users of the project with project id 123 and the role "Manager" and adds the heading "Manager only"
|
||||
{{list_users(123, title=Manager, role=Manager only)}} := Lists all users of the project with project id 123 and the role "Manager" and adds the heading "Manager only"
|
||||
|
||||
|
||||
### Project list macros
|
||||
@ -62,7 +62,7 @@ Lists projects of current user
|
||||
|
||||
{{list_projects}} := lists all projects of current users
|
||||
|
||||
{{list_projects(My title)}} := lists all projects of current users and adds the heading "My title"
|
||||
{{list_projects(title=My title)}} := lists all projects of current users and adds the heading "My title"
|
||||
|
||||
|
||||
### Wiki date macros
|
||||
@ -103,6 +103,12 @@ Note: Redmine must be restarted after changing "Custom Help URL"</tt> value befo
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.5.3
|
||||
|
||||
- Redmine 3.0.x and 3.1.x supported
|
||||
- "New issue" link with list_projects macro
|
||||
- Parameter syntax changed for list_users and list_projects marcos (sorry for that)
|
||||
|
||||
### 0.5.2
|
||||
|
||||
- "Edit closed issue" permission has been added
|
||||
|
@ -49,8 +49,8 @@ end
|
||||
<fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend>
|
||||
<% @trackers.each do |tracker| %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker), :id => nil %>
|
||||
<%=h tracker %>
|
||||
<%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.to_a.include?(tracker), :id => nil %>
|
||||
<%= tracker %>
|
||||
</label>
|
||||
<% end %>
|
||||
<%= hidden_field_tag 'project[tracker_ids][]', '' %>
|
||||
@ -64,7 +64,11 @@ end
|
||||
<%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field),
|
||||
:disabled => (custom_field.is_for_all? ? "disabled" : nil),
|
||||
:id => nil %>
|
||||
<%=h custom_field.name %>
|
||||
<% if ActiveRecord::VERSION::MAJOR < 4 %>
|
||||
<%= custom_field.name %>
|
||||
<% else %>
|
||||
<%= custom_field_name_tag(custom_field) %>
|
||||
<% end %>
|
||||
</label>
|
||||
<% end %>
|
||||
<%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %>
|
||||
|
@ -1,10 +1,15 @@
|
||||
<div class="projects box">
|
||||
<% if @list_title %><h3><%= @list_title %></h3><% end %>
|
||||
<% if list_title %><h3><%= list_title %></h3><% end %>
|
||||
<ul>
|
||||
<%
|
||||
@projects.each {|project| %>
|
||||
<li class="project <%= cycle("odd", "even") %>"><span style="font-weight: bold;"><%= link_to_project(project) %></span><%
|
||||
if project.homepage? %>: <%= link_to(project.homepage, project.homepage, @html_options) %><% end %></li>
|
||||
if project.homepage? %>: <%= link_to(project.homepage, project.homepage, @html_options) %><% end %>
|
||||
<% if with_create_issue %>
|
||||
<%= link_to('', {controller: 'issues',action: 'new', project_id: project },
|
||||
class: 'icon icon-add', title: l(:label_issue_new)) if User.current.allowed_to?(:add_issues, project) %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<div class="users box">
|
||||
<%
|
||||
if @list_title %><h3><%= @list_title %></h3><% end
|
||||
if list_title %><h3><%= list_title %></h3><% end
|
||||
users.each {|user| %>
|
||||
<div class="user box <%= cycle("odd", "even") %>">
|
||||
<div style="float: left; display: block; margin-right: 5px;"><%= avatar(user, :size => "50") %></div>
|
||||
<div class="user line" style="font-weight: bold;"><%= link_to(user.firstname + ' ' + user.lastname, '/users/' + user.id.to_s()) %></div>
|
||||
<% if user['role'] %><div class="user line"><%= l(:field_role) %>: <%= user['role'].join(", ").html_safe %></div><% end %>
|
||||
<% if user_roles[user.id] %><div class="user line"><%= l(:field_role) %>: <%= user_roles[user.id].join(", ").html_safe %></div><% end %>
|
||||
<div class="user line"><%= l(:field_login) %>: <%= link_to user.login, '/users/' + user.id.to_s() %></div>
|
||||
<% if !user.pref.hide_mail %>
|
||||
<div class="user line"><%= l(:field_mail) %>: <%= mail_to(h(user.mail), nil, :encode => 'javascript') %></div>
|
||||
|
2
init.rb
2
init.rb
@ -5,7 +5,7 @@ Redmine::Plugin.register :redmine_tweaks do
|
||||
name 'Redmine Tweaks'
|
||||
author 'AlphaNodes GmbH'
|
||||
description 'Wiki and content extensions'
|
||||
version '0.5.2'
|
||||
version '0.5.3'
|
||||
author_url 'https://alphanodes.com/'
|
||||
url 'https://github.com/alexandermeindl/redmine_tweaks'
|
||||
|
||||
|
@ -5,30 +5,43 @@ module RedmineTweaks
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
desc <<-EOHELP
|
||||
Display projects. Examples:
|
||||
Display projects.
|
||||
|
||||
Syntax:
|
||||
|
||||
{{list_projects(title=My project list,with_create_issue=BOOL)}}
|
||||
|
||||
Examples:
|
||||
|
||||
{{list_projects}}
|
||||
...List all project, which I am member of
|
||||
|
||||
{{list_projects(My project list)}}
|
||||
{{list_projects(title=My project list)}}
|
||||
...List all project with title "My project list", which I am member of
|
||||
|
||||
{{list_projects(with_create_issue=true)}}
|
||||
...List all project with link to create new issue, which I am member of
|
||||
|
||||
EOHELP
|
||||
|
||||
macro :list_projects do |obj, args|
|
||||
@list_title = args[0]
|
||||
args, options = extract_macro_options(args, :title, :with_create_issue)
|
||||
@projects = RedmineTweaks.load_projects
|
||||
return '' if @projects.nil?
|
||||
|
||||
@html_options = {:class => 'external'}
|
||||
render :partial => 'wiki/project_macros', :locals => {:projects => @projects, :html_options => @html_options, :list_title => @list_title}
|
||||
render :partial => 'wiki/project_macros', :locals => {:projects => @projects,
|
||||
:list_title => options[:title],
|
||||
:with_create_issue => options[:with_create_issue]}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.load_projects
|
||||
scope = Project
|
||||
scope = scope.active
|
||||
all_projects = scope.visible(User.current).find(:all, :order => "projects.name")
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
all_projects = Project.active.visible(User.current).find(:all, :order => "projects.name")
|
||||
else
|
||||
all_projects = Project.visible.sorted
|
||||
end
|
||||
my_projects = []
|
||||
all_projects.each do |p|
|
||||
if User.current.member_of?(p)
|
||||
|
@ -25,9 +25,10 @@ Display users. Examples:
|
||||
EOHELP
|
||||
|
||||
macro :list_users do |obj, args|
|
||||
args, options = extract_macro_options(args, :role, :title)
|
||||
|
||||
project_id = args[0]
|
||||
roles_limit = args[1]
|
||||
@list_title = args[2]
|
||||
user_roles = []
|
||||
|
||||
if project_id.present?
|
||||
project_id.strip!
|
||||
@ -37,26 +38,28 @@ EOHELP
|
||||
project ||= Project.visible.find_by_name(project_id)
|
||||
return '' if project.nil?
|
||||
|
||||
raw_users = User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id=(?))", project.id]).sort
|
||||
raw_users = User.active.where(["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id=(?))", project.id]).sort
|
||||
return '' if raw_users.nil?
|
||||
|
||||
users = [];
|
||||
users = []
|
||||
raw_users.each {|user|
|
||||
user['role'] = user.roles_for_project(project)
|
||||
if !roles_limit.present? or RedmineTweaks.check_role_matches(user['role'], roles_limit)
|
||||
user_roles[user.id] = user.roles_for_project(project)
|
||||
if !options[:role].present? or RedmineTweaks.check_role_matches(user_roles[user.id], options[:role])
|
||||
users << user
|
||||
end
|
||||
}
|
||||
else
|
||||
project_ids = Project.all(:conditions => Project.visible_condition(User.current)).collect(&:id)
|
||||
project_ids = Project.visible.collect(&:id)
|
||||
if project_ids.any?
|
||||
# members of the user's projects
|
||||
users = User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids]).sort
|
||||
users = User.active.where(["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids]).sort
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
render :partial => 'wiki/user_macros', :locals => {:users => users}
|
||||
render :partial => 'wiki/user_macros', :locals => {:users => users,
|
||||
:user_roles => user_roles,
|
||||
:list_title => options[:title]}
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user