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

SUPPORT : Show Broken Weak References

SVN: 33754
parent 90fb28f1
No related branches found
No related tags found
No related merge requests found
......@@ -199,6 +199,28 @@ function SampleFormView(sampleFormController, sampleFormModel) {
currentParentsLinks,
this._sampleFormModel.mode === FormMode.CREATE || this._sampleFormModel.mode === FormMode.EDIT);
//
// LINKS TO CHILDREN
//
var requiredChildren = [];
if(sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_HINT"]) {
requiredChildren = sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_HINT"];
}
var sampleChildrenWidgetId = "sampleChildrenWidgetId";
var $sampleChildrenWidget = $("<div>", { "id" : sampleChildrenWidgetId });
$formColumn.append($sampleChildrenWidget);
var currentChildrenLinks = (this._sampleFormModel.sample)?this._sampleFormModel.sample.children:null;
this._sampleFormModel.sampleLinksChildren = new SampleLinksWidget(sampleChildrenWidgetId,
profile,
mainController.serverFacade,
"Children",
requiredChildren,
isDisabled,
currentChildrenLinks,
this._sampleFormModel.mode === FormMode.CREATE);
//
// LINKS
//
......@@ -211,7 +233,9 @@ function SampleFormView(sampleFormController, sampleFormModel) {
var $sampleLinksWidget = $("<div>", { "id" : sampleLinksWidgetId });
$formColumn.append($sampleLinksWidget);
var currentOrphanLinks = [];
var currentOrphanLinksIdentifiers = [];
var currentOrphanLinksPermIds = [];
//Read the XML to build the orphan links list
var annotationsFromSample = FormUtil.getAnnotationsFromSample(this._sampleFormModel.sample);
//Delete parents and children
......@@ -230,15 +254,41 @@ function SampleFormView(sampleFormController, sampleFormModel) {
//Make samples from Orphans left
if(annotationsFromSample) {
for(var orphanSamplePermId in annotationsFromSample) {
currentOrphanLinks.push(annotationsFromSample[orphanSamplePermId].identifier);
currentOrphanLinksIdentifiers.push(annotationsFromSample[orphanSamplePermId].identifier);
currentOrphanLinksPermIds.push(orphanSamplePermId);
}
}
var isPresentLinkOnData = function(orphanSamplePermId, data) {
for(var dIdx = 0; dIdx <data.length; dIdx++) {
if(data[dIdx].permId === orphanSamplePermId) {
return true;
}
}
return false;
}
var buildFakeSampleIfNotFoundLink = function(orphanSamplePermId, annotationsFromSample) {
var orphanSample = {};
orphanSample.notFound = true;
orphanSample.permId = orphanSamplePermId;
orphanSample.code = annotationsFromSample[orphanSamplePermId].identifier.split('/')[2];
orphanSample.identifier = annotationsFromSample[orphanSamplePermId].identifier;
orphanSample.sampleTypeCode = annotationsFromSample[orphanSamplePermId].sampleType;
return orphanSample;
}
var showLinksWidgetAction = function(data) {
for(var oIdx = 0; oIdx < currentOrphanLinksPermIds.length; oIdx++) {
if(!isPresentLinkOnData(currentOrphanLinksPermIds[oIdx], data)) {
data.push(buildFakeSampleIfNotFoundLink(currentOrphanLinksPermIds[oIdx], annotationsFromSample));
}
}
_this._sampleFormModel.sampleLinks = new SampleLinksWidget(sampleLinksWidgetId,
profile,
mainController.serverFacade,
"Links",
"Weak References",
requiredLinks,
isDisabled,
data,
......@@ -246,28 +296,6 @@ function SampleFormView(sampleFormController, sampleFormModel) {
_this._sampleFormModel.sampleLinks.repaint();
}
//
// LINKS TO CHILDREN
//
var requiredChildren = [];
if(sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_HINT"]) {
requiredChildren = sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_HINT"];
}
var sampleChildrenWidgetId = "sampleChildrenWidgetId";
var $sampleChildrenWidget = $("<div>", { "id" : sampleChildrenWidgetId });
$formColumn.append($sampleChildrenWidget);
var currentChildrenLinks = (this._sampleFormModel.sample)?this._sampleFormModel.sample.children:null;
this._sampleFormModel.sampleLinksChildren = new SampleLinksWidget(sampleChildrenWidgetId,
profile,
mainController.serverFacade,
"Children",
requiredChildren,
isDisabled,
currentChildrenLinks,
this._sampleFormModel.mode === FormMode.CREATE);
//
// GENERATE CHILDREN
//
......@@ -443,8 +471,8 @@ function SampleFormView(sampleFormController, sampleFormModel) {
this._sampleFormModel.sampleLinksParents.repaint();
this._sampleFormModel.sampleLinksChildren.repaint();
if(currentOrphanLinks.length !== 0) {
mainController.serverFacade.searchWithIdentifiers(currentOrphanLinks, showLinksWidgetAction);
if(currentOrphanLinksIdentifiers.length !== 0) {
mainController.serverFacade.searchWithIdentifiers(currentOrphanLinksIdentifiers, showLinksWidgetAction);
} else {
showLinksWidgetAction([]);
}
......
......@@ -495,7 +495,13 @@ function SampleLinksWidget(containerId, profile, serverFacade, title, sampleType
var codeLink = sampleToAdd.code;
if(this.isDisabled) {
codeLink = $("<a>").append(sampleToAdd.code);
var style = "";
var notFound = "";
if(sampleToAdd.notFound) {
style = "color: red;"
notFound = " (Not Found)"
}
codeLink = $("<a>", { "style" : style }).append(sampleToAdd.code + notFound);
codeLink.click(function() {
var url = document.location.href;
......
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