Skip to content

Commit

Permalink
Merge branch 'master' of github.com:neowit/redmine_last_updated_by_co…
Browse files Browse the repository at this point in the history
…lumn
  • Loading branch information
neowit committed Apr 27, 2013
2 parents 58926ae + cb3a9ed commit f72e3f2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ design.
- Black - updated by assignee


!["Tickets assigned to me"](https://github.com/neowit/redmine-last_updated_by_column/raw/master/Screenshots/My-Page-original.png)
!["Tickets assigned to me"](https://github.com/neowit/redmine_last_updated_by_column/raw/master/Screenshots/My-Page-original.png)

![My Tickets with "Updated By"](https://github.com/neowit/redmine-last_updated_by_column/raw/master/Screenshots/My-Page-custom.png)
![My Tickets with "Updated By"](https://github.com/neowit/redmine_last_updated_by_column/raw/master/Screenshots/My-Page-custom.png)

## Redmine version

Requires Redmine version 2.X. and Rails >= 3

## Installation

Copy last_updated_by_column folder into #{RAILS_ROOT}/plugins and restart the
Copy redmine_last_updated_by_column folder into #{RAILS_ROOT}/plugins and restart the
web server. Plugin does not change any data and no DB migration is required.

More details about Redmine plugin installation here: http://www.redmine.org/projects/redmine/wiki/Plugins
Expand All @@ -47,7 +47,7 @@ To display extra column on "My Page" add block `'Issues assigned to me with "Upd
via `"My Page" -> "Personalise this page"`.

When using "My Page" component you can personalise highlight style.
See `last_updated_by_column/assets/stylesheets/last_updated_by_column.css`
See `redmine_last_updated_by_column/assets/stylesheets/last_updated_by_column.css`

## Legal stuff

Expand Down
34 changes: 25 additions & 9 deletions app/views/my/blocks/_issues_with_last_updated_by.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
<h3><%=l(:label_assigned_to_me_issues_with_lastupdatedby)%> (<%= Issue.visible.open.count(:conditions => {:assigned_to_id => ([User.current.id] + User.current.group_ids)})%>)</h3>
<%
issuesassignedtome_items = Issue.visible.open.
where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).
limit(10).
includes(:status, :project, :tracker, :priority).
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
all
<%
all_statuses = IssueStatus.where(:is_closed => false)
selected_statuses = params[:my_issues_statuses] || session[:my_issues_statuses] || []
if selected_statuses == []
selected_statuses = all_statuses.map {|status| status.id.to_s}
else
session[:my_issues_statuses] = selected_statuses
end

issues_assigned_to_me = Issue.visible.open.
where(:assigned_to_id => ([User.current.id] + User.current.group_ids), :status_id => selected_statuses).
limit(10).
includes(:status, :project, :tracker, :priority).
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC").
all

%>

<% assigned_issues = issuesassignedtome_items %>
<% if all_statuses && all_statuses.any? %>
<%= form_tag('/my/page', :method => :get) do %>
<% for status in all_statuses %>
<%= check_box_tag("my_issues_statuses[]", status.id, selected_statuses.include?(status.id.to_s), :id => "my_issues_statuses#{status.id}" ) %>
<%= status.name%>
&nbsp;
<% end%>
<%= submit_tag('Refresh', :id => 'statuses_submit') %>
<% end %>
<% end%>
<% assigned_issues = issues_assigned_to_me %>
<% if assigned_issues && assigned_issues.any? %>
<%= form_tag({}) do %>
<table class="list issues">
Expand All @@ -25,7 +42,6 @@
<% for issue in assigned_issues %>
<tr id="issue-<%= h(issue.id) %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %>">
<td class="id">
<%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;', :id => nil) %>
<%= link_to(h(issue.id), :controller => 'issues', :action => 'show', :id => issue) %>
</td>
<td class="project"><%= link_to_project(issue.project) %></td>
Expand Down
6 changes: 3 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
Query.send(:include, LastUpdatedByQueryPatch) unless Query.included_modules.include? LastUpdatedByQueryPatch
end

Redmine::Plugin.register :last_updated_by_column do
Redmine::Plugin.register :redmine_last_updated_by_column do
name 'Redmine Issue "Last Updated By" column'
author 'Andrey Gavrikov'
description 'Display Name of the user who last updated Issue in the Issue lists.'
version '0.1'
url 'https://github.com/neowit/redmine-last_updated_by_column'
version '0.2.1'
url 'https://github.com/neowit/redmine_last_updated_by_column'
requires_redmine '2.1.0'


Expand Down
16 changes: 11 additions & 5 deletions lib/last_updated_by_issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ module InstanceMethods
# add a column to the +available_columns+ that isn't provided by the core.
# @param: no_default - if true then when Issue was created and has not have any updates then
# instead of Creator name and Id we return nil
# this is used in "Updated By" column on /issues page because we want
# to show blank value, otherwise sort order looks weird
def last_updated_by (no_default = false)
_sql = "select CONCAT_WS(' ', u.firstname, u.lastname) as name, u.id as id from #{Journal.table_name} as j1 inner join #{User.table_name} as u on u.id = j1.`user_id` where `journalized_type` = 'Issue' and `journalized_id` = #{id} order by j1.`id` DESC limit 1"
# this is used in "Updated By" column on /issues page because we want
# to show blank value, otherwise sort order looks weird
def last_updated_by (no_default = false)
sqlStr = ""
if ActiveRecord::Base.connection.adapter_name == "SQLite"
sqlStr = "select (u.firstname || ' ' || u.lastname) as name"
else #postgre and mysql
sqlStr = "select CONCAT_WS(' ', u.firstname, u.lastname) as name"
end
_sql = sqlStr + ", u.id as id from #{Journal.table_name} as j1 inner join #{User.table_name} as u on u.id = j1.`user_id` where `journalized_type` = 'Issue' and `journalized_id` = #{id} order by j1.`id` DESC limit 1"
result = ActiveRecord::Base.connection.select_one _sql
updated_by_name = ""
updated_by_id = nil
Expand All @@ -34,6 +40,6 @@ def last_updated_by_name
@last_updated_by_name ||= self.last_updated_by(true)[:name]
end

end
end
end

0 comments on commit f72e3f2

Please sign in to comment.