Skip to content
Snippets Groups Projects
Commit 5bacd600 authored by juanf's avatar juanf
Browse files

SSDM-5537 : Bugfix race condition loading parents table in ELN object forms on...

SSDM-5537 : Bugfix race condition loading parents table in ELN object forms on view mode with parents of different types

SVN: 38699
parent 8dbfa009
No related branches found
No related tags found
No related merge requests found
...@@ -135,22 +135,31 @@ function LinksController(title, sampleTypeHints, isDisabled, samplesToEdit, show ...@@ -135,22 +135,31 @@ function LinksController(title, sampleTypeHints, isDisabled, samplesToEdit, show
this.addSamplesOnInit = function(samples) { this.addSamplesOnInit = function(samples) {
Util.blockUI(); Util.blockUI();
var samplesByType = {};
if(samples && samples.length > 0) { if(!linksModel.isDisabled) {
for(var sIdx = 0; sIdx < samples.length; sIdx++) { var samplesByType = {};
var sampleTypeCode = samples[sIdx].sampleTypeCode; if(samples && samples.length > 0) {
var samplesOfType = samplesByType[sampleTypeCode]; for(var sIdx = 0; sIdx < samples.length; sIdx++) {
if(!samplesOfType) { var sampleTypeCode = samples[sIdx].sampleTypeCode;
samplesOfType = []; var samplesOfType = samplesByType[sampleTypeCode];
samplesByType[sampleTypeCode] = samplesOfType; if(!samplesOfType) {
samplesOfType = [];
samplesByType[sampleTypeCode] = samplesOfType;
}
samplesOfType.push(samples[sIdx]);
} }
samplesOfType.push(samples[sIdx]);
} }
for(var type in samplesByType) {
linksView.updateSample(samplesByType[type], true, true);
}
} else {
// Only add once on view mode, there can be a race condition happening on this case
// Each time we add, the fuelux repeater html needs to load if is not cached by the browser, typically done the first time you use it during the day, but can vary due to caching policies.
// If the last load, don't finish last, all samples will not be displayed, this can only happen on view mode since all sample types share the same container and this corner case don't requires to load by type anyway.
linksView.updateSample(samples, true, true);
} }
for(var type in samplesByType) {
linksView.updateSample(samplesByType[type], true, true);
}
Util.unblockUI(); Util.unblockUI();
} }
......
...@@ -67,17 +67,15 @@ function LinksView(linksController, linksModel) { ...@@ -67,17 +67,15 @@ function LinksView(linksController, linksModel) {
} }
this.updateSample = function(sample, isAdd, isInit) { this.updateSample = function(sample, isAdd, isInit) {
var sampleTypeCode = null;
if(isInit) {
sampleTypeCode = sample[0].sampleTypeCode;
} else {
sampleTypeCode = sample.sampleTypeCode;
}
var containerCode = null; var containerCode = null;
if(!linksModel.isDisabled) { if(!linksModel.isDisabled) {
var sampleTypeCode = null;
if(isInit) {
sampleTypeCode = sample[0].sampleTypeCode;
} else {
sampleTypeCode = sample.sampleTypeCode;
}
containerCode = sampleTypeCode; containerCode = sampleTypeCode;
} }
...@@ -104,8 +102,6 @@ function LinksView(linksController, linksModel) { ...@@ -104,8 +102,6 @@ function LinksView(linksController, linksModel) {
} }
} }
if(isAdd && !isInit) { if(isAdd && !isInit) {
linksModel.samplesAdded.push(sample.identifier); linksModel.samplesAdded.push(sample.identifier);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment