Adds subtitles and hint on external data autocomplete

This commit is contained in:
apapachristou 2019-08-30 18:06:12 +03:00
parent eb48edfb2d
commit 46e62b01df
4 changed files with 18 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import { DatasetExternalDataRepositoryDialogEditorComponent } from './editors/da
import { DatasetExternalDatasetDialogEditorComponent } from './editors/external-dataset/dataset-external-dataset-dialog-editor.component'; import { DatasetExternalDatasetDialogEditorComponent } from './editors/external-dataset/dataset-external-dataset-dialog-editor.component';
import { DatasetExternalRegistryDialogEditorComponent } from './editors/registry/dataset-external-registry-dialog-editor.component'; import { DatasetExternalRegistryDialogEditorComponent } from './editors/registry/dataset-external-registry-dialog-editor.component';
import { DatasetExternalServiceDialogEditorComponent } from './editors/service/dataset-external-service-dialog-editor.component'; import { DatasetExternalServiceDialogEditorComponent } from './editors/service/dataset-external-service-dialog-editor.component';
import { TranslateService } from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-dataset-external-references-editor-component', selector: 'app-dataset-external-references-editor-component',
@ -45,6 +46,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
constructor( constructor(
private dialog: MatDialog, private dialog: MatDialog,
private router: Router, private router: Router,
private language: TranslateService,
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
private externalSourcesConfigurationService: ExternalSourcesConfigurationService private externalSourcesConfigurationService: ExternalSourcesConfigurationService
) { super(); } ) { super(); }
@ -67,7 +69,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1), initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
displayFn: (item) => item ? item.label : null, displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label : null, titleFn: (item) => item ? item.label : null,
subtitleFn: (item) => item ? item.tag : null, subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : null,
}; };
this.registriesAutoCompleteConfiguration = { this.registriesAutoCompleteConfiguration = {
@ -75,7 +77,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalRegistries('', type), initialItems: (type) => this.searchDatasetExternalRegistries('', type),
displayFn: (item) => item ? item.label : null, displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label : null, titleFn: (item) => item ? item.label : null,
subtitleFn: (item) => item ? item.tag : null subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : null
}; };
this.dataRepositoriesAutoCompleteConfiguration = { this.dataRepositoriesAutoCompleteConfiguration = {
@ -83,7 +85,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
displayFn: (item) => item ? item.name : null, displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null, titleFn: (item) => item ? item.name : null,
subtitleFn: (item) => item ? item.tag : null subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : null
}; };
this.servicesAutoCompleteConfiguration = { this.servicesAutoCompleteConfiguration = {
@ -91,14 +93,14 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
initialItems: (type) => this.searchDatasetExternalServices('', type), initialItems: (type) => this.searchDatasetExternalServices('', type),
displayFn: (item) => item ? item.label : null, displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label : null, titleFn: (item) => item ? item.label : null,
subtitleFn: (item) => item ? item.tag : null subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : null
}; };
this.tagsAutoCompleteConfiguration = { this.tagsAutoCompleteConfiguration = {
filterFn: this.searchDatasetTags.bind(this), filterFn: this.searchDatasetTags.bind(this),
initialItems: (type) => this.searchDatasetTags('', type), initialItems: (type) => this.searchDatasetTags('', type),
displayFn: (item) => item ? item.name : null, displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null titleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.name : null
}; };
} }

View File

@ -10,6 +10,7 @@ import { ProjectService } from '../../../../core/services/project/project.servic
import { FunderService } from '../../../../core/services/funder/funder.service'; import { FunderService } from '../../../../core/services/funder/funder.service';
import { FunderCriteria } from '../../../../core/query/funder/funder-criteria'; import { FunderCriteria } from '../../../../core/query/funder/funder-criteria';
import { ProjectCriteria } from '../../../../core/query/project/project-criteria'; import { ProjectCriteria } from '../../../../core/query/project/project-criteria';
import { TranslateService } from '@ngx-translate/core';
@Component({ @Component({
selector: 'app-grant-tab', selector: 'app-grant-tab',
@ -35,6 +36,7 @@ export class GrantTabComponent implements OnInit {
private grantService: GrantService, private grantService: GrantService,
private projectService: ProjectService, private projectService: ProjectService,
private funderService: FunderService, private funderService: FunderService,
private language: TranslateService,
public languageResolverService: LanguageResolverService public languageResolverService: LanguageResolverService
) { } ) { }
@ -48,21 +50,23 @@ export class GrantTabComponent implements OnInit {
initialItems: (extraData) => this.searchGrant(''), initialItems: (extraData) => this.searchGrant(''),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'], titleFn: (item) => item['label'],
subtitleFn: (item) => item ? item['source'] : null subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : null
}; };
this.projectAutoCompleteConfiguration = { this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this), filterFn: this.searchProject.bind(this),
initialItems: (extraData) => this.searchProject(''), initialItems: (extraData) => this.searchProject(''),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'] titleFn: (item) => item['label'],
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : null
} }
this.funderAutoCompleteConfiguration = { this.funderAutoCompleteConfiguration = {
filterFn: this.searchFunder.bind(this), filterFn: this.searchFunder.bind(this),
initialItems: (extraData) => this.searchFunder(''), initialItems: (extraData) => this.searchFunder(''),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'] titleFn: (item) => item['label'],
subtitleFn: (item) => item ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : null
} }
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0); this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);

View File

@ -9,6 +9,7 @@
<mat-form-field class="col-md-6"> <mat-form-field class="col-md-6">
<app-single-auto-complete [placeholder]="placeholder" [formControl]="formControl" [configuration]="autoCompleteConfiguration"> <app-single-auto-complete [placeholder]="placeholder" [formControl]="formControl" [configuration]="autoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>
<mat-hint>{{ 'DATASET-WIZARD.SECOND-STEP.EXTERNAL-HINT' | translate }}</mat-hint>
</mat-form-field> </mat-form-field>
<div class="col-12" *ngIf="formArray"> <div class="col-12" *ngIf="formArray">
<div class="row" *ngFor="let suggestion of formArray['controls']; let i = index"> <div class="row" *ngFor="let suggestion of formArray['controls']; let i = index">

View File

@ -356,7 +356,8 @@
"PROFILE": "Dataset Description Template" "PROFILE": "Dataset Description Template"
}, },
"SECOND-STEP": { "SECOND-STEP": {
"TITLE": "External References" "TITLE": "External References",
"EXTERNAL-HINT": "Options are fetched from an external source"
}, },
"THIRD-STEP": { "THIRD-STEP": {
"TITLE": "Description" "TITLE": "Description"
@ -763,6 +764,7 @@
"EXTERNAL-DATASET-TYPE": { "EXTERNAL-DATASET-TYPE": {
"SOURCE": "Source", "SOURCE": "Source",
"SOURCES": "Sources", "SOURCES": "Sources",
"SOURCE:": "Source: ",
"OUTPUT": "Output" "OUTPUT": "Output"
}, },
"DMP": { "DMP": {