プロジェクト

全般

プロフィール

Vote #78260

未完了

Changing the scope and resetting the position of an acts_as_positioned object inserts it at the one-before-last position

Admin Redmine さんが約2年前に追加.

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

0%

予定工数:
category_id:
0
version_id:
0
issue_org_id:
25141
author_id:
3866
assigned_to_id:
0
comments:
0
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

We have a model where objects should be appended to the list in the new scope when the list scope of the object is changed. We do this by setting the @self.position = nil@ before it is saved, unfortunately this inserts the object at the one-before-last position.

The following patch solves this problem:


diff --git a/lib/redmine/acts/positioned.rb b/lib/redmine/acts/positioned.rb
index 75041fe38..d3959a335 100644
--- a/lib/redmine/acts/positioned.rb
+++ b/lib/redmine/acts/positioned.rb
@@ -67,7 +67,7 @@ module Redmine

         def set_default_position
           if position.nil?
-            self.position = position_scope.maximum(:position).to_i + (new_record? ? 1 : 0)
+            self.position = position_scope.maximum(:position).to_i + ((new_record? || position_scope_changed?) ? 1 : 0)
           end
         end

This affects trunk.

表示するデータがありません

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

いいね!0