Project

General

Profile

Actions

Defect #41977

open

nested_set move node error

Added by yingchao wu 8 days ago. Updated 4 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Issues
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description


   1node6   ------------------------>    1node6        
    /  \                                    \
   /    \                                    \
 2node3  4node5                               2node5
                                               .
                                              .                                               
                                            3node5

in nest set when a node move to in the same root, then parent.lft need reload in the method target_lft

      def target_lft
        scope_for_max_rgt = self.class.where(:root_id => root_id).where(:parent_id => parent_id)
        if id
          scope_for_max_rgt = scope_for_max_rgt.where(id: ...id)
        end
        max_rgt = scope_for_max_rgt.maximum(:rgt)
        if max_rgt
          max_rgt + 1
        elsif parent

          # parent need reload lft, rgt
          parent.send :reload_nested_set_values

          parent.lft + 1
        else
          1
        end
      end
Actions

Also available in: Atom PDF