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) => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
|
||||||
if (result && !result.cancelled) {
|
if (result && !result.cancelled) {
|
||||||
if(!this.checkIfAnyProfileIsUsedLessThanMin(data)) {
|
this.checkIfAnyProfileIsUsedLessThanMin(data).subscribe(checked => {
|
||||||
|
if (!checked) {
|
||||||
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
||||||
uuids: result.datasetsToBeFinalized
|
uuids: result.datasetsToBeFinalized
|
||||||
};
|
};
|
||||||
|
@ -635,6 +635,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
error => this.onUpdateCallbackError(error)
|
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;
|
const blueprintId = dmpModel.profile.id;
|
||||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
return this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(map(result => {
|
||||||
.subscribe(result => {
|
return result.definition.sections.some(section => {
|
||||||
result.definition.sections.forEach(section => {
|
if(!section.hasTemplates)
|
||||||
if(section.hasTemplates){
|
return false;
|
||||||
section.descriptionTemplates.forEach(template => {
|
return section.descriptionTemplates.some(template => {
|
||||||
if(template.minMultiplicity > 0) {
|
if(!(template.minMultiplicity > 0))
|
||||||
|
return false;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
dmpModel.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => {
|
dmpModel.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => {
|
||||||
if(dataset.profile.id === template.descriptionTemplateId){
|
if(dataset.profile.id === template.descriptionTemplateId){
|
||||||
|
@ -664,14 +666,14 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
message: 'Add dataset.'
|
message: 'Add dataset.'
|
||||||
}, maxWidth: '30em'
|
}, maxWidth: '30em'
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}), takeUntil(this._destroyed));
|
||||||
|
}
|
||||||
|
|
||||||
// newVersion(id: String, label: String) {
|
// newVersion(id: String, label: String) {
|
||||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
||||||
|
|
Loading…
Reference in New Issue