[wip] add control for the min/max multiplicity of a description template used in a section of a dmp
This commit is contained in:
parent
db08662cac
commit
b68070aa01
|
@ -63,7 +63,7 @@
|
|||
<div class="profile-form">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
||||
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
|
||||
<mat-option *ngFor="let profile of availableProfiles" [value]="profile" (click)="checkMinMax($event, profile)">
|
||||
{{profile.label}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
|
|
@ -7,6 +7,10 @@ import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.co
|
|||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
||||
import { DatasetWizardEditorModel } from '../dataset-wizard-editor.model';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-editor-component',
|
||||
|
@ -25,6 +29,8 @@ export class DatasetEditorComponent extends BaseComponent {
|
|||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private dmpProfileService: DmpProfileService,
|
||||
private dialog: MatDialog,
|
||||
private guidedTourService: GuidedTourService,
|
||||
private language: TranslateService
|
||||
) { super(); }
|
||||
|
@ -44,6 +50,42 @@ export class DatasetEditorComponent extends BaseComponent {
|
|||
]
|
||||
};
|
||||
|
||||
checkMinMax(event, profile: DatasetProfileModel) {
|
||||
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
||||
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(result => {
|
||||
const section = result.definition.sections[dmpSectionIndex];
|
||||
if(section.hasTemplates){
|
||||
const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === profile.id);
|
||||
if (foundTemplate !== undefined) {
|
||||
let count = 0;
|
||||
if(this.formGroup.get('dmp').value.datasets != null){
|
||||
for(let dataset of this.formGroup.get('dmp').value.datasets){
|
||||
if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count === foundTemplate.maxMultiplicity){
|
||||
event.stopPropagation();
|
||||
this.dialog.open(ConfirmationDialogComponent, {
|
||||
data:{
|
||||
message: 'MAX DATASETS USING TEMPLATE',
|
||||
confirmButton: 'RETURN',
|
||||
cancelButton: 'CANCEL'
|
||||
},
|
||||
maxWidth:'30em'
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe(confirm=>{})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getDmpText(): string {
|
||||
return this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' +
|
||||
this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' +
|
||||
|
|
|
@ -268,7 +268,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
|||
});
|
||||
} else if (this.dmpId != null) {
|
||||
this.isNew = true;
|
||||
this.dmpService.getSingleNoDatasets(this.dmpId).pipe(map(data => data as DmpModel))
|
||||
this.dmpService.getSingle(this.dmpId).pipe(map(data => data as DmpModel))
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel();
|
||||
|
|
Loading…
Reference in New Issue