Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-03-06 12:03:14 +02:00
commit 391bf0bca1
4 changed files with 40 additions and 19 deletions

View File

@ -3,7 +3,7 @@
<mat-step class="step-container" [stepControl]="formGroup.get('dmpMeta')">
<ng-template matStepLabel>{{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}}</ng-template>
<form [formGroup]="formGroup.get('dmpMeta')">
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')">
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')" [datasetFormGroup]="formGroup.get('datasets')" [stepper]="stepper">
</dataset-dmp-selector-component>
</form>
<div class="col-12">
@ -20,7 +20,7 @@
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('dmpMeta').valid && isAvtive('step2')">
<div *ngIf="formGroup.get('dmpMeta').valid && isActive('step2')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp').value['label']">
@ -34,4 +34,4 @@
</div>
</mat-step>
</mat-horizontal-stepper>
</div>
</div>

View File

@ -42,7 +42,7 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
})
}
isAvtive(step: string): boolean {
isActive(step: string): boolean {
switch (step) {
case 'step1':
return this.stepper.selectedIndex==0;

View File

@ -1,14 +1,20 @@
<div class="dataset-dmp-selector" [formGroup]="formGroup" *ngIf="formGroup">
<mat-form-field class="col-md-6">
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}"
[configuration]="dmpAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
<mat-form-field class="col-md-6">
<mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" formControlName="datasetProfile">
<mat-option *ngFor="let datasetProfile of availableProfiles" [value]="datasetProfile">
{{datasetProfile.label}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-card>
<div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}"
[configuration]="dmpAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
</div>
<div>
<mat-form-field class="col-md-12" *ngIf="availableProfiles.length > 1">
<mat-select (selectionChange)="datasetChanged($event)" placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" formControlName="datasetProfile">
<mat-option *ngFor="let datasetProfile of availableProfiles" [value]="datasetProfile">
{{datasetProfile.label}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-card>
</div>

View File

@ -4,7 +4,7 @@ import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCru
import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { MatStepper, MatSnackBar } from '@angular/material';
import { FormGroup } from '@angular/forms';
import { FormGroup, FormArray } from '@angular/forms';
import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile';
import { takeUntil } from 'rxjs/operators';
import { RequestItem } from '../../../core/query/request-item';
@ -31,6 +31,8 @@ export class DatasetDmpSelector extends BaseComponent implements OnInit, IBreadC
breadCrumbs: Observable<BreadcrumbItem[]>;
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
@Input() formGroup: FormGroup;
@Input() datasetFormGroup: FormGroup;
@Input() stepper: MatStepper;
formControl: FormControl;
availableProfiles: DatasetProfileModel[] = [];
@ -60,6 +62,12 @@ export class DatasetDmpSelector extends BaseComponent implements OnInit, IBreadC
this.formGroup.get('datasetProfile').reset();
}
});
this.formGroup.get('datasetProfile').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
(this.datasetFormGroup.get('datasetsList') as FormArray).controls.length = 0;
});
}
searchDmp(query: string): Observable<DmpListingModel[]> {
@ -68,10 +76,9 @@ export class DatasetDmpSelector extends BaseComponent implements OnInit, IBreadC
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
dmpDataTableRequest.criteria = new DmpCriteria();
dmpDataTableRequest.criteria.like = query;
//const dmpListingModel =
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete")
.map(x => x.data);
.map(y => y.data);
}
loadDatasetProfiles() {
@ -83,7 +90,15 @@ export class DatasetDmpSelector extends BaseComponent implements OnInit, IBreadC
.pipe(takeUntil(this._destroyed))
.subscribe(items => {
this.availableProfiles = items;
if (this.availableProfiles.length === 1) {
this.formGroup.get('datasetProfile').patchValue(this.availableProfiles[0]);
this.stepper.next();
}
});
}
}
datasetChanged($event) {
this.stepper.next();
}
}