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