10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Redmineのチケット一覧にアイコンを表示する

Posted at

小ネタです。

Redmineではユーザーのメールアドレスと連動したGravatarのアイコンを表示することができます。
(管理→表示→Gravatarのアイコンを使用する)

しかしチケットの一覧画面では表示されないので、表示されるようにビューを変更してみました。

「この行を追加」と書いてある2行を追加します。

app/views/issues/_list.html.erb
<%= form_tag({}) do -%>
<%= hidden_field_tag 'back_url', url_for(params), :id => nil %>
<div class="autoscroll">
<table class="list issues <%= sort_css_classes %>">
  <thead>
    <tr>
      <th class="checkbox hide-when-print">
        <%= link_to image_tag('toggle_check.png'), {},
                              :onclick => 'toggleIssuesSelection(this); return false;',
                              :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
      </th>
      <th>icon</th> <!-- ←この行を追加 -->
      <% query.inline_columns.each do |column| %>
        <%= column_header(column) %>
      <% end %>
    </tr>
  </thead>
  <% previous_group = false %>
  <tbody>
  <% issue_list(issues) do |issue, level| -%>
  <% if @query.grouped? && (group = @query.group_by_column.value(issue)) != previous_group %>
    <% reset_cycle %>
    <tr class="group open">
      <td colspan="<%= query.inline_columns.size + 2 %>">
        <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
        <%= group.blank? ? l(:label_none) : column_content(@query.group_by_column, issue) %> <span class="count"><%= @i$
        <%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}",
                             "toggleAllRowGroups(this)", :class => 'toggle-all') %>
      </td>
    </tr>
    <% previous_group = group %>
  <% end %>
  <tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level >$
    <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
    <td><%= avatar(issue.assigned_to, :size => "30") %></td> <!-- ←この行を追加 -->
    <%= raw query.inline_columns.map {|column| "<td class=\"#{column.css_classes}\">#{column_content(column, issue)}</t$
  </tr>
  <% @query.block_columns.each do |column|
       if (text = column_content(column, issue)) && text.present? -%>
  <tr class="<%= current_cycle %>">
    <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td>
  </tr>
  <% end -%>
  <% end -%>
  <% end -%>
  </tbody>
</table>
</div>
<% end -%>

これでチケット一覧にもアイコンが表示されて誰のチケットか一目瞭然に。

プラグイン探したほうが早かったかも知れません。

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?