Changes on create new dataset editor (2nd commit)

This commit is contained in:
apapachristou 2020-08-06 14:02:50 +03:00
parent d7fef01391
commit 8caad8bb3e
3 changed files with 37 additions and 4 deletions

View File

@ -83,7 +83,6 @@ import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/d
DmpCloneComponent, DmpCloneComponent,
AddOrganizationComponent, AddOrganizationComponent,
DmpCriteriaDialogComponent, DmpCriteriaDialogComponent,
AddOrganizationComponent,
AddCostComponent, AddCostComponent,
CostListingComponent, CostListingComponent,
StartNewDmpDialogComponent, StartNewDmpDialogComponent,

View File

@ -12,17 +12,25 @@
<div><span class="material-icons-outlined align-bottom">info</span> {{'DMP-EDITOR.MAIN-INFO.TYPING' | translate}}</div> <div><span class="material-icons-outlined align-bottom">info</span> {{'DMP-EDITOR.MAIN-INFO.TYPING' | translate}}</div>
</div> </div>
<div class="profile-form"> <div class="profile-form">
<mat-form-field appearance="outline"> <mat-form-field *ngIf="!isNewDataset">
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration"> <app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')"> <mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
{{formGroup.get('profiles').getError('backendError').message}}</mat-error> {{formGroup.get('profiles').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('profiles').hasError('required')"> <mat-error *ngIf="formGroup.get('profiles').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<button matSuffix class="input-btn" [disabled]="formGroup.get('profiles').disabled" (click)="availableProfiles($event)"> <button matSuffix class="input-btn" [disabled]="formGroup.get('profiles').disabled" (click)="allAvailableProfiles($event)">
<mat-icon class="icon-btn">view_list</mat-icon> <mat-icon class="icon-btn">view_list</mat-icon>
</button> </button>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="isNewDataset">
<mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" formControlName="profile" (click)="loadDatasetProfiles()">
<mat-option *ngFor="let profile of availableProfiles" [value]="profile.id">
{{profile.label}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('profile').hasError('backendError')">{{formGroup.get('profile').getError('backendError').message}}</mat-error>
</mat-form-field>
</div> </div>
<div class="col pb-3 d-flex"> <div class="col pb-3 d-flex">
<span class="not-found">{{'DMP-EDITOR.DATASET-INFO.FIND' | translate}}</span> <span class="not-found">{{'DMP-EDITOR.DATASET-INFO.FIND' | translate}}</span>

View File

@ -18,6 +18,8 @@ import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component'; import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component';
import { DmpEditorModel } from '../dmp-editor.model'; import { DmpEditorModel } from '../dmp-editor.model';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { RequestItem } from '@app/core/query/request-item';
import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service';
@Component({ @Component({
selector: 'dataset-info', selector: 'dataset-info',
@ -32,9 +34,12 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
@Input() isPublic: boolean; @Input() isPublic: boolean;
@Input() isFinalized: boolean; @Input() isFinalized: boolean;
@Input() isNewVersion: boolean; @Input() isNewVersion: boolean;
@Input() isNewDataset: boolean;
@Input() isClone: boolean; @Input() isClone: boolean;
@Output() onFormChanged: EventEmitter<any> = new EventEmitter(); @Output() onFormChanged: EventEmitter<any> = new EventEmitter();
availableProfiles: DatasetProfileModel[] = [];
selectedDmpProfileDefinition: DmpProfileDefinition; selectedDmpProfileDefinition: DmpProfileDefinition;
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
@ -42,6 +47,7 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
private language: TranslateService, private language: TranslateService,
private configurationService: ConfigurationService, private configurationService: ConfigurationService,
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
private datasetWizardService: DatasetWizardService,
private dialog: MatDialog, private dialog: MatDialog,
private _service: DmpService, private _service: DmpService,
private dmpProfileService: DmpProfileService, private dmpProfileService: DmpProfileService,
@ -73,8 +79,11 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date()); this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date());
} }
// this.loadDatasetProfiles();
this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) this.formGroup.valueChanges.pipe(takeUntil(this._destroyed))
.subscribe(x => { .subscribe(x => {
console.log('value changes')
this.profilesAutoCompleteConfiguration = { this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this), filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
@ -114,7 +123,24 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
}) })
} }
availableProfiles(event: MouseEvent) { loadDatasetProfiles() {
console.log(this.formGroup);
console.log(this.dmp);
const datasetProfileRequestItem: RequestItem<DatasetProfileCriteria> = new RequestItem();
datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
console.log(this.formGroup.value.id);
datasetProfileRequestItem.criteria.id = this.formGroup.value.id;
if (datasetProfileRequestItem.criteria.id) {
this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem)
.pipe(takeUntil(this._destroyed))
.subscribe(items => {
this.availableProfiles = items;
});
}
console.log(this.availableProfiles);
}
allAvailableProfiles(event: MouseEvent) {
event.stopPropagation(); event.stopPropagation();
const dialogRef = this.dialog.open(AvailableProfilesComponent, { const dialogRef = this.dialog.open(AvailableProfilesComponent, {
data: { data: {