Commit e7231026 authored by flothoni's avatar flothoni
Browse files

Add a condition to use calculateOrder function

Also use new function removeDuplicate from tools.js
Link to #4541
parent 74cd7e22
......@@ -423,7 +423,7 @@ Model_loader.prototype = {
/**
* recalculating the array is sometimes necessary if the analysis and fused_file have diverged.
* @param {Array} arr [description]
* @param {Array} arr Order as loaded from analysis file
* @return {Array} [description]
*/
calculateOrder: function(arr) {
......@@ -471,6 +471,7 @@ Model_loader.prototype = {
copySampleFields: function(samples, analysis) {
var clone = $.extend({}, samples);
if ('id' in analysis) {
//replace names, timestamps, order...
dict = this.buildDict(analysis.id, clone.original_names);
......@@ -488,15 +489,15 @@ Model_loader.prototype = {
}
// Fix case of error where same timepoint is present multiple time in order
if (clone.order != undefined){
clone.order = removeDuplicate(clone.order)
}
if (analysis.order != undefined){
analysis.order = analysis.order.filter(function(item, pos) {
return analysis.order.indexOf(item) == pos;
})
analysis.order = removeDuplicate(analysis.order)
}
if (analysis.stock_order != undefined){
analysis.stock_order = analysis.stock_order.filter(function(item, pos) {
return analysis.stock_order.indexOf(item) == pos;
})
analysis.stock_order = removeDuplicate(analysis.stock_order)
}
if ('order' in analysis && 'stock_order' in analysis) {
......@@ -518,8 +519,8 @@ Model_loader.prototype = {
clone.order = Array.from(Array(this.samples.number).keys())
clone.stock_order = Array.from(Array(this.samples.number).keys())
}
} else if ('order' in analysis && !('stock_order' in analysis)) {
// Keep this behavior to ope old samples/analysis
} else if ('order' in analysis && !('stock_order' in analysis) && analysis.id.length != clone.original_names.length) {
clone.order = this.calculateOrder(clone.order);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment