dmp general tab changes
This commit is contained in:
parent
7e8a70e2d4
commit
77638fbf9d
|
@ -1,9 +1,10 @@
|
|||
|
||||
import {map, takeUntil } from 'rxjs/operators';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { BaseComponent } from '../../../../core/common/base/base.component';
|
||||
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
|
||||
import { DatasetProfileModel } from '../../../../core/model/dataset/dataset-profile';
|
||||
|
@ -19,7 +20,6 @@ import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-comp
|
|||
import { SingleAutoCompleteConfiguration } from '../../../../library/auto-complete/single/single-auto-complete-configuration';
|
||||
import { AddResearcherComponent } from '../add-researcher/add-researcher.component';
|
||||
import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-general-tab',
|
||||
|
@ -31,17 +31,34 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
@Input() formGroup: FormGroup = null;
|
||||
@Input() isNewVersion: boolean;
|
||||
|
||||
filteringOrganisationsAsync = false;
|
||||
filteringResearchersAsync = false;
|
||||
filteredProfilesAsync = false;
|
||||
filteredOrganisations: ExternalSourceItemModel[];
|
||||
filteredResearchers: ExternalSourceItemModel[];
|
||||
filteredProfiles: DatasetProfileModel[];
|
||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
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))),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
subtitleFn: (item) => item['description']
|
||||
};
|
||||
|
||||
profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
|
||||
dmpProfileAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterOrganisations.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
displayFn: (item) => item['name'],
|
||||
titleFn: (item) => item['name'],
|
||||
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
};
|
||||
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterResearchers.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterResearchers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
displayFn: (item) => item['name'],
|
||||
titleFn: (item) => item['name'],
|
||||
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
};
|
||||
dmpProfileAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
||||
filterFn: this.dmpProfileSearch.bind(this),
|
||||
initialItems: (extraData) => this.dmpProfileSearch(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
selectedDmpProfileDefinition: DmpProfileDefinition;
|
||||
|
||||
|
@ -63,43 +80,12 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
if (this.isNewVersion) {
|
||||
this.formGroup.get('label').disable();
|
||||
}
|
||||
|
||||
this.dmpProfileAutoCompleteConfiguration = {
|
||||
filterFn: this.dmpProfileSearch.bind(this),
|
||||
initialItems: (extraData) => this.dmpProfileSearch(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label']
|
||||
};
|
||||
|
||||
this.profilesAutoCompleteConfiguration = {
|
||||
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))),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
subtitleFn: (item) => item['description']
|
||||
};
|
||||
|
||||
this.organisationsAutoCompleteConfiguration = {
|
||||
filterFn: this.filterOrganisations.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
displayFn: (item) => item['name'],
|
||||
titleFn: (item) => item['name'],
|
||||
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
};
|
||||
|
||||
this.researchersAutoCompleteConfiguration = {
|
||||
filterFn: this.filterResearchers.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterResearchers('').pipe(map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
|
||||
displayFn: (item) => item['name'],
|
||||
titleFn: (item) => item['name'],
|
||||
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||
};
|
||||
}
|
||||
|
||||
registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void {
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(
|
||||
takeUntil(this._destroyed))
|
||||
takeUntil(this._destroyed))
|
||||
.subscribe(Option => {
|
||||
if (Option instanceof Object) {
|
||||
this.selectedDmpProfileDefinition = null;
|
||||
|
@ -140,26 +126,15 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
// }
|
||||
|
||||
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
|
||||
|
||||
this.filteredOrganisations = undefined;
|
||||
this.filteringOrganisationsAsync = true;
|
||||
|
||||
return this.externalSourcesService.searchDMPOrganizations(value);
|
||||
}
|
||||
|
||||
filterResearchers(value: string): Observable<ExternalSourceItemModel[]> {
|
||||
|
||||
this.filteredResearchers = undefined;
|
||||
this.filteringResearchersAsync = true;
|
||||
|
||||
return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
||||
}
|
||||
|
||||
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
|
||||
|
||||
this.filteredProfiles = undefined;
|
||||
this.filteredProfilesAsync = true;
|
||||
|
||||
const request = new RequestItem<DatasetProfileCriteria>();
|
||||
const criteria = new DatasetProfileCriteria();
|
||||
criteria.like = value;
|
||||
|
|
Loading…
Reference in New Issue