From f0e38e9e8c7085fc2ec25a000651811bf92984fb Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 5 Dec 2019 17:31:13 +0100 Subject: [PATCH] 67611: Console error fix, notification on adding local entity and JSDocs --- resources/i18n/en.json5 | 3 ++ ...namic-lookup-relation-modal.component.html | 1 - ...-relation-external-source-tab.component.ts | 50 +++++++++++++++++-- ...nal-source-entry-import-modal.component.ts | 11 +++- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 16d5d64bd9..7fa9c96010 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -1523,8 +1523,11 @@ "submission.general.save-later": "Save for later", + "submission.sections.describe.relationship-lookup.close": "Close", + "submission.sections.describe.relationship-lookup.external-source.added": "Successfully added local entry to the selection", + "submission.sections.describe.relationship-lookup.external-source.import-button-title": "Import remote entry", "submission.sections.describe.relationship-lookup.external-source.import-modal.authority": "Authority", diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html index 1773661486..06e45ecb92 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html @@ -29,7 +29,6 @@ [item]="item" [collection]="collection" [relationship]="relationshipOptions" - [repeatable]="repeatable" [context]="context" [externalSource]="source" (selectObject)="select($event)" diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts index dfdb1508fc..54cd4e2f86 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts @@ -22,6 +22,8 @@ import { hasValue } from '../../../../../empty.util'; import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service'; import { Item } from '../../../../../../core/shared/item.model'; import { Collection } from '../../../../../../core/shared/collection.model'; +import { NotificationsService } from '../../../../../notifications/notifications.service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'ds-dynamic-lookup-relation-external-source-tab', @@ -38,18 +40,49 @@ import { Collection } from '../../../../../../core/shared/collection.model'; fadeInOut ] }) - +/** + * Component rendering the tab content of an external source during submission lookup + * Shows a list of entries matching the current search query with the option to import them into the repository + */ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit, OnDestroy { - @Input() label: string; + /** + * The ID of the list of selected entries + */ @Input() listId: string; + + /** + * The item in submission + */ @Input() item: Item; + + /** + * The collection the user is submitting an item into + */ @Input() collection: Collection; + + /** + * The relationship-options for the current lookup + */ @Input() relationship: RelationshipOptions; - @Input() repeatable: boolean; + + /** + * The context to displaying lists for + */ @Input() context: Context; + + /** + * Emit an event when an object has been deselected + */ @Output() deselectObject: EventEmitter = new EventEmitter(); + + /** + * Emit an event when an object has been selected (or imported) + */ @Output() selectObject: EventEmitter = new EventEmitter(); + /** + * The initial pagination options + */ initialPagination = Object.assign(new PaginationComponentOptions(), { id: 'submission-external-source-relation-list', pageSize: 5 @@ -86,9 +119,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit public searchConfigService: SearchConfigurationService, private externalSourceService: ExternalSourceService, private modalService: NgbModal, - private selectableListService: SelectableListService) { + private selectableListService: SelectableListService, + private notificationsService: NotificationsService, + private translateService: TranslateService) { } + /** + * Get the entries for the selected external source + */ ngOnInit(): void { this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe( switchMap((searchOptions: PaginatedSearchOptions) => @@ -112,10 +150,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit modalComp.relationship = this.relationship; this.importObjectSub = modalComp.importedObject.subscribe((object) => { this.selectableListService.selectSingle(this.listId, object); + this.notificationsService.success(this.translateService.get('submission.sections.describe.relationship-lookup.external-source.added')); this.selectObject.emit(object); }); } + /** + * Unsubscribe from open subscriptions + */ ngOnDestroy(): void { if (hasValue(this.importObjectSub)) { this.importObjectSub.unsubscribe(); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.ts index acd1fa59ea..2107021d40 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.ts @@ -17,6 +17,7 @@ import { SelectableListService } from '../../../../../../object-list/selectable- import { ListableObject } from '../../../../../../object-collection/shared/listable-object.model'; import { Collection } from '../../../../../../../core/shared/collection.model'; import { ItemDataService } from '../../../../../../../core/data/item-data.service'; +import { PaginationComponentOptions } from '../../../../../../pagination/pagination-component-options.model'; /** * The possible types of import for the external entry @@ -34,6 +35,12 @@ export enum ImportType { styleUrls: ['./external-source-entry-import-modal.component.scss'], templateUrl: './external-source-entry-import-modal.component.html' }) +/** + * Component to display a modal window for importing an external source entry + * Shows information about the selected entry and a selectable list of local entities and authorities with similar names + * and the ability to add one of those results to the selection instead of the external entry. + * The other option is to import the external entry as a new entity or authority into the repository. + */ export class ExternalSourceEntryImportModalComponent implements OnInit { /** * The external source entry @@ -128,7 +135,8 @@ export class ExternalSourceEntryImportModalComponent implements OnInit { ngOnInit(): void { this.uri = Metadata.first(this.externalSourceEntry.metadata, 'dc.identifier.uri'); - this.searchOptions = Object.assign(new PaginatedSearchOptions({ query: 'sarah' })); + const pagination = Object.assign(new PaginationComponentOptions(), { id: 'external-entry-import', pageSize: 5 }); + this.searchOptions = Object.assign(new PaginatedSearchOptions({ query: this.externalSourceEntry.value, pagination: pagination })); this.localEntitiesRD$ = this.lookupRelationService.getLocalResults(this.relationship, this.searchOptions); this.collectionId = this.collection.id; } @@ -180,7 +188,6 @@ export class ExternalSourceEntryImportModalComponent implements OnInit { * Create and import a new entity from the external entry */ importNewEntity() { - console.log(this.collection); this.itemService.importExternalSourceEntry(this.externalSourceEntry, this.collectionId).subscribe((response) => { console.log(response); });