min multiplicity check for descriptions in dmp finalization
This commit is contained in:
parent
0c9601d6f0
commit
56a70636c3
|
@ -608,8 +608,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
|
||||
if (result && !result.cancelled) {
|
||||
if(!this.checkIfAnyProfileIsUsedLessThanMin(data)) {
|
||||
|
||||
this.checkIfAnyProfileIsUsedLessThanMin(data).subscribe(checked => {
|
||||
if (!checked) {
|
||||
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
||||
uuids: result.datasetsToBeFinalized
|
||||
};
|
||||
|
@ -635,6 +635,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
error => this.onUpdateCallbackError(error)
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -642,15 +643,16 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
private checkIfAnyProfileIsUsedLessThanMin(dmpModel: DmpModel): boolean {
|
||||
private checkIfAnyProfileIsUsedLessThanMin(dmpModel: DmpModel): Observable<boolean> {
|
||||
const blueprintId = dmpModel.profile.id;
|
||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(result => {
|
||||
result.definition.sections.forEach(section => {
|
||||
if(section.hasTemplates){
|
||||
section.descriptionTemplates.forEach(template => {
|
||||
if(template.minMultiplicity > 0) {
|
||||
return this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||
.pipe(map(result => {
|
||||
return result.definition.sections.some(section => {
|
||||
if(!section.hasTemplates)
|
||||
return false;
|
||||
return section.descriptionTemplates.some(template => {
|
||||
if(!(template.minMultiplicity > 0))
|
||||
return false;
|
||||
let count = 0;
|
||||
dmpModel.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => {
|
||||
if(dataset.profile.id === template.descriptionTemplateId){
|
||||
|
@ -664,14 +666,14 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
message: 'Add dataset.'
|
||||
}, maxWidth: '30em'
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
})
|
||||
})
|
||||
}), takeUntil(this._destroyed));
|
||||
}
|
||||
|
||||
// newVersion(id: String, label: String) {
|
||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
||||
|
|
Loading…
Reference in New Issue