Set sequence order following the new position order
issue10299 review334181002
This commit is contained in:
1 parent
431ed0c2cd
commit
e5f07651b9
3 files changed
+29
-11
No files matched your search
+19
-6
@@ -493,10 +493,15 @@
|
||||
};
|
||||
return jQuery.when().then(browse_child);
|
||||
};
|
||||
array.set_sequence = function(field) {
|
||||
array.set_sequence = function(field, position) {
|
||||
var changed = false;
|
||||
var prev = null;
|
||||
var record, index, update, value;
|
||||
var record, index, update, value, cmp;
|
||||
if (position === 0) {
|
||||
cmp = function(a, b) { return a > b; };
|
||||
} else {
|
||||
cmp = function(a, b) { return a < b; };
|
||||
}
|
||||
for (var i=0; i < this.length; i++) {
|
||||
record = this[i];
|
||||
if (record.get_loaded([field]) || changed || record.id < 0) {
|
||||
@@ -510,12 +515,20 @@
|
||||
if (value === null) {
|
||||
if (index) {
|
||||
update = true;
|
||||
} else if (prev && (record.id >= 0)) {
|
||||
update = record.id < prev.id;
|
||||
} else if (prev) {
|
||||
if (record.id >= 0) {
|
||||
update = cmp(record.id, prev.id);
|
||||
} else if (position === 0) {
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
} else if (value === index) {
|
||||
if (prev && (record.id >= 0)) {
|
||||
update = record.id < prev.id;
|
||||
if (prev) {
|
||||
if (record.id >= 0) {
|
||||
update = cmp(record.id, prev.id);
|
||||
} else if (position === 0) {
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
} else if (value <= (index || 0)) {
|
||||
update = true;
|
||||
|
||||
+6
-3
@@ -3264,7 +3264,8 @@ function eval_pyson(value){
|
||||
this.screen.group.load(ids, true);
|
||||
prm = this.screen.display();
|
||||
if (sequence) {
|
||||
this.screen.group.set_sequence(sequence);
|
||||
this.screen.group.set_sequence(
|
||||
sequence, this.screen.new_position);
|
||||
}
|
||||
}
|
||||
prm.done(function() {
|
||||
@@ -3313,7 +3314,8 @@ function eval_pyson(value){
|
||||
var sequence = this._sequence();
|
||||
var update_sequence = function() {
|
||||
if (sequence) {
|
||||
this.screen.group.set_sequence(sequence);
|
||||
this.screen.group.set_sequence(
|
||||
sequence, this.screen.new_position);
|
||||
}
|
||||
}.bind(this);
|
||||
if (this.screen.current_view.type == 'form' ||
|
||||
@@ -3394,7 +3396,8 @@ function eval_pyson(value){
|
||||
});
|
||||
var sequence = this._sequence();
|
||||
if (sequence) {
|
||||
screen.group.set_sequence(sequence);
|
||||
screen.group.set_sequence(
|
||||
sequence, screen.new_position);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
||||
+4
-2
@@ -541,7 +541,8 @@
|
||||
row.rows.forEach(child_redraw);
|
||||
|
||||
if (this.attributes.sequence) {
|
||||
row.record.group.set_sequence(this.attributes.sequence);
|
||||
row.record.group.set_sequence(
|
||||
this.attributes.sequence, this.screen.new_position);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
@@ -1944,7 +1945,8 @@
|
||||
.then(function(record) {
|
||||
var sequence = this.tree.attributes.sequence;
|
||||
if (sequence) {
|
||||
record.group.set_sequence(sequence);
|
||||
record.group.set_sequence(
|
||||
sequence, this.tree.screen.new_position);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user