Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

add more affiliation autocomplete #265

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/app/core/services/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,7 @@ export class AppConfigService {
}
},
value: {
autocompletionConfig: {
url: `${environment.baseUrl}/api/institutions/_suggest?affiliation=`,
path: '/affiliation/0/options',
size: 20,
itemTemplateName: 'affiliationAutocompleteTemplate',
onCompletionSelect: (path, completion, store) => {
path.splice(-1, 1, 'record', '$ref');
store.setIn(path, completion.payload['$ref']);
path.splice(-2, 2, 'curated_relation');
store.setIn(path, true);
}
}
autocompletionConfig: this.commonConfigsService.affiliationAutocompletionConfig
}
}
}
Expand Down Expand Up @@ -342,6 +331,15 @@ export class AppConfigService {
}
}
},
record_affiliations: {
items: {
properties: {
value: {
autocompletionConfig: this.commonConfigsService.affiliationAutocompletionConfig
}
}
}
},
references: {
sortable: true,
longListNavigatorConfig: {
Expand Down Expand Up @@ -456,6 +454,13 @@ export class AppConfigService {
properties: {
degree_type: {
priority: 1
},
institutions: {
items: {
properties: {
name: this.commonConfigsService.affiliationAutocompletionConfig
}
}
}
}
},
Expand Down
19 changes: 18 additions & 1 deletion src/app/core/services/common-configs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*/

import { Injectable } from '@angular/core';
import { RefAnchorAttributes, JsonStoreService, KeysStoreService } from 'ng2-json-editor';
import { RefAnchorAttributes, JsonStoreService, KeysStoreService, AutocompletionConfig } from 'ng2-json-editor';

import { FieldSplitterService } from './field-splitter.service';
import { ISO_LANGUAGE_MAP } from '../../shared/constants';
import { environment } from '../../../environments/environment';

@Injectable()
export class CommonConfigsService {
Expand All @@ -33,6 +34,20 @@ export class CommonConfigsService {

readonly isoLanguageMap = ISO_LANGUAGE_MAP;

readonly affiliationAutocompletionConfig: AutocompletionConfig = {
url: `${environment.baseUrl}/api/institutions/_suggest?affiliation=`,
path: '/affiliation/0/options',
size: 20,
itemTemplateName: 'affiliationAutocompleteTemplate',
onCompletionSelect: (path, completion, store) => {
path.splice(-1, 1, 'record', '$ref');
store.setIn(path, completion.payload['$ref']);

path.splice(-2, 2, 'curated_relation');
store.setIn(path, true);
}
};

readonly anchorBuilder = (url: string): RefAnchorAttributes => {
let parts = url.split('/');
let type = parts[parts.length - 2];
Expand Down Expand Up @@ -95,4 +110,6 @@ export class CommonConfigsService {
keyStore.buildKeysMapRecursivelyForPath(jsonStore.getIn(referencePath), referencePath);
}



}