1. Change configuration of Zenodo to production.

2. Add default multiplicity placeholder and remove tooltip
3. Disable reordering of fields if template is finalized.
4. Create Dataset Wizard: Add prefilling functionality
This commit is contained in:
Konstantinos Triantafyllou 2021-12-22 15:59:58 +02:00
parent 814a9b2fee
commit c8b388b546
21 changed files with 545 additions and 206 deletions

View File

@ -1013,7 +1013,7 @@
<label>Zenodo</label>
<ordinal>1</ordinal>
<type>External</type>
<url>https://sandbox.zenodo.org/api/records/?page={page}&amp;size={pageSize}&amp;q="{like}"</url>
<url>https://zenodo.org/api/records/?page={page}&amp;size={pageSize}&amp;q="{like}"</url>
<firstPage>1</firstPage>
<contenttype>application/json</contenttype>
<data>
@ -1028,7 +1028,7 @@
</urlConfig>
</prefillingSearch>
<prefillingGet>
<url>https://sandbox.zenodo.org/api/records/{id}</url>
<url>https://zenodo.org/api/records/{id}</url>
<mappings>
<mapping source="metadata.title" target="label" />
<mapping source="metadata.description" target="description" />

View File

@ -45,6 +45,7 @@ import { UserService } from './services/user/user.service';
import { CollectionUtils } from './services/utilities/collection-utils.service';
import { TypeUtils } from './services/utilities/type-utils.service';
import { SpecialAuthGuard } from './special-auth-guard.service';
import {PrefillingService} from "@app/core/services/prefilling.service";
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
@ -118,7 +119,8 @@ export class CoreServiceModule {
deps: [ConfigurationService, HttpClient],
multi: true
},
LanguageInfoService
LanguageInfoService,
PrefillingService
],
};
}

View File

@ -0,0 +1,5 @@
export interface Prefilling {
pid: string;
name: string;
tag: string;
}

View File

@ -0,0 +1,25 @@
import {Injectable} from "@angular/core";
import {HttpClient, HttpHeaders} from "@angular/common/http";
import {BaseHttpService} from "@app/core/services/http/base-http.service";
import {ConfigurationService} from "@app/core/services/configuration/configuration.service";
import {Observable} from "rxjs";
import {Prefilling} from "@app/core/model/dataset/prefilling";
import {DatasetWizardModel} from "@app/core/model/dataset/dataset-wizard";
@Injectable()
export class PrefillingService {
private readonly actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'prefilling/';
}
public getPrefillingList(like: string, configId: string): Observable<Prefilling[]> {
return this.http.get<Prefilling[]>(this.actionUrl + 'list?configId=' + encodeURIComponent(configId) + '&like=' + encodeURIComponent(like), { headers: this.headers });
}
public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable<DatasetWizardModel> {
return this.http.get<DatasetWizardModel>(this.actionUrl + '/generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers });
}
}

View File

@ -981,11 +981,11 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
}
canGoUp(index: number): boolean {
return index > 0;
return index > 0 && !this.viewOnly;
}
canGoDown(index: number): boolean {
return index < (this.fieldsArray.length - 1);
return index < (this.fieldsArray.length - 1) && !this.viewOnly;
}
}

View File

@ -16,22 +16,28 @@ import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-
import {DmpService} from '@app/core/services/dmp/dmp.service';
import {ExternalSourcesConfigurationService} from '@app/core/services/external-sources/external-sources-configuration.service';
import {ExternalSourcesService} from '@app/core/services/external-sources/external-sources.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import {
SnackBarNotificationLevel,
UiNotificationService
} from '@app/core/services/notification/ui-notification-service';
import {SingleAutoCompleteConfiguration} from '@app/library/auto-complete/single/single-auto-complete-configuration';
import {DatasetCopyDialogueComponent} from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
import {DatasetWizardEditorModel} from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model';
import {BreadcrumbItem} from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
import {IBreadCrumbComponent} from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent';
import {DatasetDescriptionFormEditorModel} from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
import { Link, LinkToScroll, TableOfContents } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents';
import { BaseComponent } from '@common/base/base.component';
import {
Link,
LinkToScroll,
TableOfContents
} from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents';
import {FormService} from '@common/forms/form-service';
import {FormValidationErrorsDialogComponent} from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component';
import {ValidationErrorModel} from '@common/forms/validation/error-model/validation-error-model';
import {ConfirmationDialogComponent} from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import {TranslateService} from '@ngx-translate/core';
import * as FileSaver from 'file-saver';
import { Observable, of as observableOf, interval} from 'rxjs';
import {interval, Observable, of as observableOf} from 'rxjs';
import {catchError, debounceTime, filter, map, takeUntil} from 'rxjs/operators';
import {LockService} from '@app/core/services/lock/lock.service';
import {Location} from '@angular/common';
@ -47,6 +53,7 @@ import { HttpClient } from '@angular/common/http';
import {VisibilityRulesService} from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
import {PopupNotificationDialogComponent} from '@app/library/notification/popup/popup-notification.component';
import {CheckDeactivateBaseComponent} from '@app/library/deactivate/deactivate.component';
import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component";
@Component({
selector: 'app-dataset-wizard-component',
@ -131,7 +138,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.route
.data
.pipe(takeUntil(this._destroyed))
.subscribe(v => this.viewOnly = v['public']);
.subscribe(v => {
this.viewOnly = v['public'];
});
const dmpRequestItem: RequestItem<DmpCriteria> = new RequestItem();
dmpRequestItem.criteria = new DmpCriteria();
@ -198,10 +207,12 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.registerFormListeners();
if (lockStatus) {
this.dialog.open(PopupNotificationDialogComponent,{data:{
this.dialog.open(PopupNotificationDialogComponent, {
data: {
title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'),
message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE')
}, maxWidth:'30em'});
}, maxWidth: '30em'
});
}
// this.availableProfiles = this.datasetWizardModel.dmp.profiles;
})
@ -232,7 +243,24 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
this.formGroup.get('dmp').disable();
const dialogRef = this.dialog.open(PrefillDatasetComponent, {
width: '590px',
minHeight: '200px',
restoreFocus: false,
data: {
availableProfiles: this.formGroup.get('dmp').value.profiles,
},
panelClass: 'custom-modalbox'
});
dialogRef.afterClosed().subscribe(result => {
if(result) {
this.datasetWizardModel = this.datasetWizardModel.fromModel(result);
this.datasetWizardModel.dmp = data;
this.formGroup = this.datasetWizardModel.buildForm();
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.formGroup.get('dmp').disable();
}
})
this.loadDatasetProfiles();
this.registerFormListeners();
// this.availableProfiles = data.profiles;
@ -334,8 +362,16 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
const breadcrumbs = [];
breadcrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: '/explore' });
breadcrumbs.push({ parentComponentName: null, label: this.datasetWizardModel.label, url: '/datasets/publicEdit/' + this.datasetWizardModel.id });
breadcrumbs.push({
parentComponentName: null,
label: this.language.instant('NAV-BAR.PUBLIC DATASETS'),
url: '/explore'
});
breadcrumbs.push({
parentComponentName: null,
label: this.datasetWizardModel.label,
url: '/datasets/publicEdit/' + this.datasetWizardModel.id
});
this.breadCrumbs = observableOf(breadcrumbs);
}
});
@ -466,6 +502,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// this._listenersSubscription.add(uriSubscription);
// this._listenersSubscription.add(tagsSubscription);
}
// private _unregisterFormListeners(){
// this._listenersSubscription.unsubscribe();
// this._listenersSubscription = new Subscription();
@ -475,8 +512,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
if (dmp) {
this.formGroup.get('profile').enable();
this.loadDatasetProfiles();
}
else {
} else {
this.availableProfiles = [];
this.formGroup.get('profile').reset();
this.formGroup.get('profile').disable();
@ -531,7 +567,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.formGroup.get('status').setValue(DmpStatus.Draft);
this.onCallbackError(error);
}
)
} else {
this.publicMode ? this.router.navigate(['/explore']) : this.router.navigate(['/datasets']);
@ -542,8 +577,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
getDatasetDisplay(item: any): string {
if (!this.publicMode) {
return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label'];
} else {
return item['label'];
}
else { return item['label']; }
}
getDefinition(profileId: string) {
@ -616,7 +652,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// }
submit(saveType?: SaveType) {
this.scrollTop = document.getElementById('dataset-editor-form').scrollTop;
this.tocScrollTop = document.getElementById('stepper-options').scrollTop;
@ -632,17 +667,22 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
}
private _getErrorMessage(formControl: AbstractControl, name: string): string[] {
const errors: string[] = [];
Object.keys(formControl.errors).forEach(key => {
if (key === 'required') { errors.push(this.language.instant(name + ": " + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED'))); }
if (key === 'required') {
errors.push(this.language.instant(name + ": " + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED')));
}
// if (key === 'required') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + this.getPlaceHolder(formControl) + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED')); }
else if (key === 'email') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.EMAIL')); }
else if (key === 'min') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MIN-VALUE', { 'min': formControl.getError('min').min })); }
else if (key === 'max') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MAX-VALUE', { 'max': formControl.getError('max').max })); }
else { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + formControl.errors[key].message); }
else if (key === 'email') {
errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.EMAIL'));
} else if (key === 'min') {
errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MIN-VALUE', {'min': formControl.getError('min').min}));
} else if (key === 'max') {
errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MAX-VALUE', {'max': formControl.getError('max').max}));
} else {
errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + formControl.errors[key].message);
}
});
return errors;
}
@ -661,7 +701,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
}
private _buildSemiFormErrorMessages(): string[] {//not including datasetProfileDefinition
const errmess: string[] = [];
Object.keys(this.formGroup.controls).forEach(controlName => {
@ -796,7 +835,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
).subscribe(_ => {
this.viewOnly = false;
this.datasetWizardModel.status = DatasetStatus.Draft;
setTimeout(x => { this.formGroup = null; });
setTimeout(x => {
this.formGroup = null;
});
setTimeout(x => {
this.formGroup = this.datasetWizardModel.buildForm();
this.registerFormListeners();
@ -804,7 +845,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
});
}
saveFinalize() {
@ -845,11 +885,17 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
if (data) {
if (saveType === this.saveAnd.addNew) {
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'new', this.formGroup.get('dmp').value.id]); })
this.router.navigate(['/reload']).then(() => {
this.router.navigate(['/datasets', 'new', this.formGroup.get('dmp').value.id]);
})
} else if (saveType === this.saveAnd.close) {
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]); });
this.router.navigate(['/reload']).then(() => {
this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]);
});
} else if (saveType === SaveType.finalize) {
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); });
this.router.navigate(['/reload']).then(() => {
this.router.navigate(['/datasets', 'edit', data.id]);
});
} else {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
@ -1055,8 +1101,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
if (this.datasetWizardModel.isProfileLatestVersion || (this.datasetWizardModel.status === DatasetStatus.Finalized)
|| (this.datasetWizardModel.isProfileLatestVersion == undefined && this.datasetWizardModel.status == undefined)) {
return false;
}
else {
} else {
return true;
}
}
@ -1081,6 +1126,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
}
linkToScroll: LinkToScroll;
onStepFound(linkToScroll: LinkToScroll) {
this.linkToScroll = linkToScroll;
}
@ -1173,14 +1219,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// this.isDiscarded = false;
}
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false,
data: {
@ -1198,8 +1239,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
});
// this.isDiscarded = false;
}
@ -1222,9 +1261,11 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
printForm() {
console.log(this.formGroup);
}
printFormValue() {
console.log(this.formGroup.value);
}
touchForm() {
this.formGroup.markAllAsTouched();
this.showtocentriesErrors = true;
@ -1234,7 +1275,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); //TODO
// get tocentries(){
// const form = this.formGroup.get('datasetProfileDefinition')
// if(!form) return null;
@ -1336,7 +1376,6 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// });
// result.forEach((entry,i)=>{
// const sections = entry.form.get('sections') as FormArray;
@ -1356,6 +1395,4 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// }
}

View File

@ -0,0 +1,50 @@
<div class="template-container">
<div mat-dialog-title class="row d-flex m-0 header">
<span class="template-title align-self-center">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.TITLE' | translate}}</span>
<span class="ml-auto align-self-center" (click)="closeDialog()"><mat-icon
class="close-icon">close</mat-icon></span>
</div>
<div *ngIf="progressIndication" class="progress-bar">
<mat-progress-bar color="primary" mode="indeterminate"></mat-progress-bar>
</div>
<div mat-dialog-content *ngIf="prefillForm" [formGroup]="prefillForm" class="definition-content">
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="isPrefilled">
<button mat-raised-button type="button" class="empty-btn"
(click)="closeDialog()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.EMPTY' | translate}}</button>
<div class="ml-2 mr-2">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.OR' | translate}}</div>
<button mat-raised-button type="button" class="prefill-btn"
(click)="isPrefilled = true">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILL' | translate}}</button>
</div>
<div *ngIf="isPrefilled" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
{{profile.label}}
</mat-option>
</mat-select>
<mat-error *ngIf="prefillForm.get('profile').hasError('backendError')">{{prefillForm.get('profile').getError('backendError').message}}</mat-error>
</mat-form-field>
</div>
<div *ngIf="isPrefilled" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILLED-DATASET' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefill')"
placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.SEARCH' | translate}}"
[configuration]="prefillAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
</div>
</div>
<div *ngIf="isPrefilled">
<div class="col-auto d-flex pb-4 pt-2">
<button mat-raised-button type="button" class="prefill-btn ml-auto" [disabled]="prefillForm.invalid"
(click)="next()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.NEXT' | translate}}</button>
</div>
</div>
</div>

View File

@ -0,0 +1,57 @@
.template-container {
.header {
display: flex;
width: 100%;
height: 60px;
background-color: #f7dd72;
color: #212121;
font-size: 1.25rem;
}
.template-title {
margin-left: 37px;
white-space: nowrap;
width: 480px;
overflow: hidden;
text-overflow: ellipsis;
}
.close-icon {
cursor: pointer;
margin-right: 20px;
}
.close-icon:hover {
background-color: #fefefe6e !important;
border-radius: 50%;
}
.definition-content {
display: block;
margin: 0;
padding: 25px;
}
.empty-btn, .prefill-btn {
background: #f7dd72 0 0 no-repeat padding-box;
border: 1px solid #f7dd72;
border-radius: 30px;
opacity: 1;
width: 101px;
height: 43px;
color: #212121;
font-weight: 500;
}
.prefill-btn:disabled {
background: #a1a1a1 0 0 no-repeat padding-box;
border: 1px solid #a1a1a1;
opacity: 0.5;
}
.empty-btn {
background: #ffffff 0 0 no-repeat padding-box;
border: 1px solid #a1a1a1;
}
}

View File

@ -0,0 +1,76 @@
import {Component, Inject, OnInit} from "@angular/core";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {takeUntil} from "rxjs/operators";
import {ProgressIndicationService} from "@app/core/services/progress-indication/progress-indication-service";
import {BaseComponent} from "@common/base/base.component";
import {SingleAutoCompleteConfiguration} from "@app/library/auto-complete/single/single-auto-complete-configuration";
import {Observable} from "rxjs";
import {Prefilling} from "@app/core/model/dataset/prefilling";
import {PrefillingService} from "@app/core/services/prefilling.service";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
@Component({
selector: 'prefill-dataset-component',
templateUrl: 'prefill-dataset.component.html',
styleUrls: ['prefill-dataset.component.scss']
})
export class PrefillDatasetComponent extends BaseComponent implements OnInit {
progressIndication = false;
prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
configId: string = "zenodo";
isPrefilled: boolean = false;
prefillForm: FormGroup;
constructor(public dialogRef: MatDialogRef<PrefillDatasetComponent>,
private prefillingService: PrefillingService,
private progressIndicationService: ProgressIndicationService,
private fb: FormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any) {
super();
}
ngOnInit() {
this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
setTimeout(() => { this.progressIndication = x; });
});
this.prefillForm = this.fb.group({
type: this.fb.control(false),
profile: this.fb.control('', Validators.required),
prefill: this.fb.control(null, Validators.required)
})
if(this.data.availableProfiles && this.data.availableProfiles.length === 1) {
this.prefillForm.get('profile').patchValue(this.data.availableProfiles[0]);
}
this.prefillAutoCompleteConfiguration = {
filterFn: this.searchDatasets.bind(this),
initialItems: (extraData) => this.searchDatasets(''),
displayFn: (item) => (item['name'].length > 60)?(item['name'].substr(0, 60) + "..." ):item['name'],
titleFn: (item) => item['name'],
subtitleFn: (item) => item['pid']
};
}
public compareWith(object1: any, object2: any) {
return object1 && object2 && object1.id === object2.id;
}
searchDatasets(query: string): Observable<Prefilling[]> {
return this.prefillingService.getPrefillingList(query, this.configId);
}
next() {
if(this.isPrefilled) {
this.prefillingService.getPrefillingDataset(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.configId).subscribe(wizard => {
wizard.profile = this.prefillForm.get('profile').value;
this.closeDialog(wizard);
})
} else {
this.closeDialog();
}
}
closeDialog(result = null): void {
this.dialogRef.close(result);
}
}

View File

@ -28,6 +28,7 @@ import { DatasetCopyDialogModule } from './dataset-wizard/dataset-copy-dialogue/
import { DatasetCriteriaDialogComponent } from './listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component';
import { DatasetOverviewModule } from './overview/dataset-overview.module';
import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-editor.module";
import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component";
@NgModule({
imports: [
@ -62,6 +63,7 @@ import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-edit
DatasetUploadDialogue,
DatasetListingItemComponent,
DatasetCriteriaDialogComponent,
PrefillDatasetComponent
],
entryComponents: [
DatasetExternalDataRepositoryDialogEditorComponent,

View File

@ -24,7 +24,6 @@
}
::ng-deep .mat-icon-button {
height: 30px !important;
font-size: 12px !important;
}

View File

@ -20,12 +20,12 @@
</div>
<div *ngIf="(compositeFieldFormGroup.get('multiplicity').value.max - 1) > (compositeFieldFormGroup.get('multiplicityItems').length)"
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
class="pointer d-inline-flex align-items-center">
<span class="pointer d-inline-flex align-items-center">
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled">
<mat-icon>add_circle</mat-icon>
</button>
<span class="mt-1" *ngIf="compositeFieldFormGroup.get('multiplicity').value.placeholder">{{compositeFieldFormGroup.get('multiplicity').value.placeholder}}</span>
<span class="mt-1" *ngIf="!compositeFieldFormGroup.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">

View File

@ -32,12 +32,12 @@
</div>
<div *ngIf="(compositeFieldFormGroup.get('multiplicity').value.max - 1) > (compositeFieldFormGroup.get('multiplicityItems').length)"
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
class="pointer d-inline-flex align-items-center">
<span class="pointer d-inline-flex align-items-center">
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled">
<mat-icon>add_circle</mat-icon>
</button>
<span class="mt-1" *ngIf="compositeFieldFormGroup.get('multiplicity').value.placeholder">{{compositeFieldFormGroup.get('multiplicity').value.placeholder}}</span>
<span class="mt-1" *ngIf="!compositeFieldFormGroup.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">
@ -101,12 +101,12 @@
</div>
<div *ngIf="(fieldsetEntry.form.get('multiplicity').value.max - 1) > (fieldsetEntry.form.get('multiplicityItems').length)"
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
class="pointer d-inline-flex align-items-center">
<span class="pointer d-inline-flex align-items-center">
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="fieldsetEntry.form.disabled">
<mat-icon>add_circle</mat-icon>
</button>
<span class="mt-1" *ngIf="fieldsetEntry.form.get('multiplicity').value.placeholder">{{fieldsetEntry.form.get('multiplicity').value.placeholder}}</span>
<span class="mt-1" *ngIf="!fieldsetEntry.form.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="fieldsetEntry.form.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="fieldsetEntry.form">

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Additional Information",
"MULTIPLICITY-MIN": "Multiplicity Min",
"MULTIPLICITY-MAX": "Multiplicity Max",
"MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Order",
"COMMENT-PLACEHOLDER": "Please Specify",
"COMMENT-HINT": "Provide additional information or justification about your selection",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "DMP",
"PLACEHOLDER": "Bestehenden DMP auswählen"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -368,7 +368,7 @@
"MULTIPLICITY-MIN": "Multiplicity Min",
"MULTIPLICITY-MAX": "Multiplicity Max",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Order",
"COMMENT-PLACEHOLDER": "Please Specify",
"COMMENT-HINT": "Provide additional information or justification about your selection",
@ -386,7 +386,6 @@
"VIEW-STYLE": "Type",
"MULTIPLICITY-MIN": "Multiplicity Min",
"MULTIPLICITY-MAX": "Multiplicity Max",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"ORDER": "Order",
"DEFAULT-VALUE": "Default Value",
"VALIDATION": "Validation",
@ -1271,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "DMP",
"PLACEHOLDER": "Pick an existing DMP"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Información adicional",
"MULTIPLICITY-MIN": "Multiplicidad mínima",
"MULTIPLICITY-MAX": "Multiplicidad máxima",
"MULTIPLICITY-ADD-ONE-FIELD": "Añadir un elemento más",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Orden",
"COMMENT-PLACEHOLDER": "Por favir especifique",
"COMMENT-HINT": "Proporcione información adicional o justifique su selección",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "PGD",
"PLACEHOLDER": "Seleccione un PGD existente"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Επιπλέον Πληροφορίες",
"MULTIPLICITY-MIN": "Ελάχιστη τιμή Min",
"MULTIPLICITY-MAX": "Μέγιστη τιμή Max",
"MULTIPLICITY-ADD-ONE-FIELD": "Προσθήκη ακόμα ενός πεδίου",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Εντολή",
"COMMENT-PLACEHOLDER": "Παρακαλώ προσδιορίστε",
"COMMENT-HINT": "Προσθέστε επιπλέον πληροφορίες ή αιτιολόγηση σχετικά με την επιλογή σας",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "Σχέδιο Διαχείρισης Δεδομένων",
"PLACEHOLDER": "Επιλέξτε ένα Σχέδιο Διαχείρισης Δεδομένων από τη συλλογή σας"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Informação Adicional",
"MULTIPLICITY-MIN": "Multiplicidade Min",
"MULTIPLICITY-MAX": "Multiplicidade Máx",
"MULTIPLICITY-ADD-ONE-FIELD": "Adicionar mais um conjunto de campos",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Ordem",
"COMMENT-PLACEHOLDER": "Por favor especifique",
"COMMENT-HINT": "Disponibilize informação ou justificação adicional sobre a sua seleção",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "PGD",
"PLACEHOLDER": "Selecione um PGD existente"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Additional Information",
"MULTIPLICITY-MIN": "Multiplicity Min",
"MULTIPLICITY-MAX": "Multiplicity Max",
"MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Order",
"COMMENT-PLACEHOLDER": "Please Specify",
"COMMENT-HINT": "Provide additional information or justification about your selection",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "DMP",
"PLACEHOLDER": "Vybrať existujúci DMP."
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Dodatne informacije",
"MULTIPLICITY-MIN": "Višestrukost, minimalno polja",
"MULTIPLICITY-MAX": "Višestrukost, maksimalno polja",
"MULTIPLICITY-ADD-ONE-FIELD": "Dodajte jedan ili više skupova polja",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Redosled",
"COMMENT-PLACEHOLDER": "Navedite",
"COMMENT-HINT": "Navedite dodatne informacije ili obrazložite izbor",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "Plan upravljanja podacima",
"PLACEHOLDER": "Odaberite postojeći Plan"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {

View File

@ -367,7 +367,8 @@
"ADDITIONAL-INFORMATION": "Ek Bilgi",
"MULTIPLICITY-MIN": "En az Çokluk",
"MULTIPLICITY-MAX": "En fazla Çokluk",
"MULTIPLICITY-ADD-ONE-FIELD": "Bir alan seti daha ekle",
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
"MULTIPLICITY-ADD-ONE-FIELD": "Add more",
"ORDER": "Düzen",
"COMMENT-PLACEHOLDER": "Lütfen Belirtiniz",
"COMMENT-HINT": "Seçiminiz hakkında gerekçe veya ek bilgi veriniz",
@ -1269,6 +1270,16 @@
"FIRST-STEP": {
"TITLE": "VYP",
"PLACEHOLDER": "Mevcut olan bir VYP seçin"
},
"PREFILL-STEP": {
"TITLE": "Initialize your Dataset",
"PREFILL": "Prefill",
"OR": "OR",
"EMPTY": "Empty",
"PROFILE": "Dataset Template",
"PREFILLED-DATASET": "Prefilled Dataset",
"SEARCH": "Search a Dataset",
"NEXT": "Next"
}
},
"INVITATION-EDITOR": {