プロジェクト

全般

プロフィール

QA #1148

未完了

バージョン選択時の表示順番を調整したい

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

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

0%

予定工数:

説明

■現象/要望

チケットのバージョン選択時の表示順番を調整したい。

対象バージョン欄は、作業中バージョン(未完了)だけなので、選択時の問題は少ないが、
発見バージョン(カスタムフィールドのVersion)は、長期間の運用で選択肢が大量になり、誤認し易い。
名称?作成?順に表示されるようだが、表示順番を逆にできないか。

■解決策

app/models/version.rbの def <=>(version) を変更することで、ある程度修正可能(バージョン選択/ロードマップ表示順序一括)。

現状(Redmine4.1時点)

・期日が前のバージョンから表示
 期日未設定の場合、バージョン名称の昇順
 バージョン名称も同一の場合は、バージョンIDの昇順(古いものが先に表示される場合が多い)

この表示順序は、JPLが意図して設計したもの
Version numbering sort
https://redmine.org/issues/6881#note-2

Jean-Philippe Lang が9年以上前に更新
Versions are sorted by date then by name (alphabetically), 
so what you describe is not a defect (1.1 < 1.10 < 1.2 is alphabetically correct).
What you expect is some kind of version numbering sort when names looks like x.y where x and y are integers.

筆者の考え

・対象バージョンの場合、期日優先の表示は意味があるが、発見バージョンの場合、期日優先に表示することは無意味。
・発見バージョンは大量になるため、単純にバージョン名称でソートした方が選択し易い。
・新しく定義したバージョンを先に表示/選択可能とする方が、必要なバージョンを選択する時間を短縮できる。

暫定対策

期日の無視/優先表示により対処が異なる。
この順番は、ロードマップ、対象バージョン、発見バージョン共に影響する。

期日を無視し、バージョン名、バージョンIDの降順のみでソートする。
(文字列大きい方が新しい場合が多いため)

  # Versions are sorted by effective_date and name
  # Those with no effective_date are at the end, sorted by name
  def <=>(version)
       -1 * ( name == version.name ? id <=> version.id : name <=> version.name)
  end

期日指定バージョン優先、バージョン文字列は降順(文字列大きい方が新しい場合が多いため)

変更点:名前・バージョンIDの大小関係判定時に符号変えただけ(下記、-1 * の2か所)
app/models/version.rb

  # Versions are sorted by effective_date and name
  # Those with no effective_date are at the end, sorted by name
  def <=>(version)
    if self.effective_date
      if version.effective_date
        if self.effective_date == version.effective_date
          -1 *(name == version.name ? id <=> version.id : name <=> version.name)
        else
          self.effective_date <=> version.effective_date
        end
      else
        -1
      end
    else
      if version.effective_date
        1
      else
        -1 *(name == version.name ? id <=> version.id : name <=> version.name)
      end
   end
 end

■対応状況

パッチ作成済

■補足

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

  • 説明 を更新 (差分)
  • 担当者奈良 裕記 にセット

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

関連チケット多数、あちら立てればこちら立たず。。

redmine/field_format.rb: def edit_tag(view, tag_id, tag_name, custom_value, options={})
class VersionFormat < RecordList

app/views/issues/_form_custom_fields.html.erb

app/helpers/custom_fields_helper.rb

  1. Return custom field html tag corresponding to its format
    def custom_field_tag(prefix, custom_value)

    custom_value.custom_field.format.edit_tag(

models/version.rb

 # Versions are sorted by effective_date and name
  # Those with no effective_date are at the end, sorted by name
  def <=>(version)
    if self.effective_date
      if version.effective_date
        if self.effective_date == version.effective_date
          name == version.name ? id <=> version.id : name <=> version.name
        else
          self.effective_date <=> version.effective_date
        end
      else
        -1
      end
    else
      if version.effective_date
        1
      else
        name == version.name ? id <=> version.id : name <=> version.name
      end
   end
 end

ロードマップの表示順番調整

Define manually the versions order in Roadmap (when date isn't defined)
https://redmine.org/issues/6974

Completed versions on Roadmap: Sort it so that recently created versions are on top
https://www.redmine.org/issues/23137

ーーーーーーーーーーーーーーーーーーーーーーーー

ソート順変更
app/models/version.rb def <=>(version)
https://redmine.org/issues/6974#note-5

Completed versions on Roadmap: Sort it so that recently created versions are on top
https://www.redmine.org/issues/23137


Order of versions is not correctly ordered
https://redmine.org/issues/28035

Version numbering sort
https://redmine.org/issues/6881

Target version pulldown should sort in descending order
https://www.redmine.org/issues/4519

Add the posibility to set/change the position of an issue in a version
https://www.redmine.org/issues/22802

Define manually the versions order in Roadmap (when date isn't defined)
https://www.redmine.org/issues/6974
duplicates,Reopened,8080,Ability to specify target version sort order
duplicates,Closed,13681,Option to choose sorting versions in roadmap

Option for alphabetical only sorting of versions (date ignored)
https://redmine.org/issues/8080

relates,New,6881,Version numbering sort
https://redmine.org/issues/6881

duplicates,Closed,13681,Option to choose sorting versions in roadmap


https://www.redmine.org/projects/redmine/repository/revisions/16088/diff/trunk/app/controllers/versions_controller.rb
@completed_versions = @versions.select(&:completed?)
@completed_versions = @versions.select(&:completed?).reverse

バージョンのテキスト順と思っていたが、実際には発見バージョンの選択肢欄に別のテキストが混在している。
明らかにテキストのソートだけではない事を認識した。

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

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

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