changeset 26cb1388a518 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=26cb1388a518
description:
        Position copied records based on order

        issue9474
        review311851002
diffstat:

 CHANGELOG     |  1 +
 src/model.js  |  8 ++++++--
 src/screen.js |  2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 6e3501f437fb -r 26cb1388a518 CHANGELOG
--- a/CHANGELOG Tue Jul 21 14:42:32 2020 +0200
+++ b/CHANGELOG Sat Jul 25 00:49:32 2020 +0200
@@ -1,3 +1,4 @@
+* Position copied records based on order
 * Sanitize translated RichtText fields content (issue9453)
 * Allow configuration of default colors for graph and calendar
 * Sanitize RichtText fields content (issue9405)
diff -r 6e3501f437fb -r 26cb1388a518 src/model.js
--- a/src/model.js      Tue Jul 21 14:42:32 2020 +0200
+++ b/src/model.js      Sat Jul 25 00:49:32 2020 +0200
@@ -79,7 +79,10 @@
                 this.__readonly = value;
             }
         });
-        array.load = function(ids, modified) {
+        array.load = function(ids, modified, position) {
+            if ((position === undefined) || (position == -1)) {
+                position = this.length;
+            }
             var new_records = [];
             var i, len;
             for (i = 0, len = ids.length; i < len; i++) {
@@ -88,7 +91,8 @@
                 if (!new_record) {
                     new_record = new Sao.Record(this.model, id);
                     new_record.group = this;
-                    this.push(new_record);
+                    this.splice(position, 0, new_record);
+                    position += 1;
                 }
                 new_records.push(new_record);
             }
diff -r 6e3501f437fb -r 26cb1388a518 src/screen.js
--- a/src/screen.js     Tue Jul 21 14:42:32 2020 +0200
+++ b/src/screen.js     Sat Jul 25 00:49:32 2020 +0200
@@ -1591,7 +1591,7 @@
             var records = this.current_view.selected_records;
             this.model.copy(records, this.context)
                 .then(function(new_ids) {
-                this.group.load(new_ids);
+                this.group.load(new_ids, false, this.new_position);
                 if (!jQuery.isEmptyObject(new_ids)) {
                     this.current_record = this.group.get(new_ids[0]);
                 }

Reply via email to