プロジェクト

全般

プロフィール

QA #1138

完了

Redmineでチケットのカスタムフィールドだけを変更した場合、「活動」一覧画面に表示されない。

奈良 裕記 さんがほぼ4年前に追加. 1年以上前に更新.

ステータス:
終了
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2020/05/30
期日:
進捗率:

0%

予定工数:

説明

[お知らせ] 11/5午後、redmine.tokyo第23回勉強会開催(無料、受付中、品川+Zoom+YouTubeLive) https://redmine-tokyo.connpass.com/event/261924/

■現象/要望
チケットのカスタムフィールドだけを変更した場合、「活動」一覧画面に表示されない。(チケット内の履歴では表示される)

チケットの管理項目をカスタムフィールドとして設定している場合、カスタムフィールドのみの変更も、そのプロジェクト内の活動履歴として扱うのが自然と思われる。

動作としては、journalsテーブルのnotesカラムに文字が入っていないと表示されない様子。

■解決策
h3. ■対応状況

#1192 パッチにより解決

■補足


関連するチケット 1 (1件未完了0件完了)

関連している Unofficial Redmine Cooking - QA #1192: Redmineの活動画面に、チケットの変更を全て表示する。回答済奈良 裕記2020/12/122020/12/12

操作

奈良 裕記 さんがほぼ4年前に更新

奈良 裕記 さんが3年以上前に更新

活動一覧に表示するイベント自体の追加

Redmineの活動画面に表示するイベントを選択しているのは下記コードである。

app/models/journal.rb:


class Journal < ActiveRecord::Base
・・・
  acts_as_activity_provider :type => 'issues',
                                      joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id").
                                      where("#{Journal.table_name}.journalized_type = 'Issue' AND" +
                                            " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct

このコードでは、チケットの更新で、status_idの変更 または、注記欄に何等かの文字が入力されている場合を選択している。
つまり、status_idに変更無い場合、カスタムフィールドの更新のみで注記欄の記入が無い場合には、活動欄に表示されない。(Redmine4.1時点ではこの処理となっている)

チケット内の管理項目としてカスタムフィールドを使用している場合、カスタムフィールドの変更もチケットの更新活動として把握したいのが当然。
また、スタータス以外のRedmine標準管理項目(担当者、優先度、期日、、)の変更も、チケットの変更として把握必要な場合がある。

標準管理項目、カスタムフィールド、注記のいずれかの変更時、活動欄に表示するには、上記の最終行を下記の様に変更すれば良い


 " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct

  ↑(標準)ステータス変更+コメント記入時のみ
  ↓チケット変更全部

 " (#{JournalDetail.table_name}.property = 'attr'  OR #{JournalDetail.table_name}.property = 'cf'  OR #{Journal.table_name}.notes <> '' )").distinct

奈良 裕記 さんが3年以上前に更新

活動画面には、Status以外の標準項目、カスタムフィールドが表示されない。
変更があったことのみを表示しても、実際には変更内容を確認必要になり、効果が低い。

/var/lib/redmine/app/views/activities

<dd class="<%= "grouped" if in_group >">
<span class="description">
<
= format_activity_description(e.event_description) %>
</span>

helpers/application_helper.rb
  # Used to format item titles on the activity view
  def format_activity_title(text)
    text
  end

  def format_activity_description(text)
    h(text.to_s.truncate(120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).
      gsub(/[\r\n]+/, "<br />").html_safe
  end

helpers/application_helper.rb

t _activities.html.erb 下記のevent.title部分

<%= link_to format_activity_title(e.event_title), e.event_url %>

上記のeventは下記に該当する。

app/models/issue.rb


class Issue < ActiveRecord::Base
・・・・
  acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
                :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
                :type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '') }

  acts_as_activity_provider :scope => preload(:project, :author, :tracker, :status),
                            :author_key => :author_id


/var/lib/redmine/app/views/issues/tabs/_history.html.erb

    <% if journal.details.any? %>
    <ul class="details">
      <% details_to_strings(journal.visible_details).each do |string| %>
       <li><%= string %></li>
      <% end %>
    </ul>

helpers/issues_helper.rb: def details_to_strings(details, no_html=false, options={})

  # Returns the textual representation of a journal details
  # as an array of strings
  def details_to_strings(details, no_html=false, options={})

  <div id="change-5819" class="journal has-details">
    <div id="note-9">
    <div class="contextual">
      <span class="journal-actions"></span>
      <a href="#note-9" class="journal-link">#9</a>
    </div>
    <h4 class='note-header'>

      <a class="user active" href="/redmine/users/1">Admin Redmine</a> さんが<a title="2020/12/07 01:33" href="/redmine/projects/testforynara/activity?from=2020-12-07">31分</a>前に更新
      <span id="journal-5819-private_notes" class=""></span>
    </h4>

    <ul class="details">
       <li><strong>トラッカー</strong> を <i>機能</i> から <i>Vote</i> に変更</li>
       <li><strong>plus1</strong> を <i>0</i> にセット</li>
    </ul>

    </div>
  </div>

奈良 裕記 さんが3年以上前に更新


MariaDB [redmine]> select * from journals where journalized_id=61337;
+------+----------------+------------------+---------+------------------------------------------+---------------------+---------------+
| id   | journalized_id | journalized_type | user_id | notes                                    | created_on          | private_notes |
+------+----------------+------------------+---------+------------------------------------------+---------------------+---------------+
| 5780 |          61337 | Issue            |       1 |                                          | 2020-08-14 19:09:56 |             0 |
| 5781 |          61337 | Issue            |       1 | CFと同時に注記も変更する 。
             | 2020-08-14 19:19:27 |             0 |
| 5782 |          61337 | Issue            |       1 |                                          | 2020-08-14 19:24:38 |             0 |
| 5783 |          61337 | Issue            |       1 |                                          | 2020-08-14 21:37:04 |             0 |
+------+----------------+------------------+---------+------------------------------------------+---------------------+---------------+
4 rows in set (0.001 sec)

MariaDB [redmine]> select * from journal_details where id >5862;
+------+------------+----------+-------------+--------------------------------+-------------------------------------------+
| id   | journal_id | property | prop_key    | old_value                      | value                                     |
+------+------------+----------+-------------+--------------------------------+-------------------------------------------+
| 5863 |       5780 | cf       | 46          | 必須                           | 必須フィールドの変更                      |
| 5864 |       5781 | cf       | 46          | 必須フィールドの変更           | Notes付で必須フィールドの変更             |
| 5865 |       5782 | attr     | status_id   | 1                              | 2                                         |
| 5866 |       5783 | attr     | priority_id | 2                              | 4                                         |
+------+------------+----------+-------------+--------------------------------+-------------------------------------------+
4 rows in set (0.001 sec)

奈良 裕記 さんが3年以上前に更新

そもそもチケット内の変更履歴を簡略化して表示すれば足りると思うんだが、
なんでactivitiyとして別にしたのだろう?
設計判断理由がわからない。

wikiなども含めて一括して変更をハンドリング可能にしたかったかもしれないが、、

チケット内変更履歴の場合
項目名 変更前→変更後 だが、
項目名 変更後(または差分)とか。

Activities右側で選択可能にするとか。

奈良 裕記 さんが3年以上前に更新

/var/lib/redmine/app/views/activities/_activities.html.erb


<div id="activity">
<% events_by_day.keys.sort.reverse_each do |day| %>
<h3><%= format_activity_day(day) %></h3>
<dl>
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
  <dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
  <%= avatar(e.event_author) if e.respond_to?(:event_author) %>
  <span class="time"><%= format_time(e.event_datetime, false) %></span>
  <%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
  <%= link_to format_activity_title(e.event_title), e.event_url %>
  </dt>
  <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
  <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
<% end -%>
</dl>
<% end -%>
</div>

[root@133-130-116-122 app]# grep -r details_to_strings *
helpers/issues_helper.rb: def details_to_strings(details, no_html=false, options={})
views/mailer/issue_edit.html.erb:<% details_to_strings(@journal_details, false, :only_path => false).each do |string| >
views/mailer/issue_edit.text.erb:<
details_to_strings(@journal_details, true).each do |string| ->
views/journals/index.builder: details_to_strings(change.visible_details, false).each do |string|
views/issues/_conflict.html.erb: <
details_to_strings(journal.details).each do |string| >
views/issues/tabs/_history.html.erb: <
details_to_strings(journal.visible_details).each do |string| %>
[root@133-130-116-122 app]#

奈良 裕記 さんが3年以上前に更新

  • ステータス新規 から 終了 に変更

#1192 にて公開したので終了とする。

奈良 裕記 さんが3年以上前に更新

  • 関連している QA #1192: Redmineの活動画面に、チケットの変更を全て表示する。 を追加

奈良 裕記 さんが約3年前に更新

奈良 裕記 さんが2年以上前に更新

奈良 裕記 さんが2年以上前に更新

奈良 裕記 さんが1年以上前に更新

他の形式にエクスポート: Atom PDF