Skip to content
Snippets Groups Projects
Commit 5090db34 authored by felmer's avatar felmer
Browse files

SSDM-10066: Add warning message about the samples and data sets which will...

SSDM-10066: Add warning message about the samples and data sets which will also be deleted when the experiment is deleted.
parent 7ee34846
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,9 @@ function ExperimentFormController(mainController, mode, experiment) {
var id = new ExperimentPermId(experiment.permId);
var fetchOptions = new ExperimentFetchOptions();
fetchOptions.withProject().withSpace();
fetchOptions.withSamples().withProperties();
fetchOptions.withDataSets().withType();
fetchOptions.withDataSets().withProperties();
fetchOptions.withDataSets().withSample();
mainController.openbisV3.getExperiments([ id ], fetchOptions).done(function(map) {
_this._experimentFormModel.v3_experiment = map[id];
......
......@@ -104,12 +104,44 @@ function ExperimentFormView(experimentFormController, experimentFormModel) {
}
if (_this._allowedToDelete() && toolbarConfig.DELETE) {
//Delete
dropdownOptionsModel.push({
var maxNumToShow = 10;
var $component = $("<div>");
var experiment = this._experimentFormModel.v3_experiment;
var experimentKindName = ELNDictionary.getExperimentKindName(experiment.identifier.identifier).toLowerCase();
var samples = experiment.samples;
if (samples.length > 0) {
var warningText = "The " + experimentKindName + " has " + samples.length + " "
+ ELNDictionary.sample + "s, which will be also deleted:";
for (var cIdx = 0; cIdx < Math.min(maxNumToShow, samples.length); cIdx++) {
warningText += "<br>&nbsp;&nbsp;" + Util.getDisplayNameForEntity(samples[cIdx]);
}
if (maxNumToShow < samples.length) {
warningText += "<br>&nbsp;&nbsp;...";
}
var $warning = FormUtil.getFieldForLabelWithText(null, warningText);
$warning.css('color', FormUtil.warningColor);
$component.append($warning);
}
var dataSets = experiment.dataSets;
if (dataSets.length > 0) {
var warningText = "The " + experimentKindName + " has " + dataSets.length + " data sets "
+ "which will be also deleted:";
for (var cIdx = 0; cIdx < Math.min(maxNumToShow, dataSets.length); cIdx++) {
warningText += "<br>&nbsp;&nbsp;" + Util.getDisplayNameForEntity(dataSets[cIdx]);
}
if (maxNumToShow < dataSets.length) {
warningText += "<br>&nbsp;&nbsp;...";
}
var $warning = FormUtil.getFieldForLabelWithText(null, warningText);
$warning.css('color', FormUtil.warningColor);
$component.append($warning);
}
dropdownOptionsModel.push({
label : "Delete",
action : function() {
var modalView = new DeleteEntityController(function(reason) {
_this._experimentFormController.deleteExperiment(reason);
}, true);
}, true, null, $component);
modalView.init();
}
});
......
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