67611: Console error fix, notification on adding local entity and JSDocs

This commit is contained in:
Kristof De Langhe
2019-12-05 17:31:13 +01:00
parent fda083137a
commit f0e38e9e8c
4 changed files with 58 additions and 7 deletions

View File

@@ -1523,8 +1523,11 @@
"submission.general.save-later": "Save for later", "submission.general.save-later": "Save for later",
"submission.sections.describe.relationship-lookup.close": "Close", "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-button-title": "Import remote entry",
"submission.sections.describe.relationship-lookup.external-source.import-modal.authority": "Authority", "submission.sections.describe.relationship-lookup.external-source.import-modal.authority": "Authority",

View File

@@ -29,7 +29,6 @@
[item]="item" [item]="item"
[collection]="collection" [collection]="collection"
[relationship]="relationshipOptions" [relationship]="relationshipOptions"
[repeatable]="repeatable"
[context]="context" [context]="context"
[externalSource]="source" [externalSource]="source"
(selectObject)="select($event)" (selectObject)="select($event)"

View File

@@ -22,6 +22,8 @@ import { hasValue } from '../../../../../empty.util';
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service'; import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
import { Item } from '../../../../../../core/shared/item.model'; import { Item } from '../../../../../../core/shared/item.model';
import { Collection } from '../../../../../../core/shared/collection.model'; import { Collection } from '../../../../../../core/shared/collection.model';
import { NotificationsService } from '../../../../../notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
@Component({ @Component({
selector: 'ds-dynamic-lookup-relation-external-source-tab', selector: 'ds-dynamic-lookup-relation-external-source-tab',
@@ -38,18 +40,49 @@ import { Collection } from '../../../../../../core/shared/collection.model';
fadeInOut 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 { export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit, OnDestroy {
@Input() label: string; /**
* The ID of the list of selected entries
*/
@Input() listId: string; @Input() listId: string;
/**
* The item in submission
*/
@Input() item: Item; @Input() item: Item;
/**
* The collection the user is submitting an item into
*/
@Input() collection: Collection; @Input() collection: Collection;
/**
* The relationship-options for the current lookup
*/
@Input() relationship: RelationshipOptions; @Input() relationship: RelationshipOptions;
@Input() repeatable: boolean;
/**
* The context to displaying lists for
*/
@Input() context: Context; @Input() context: Context;
/**
* Emit an event when an object has been deselected
*/
@Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>(); @Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
/**
* Emit an event when an object has been selected (or imported)
*/
@Output() selectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>(); @Output() selectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
/**
* The initial pagination options
*/
initialPagination = Object.assign(new PaginationComponentOptions(), { initialPagination = Object.assign(new PaginationComponentOptions(), {
id: 'submission-external-source-relation-list', id: 'submission-external-source-relation-list',
pageSize: 5 pageSize: 5
@@ -86,9 +119,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
public searchConfigService: SearchConfigurationService, public searchConfigService: SearchConfigurationService,
private externalSourceService: ExternalSourceService, private externalSourceService: ExternalSourceService,
private modalService: NgbModal, 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 { ngOnInit(): void {
this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe( this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
switchMap((searchOptions: PaginatedSearchOptions) => switchMap((searchOptions: PaginatedSearchOptions) =>
@@ -112,10 +150,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
modalComp.relationship = this.relationship; modalComp.relationship = this.relationship;
this.importObjectSub = modalComp.importedObject.subscribe((object) => { this.importObjectSub = modalComp.importedObject.subscribe((object) => {
this.selectableListService.selectSingle(this.listId, 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); this.selectObject.emit(object);
}); });
} }
/**
* Unsubscribe from open subscriptions
*/
ngOnDestroy(): void { ngOnDestroy(): void {
if (hasValue(this.importObjectSub)) { if (hasValue(this.importObjectSub)) {
this.importObjectSub.unsubscribe(); this.importObjectSub.unsubscribe();

View File

@@ -17,6 +17,7 @@ import { SelectableListService } from '../../../../../../object-list/selectable-
import { ListableObject } from '../../../../../../object-collection/shared/listable-object.model'; import { ListableObject } from '../../../../../../object-collection/shared/listable-object.model';
import { Collection } from '../../../../../../../core/shared/collection.model'; import { Collection } from '../../../../../../../core/shared/collection.model';
import { ItemDataService } from '../../../../../../../core/data/item-data.service'; 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 * The possible types of import for the external entry
@@ -34,6 +35,12 @@ export enum ImportType {
styleUrls: ['./external-source-entry-import-modal.component.scss'], styleUrls: ['./external-source-entry-import-modal.component.scss'],
templateUrl: './external-source-entry-import-modal.component.html' 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 { export class ExternalSourceEntryImportModalComponent implements OnInit {
/** /**
* The external source entry * The external source entry
@@ -128,7 +135,8 @@ export class ExternalSourceEntryImportModalComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.uri = Metadata.first(this.externalSourceEntry.metadata, 'dc.identifier.uri'); 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.localEntitiesRD$ = this.lookupRelationService.getLocalResults(this.relationship, this.searchOptions);
this.collectionId = this.collection.id; this.collectionId = this.collection.id;
} }
@@ -180,7 +188,6 @@ export class ExternalSourceEntryImportModalComponent implements OnInit {
* Create and import a new entity from the external entry * Create and import a new entity from the external entry
*/ */
importNewEntity() { importNewEntity() {
console.log(this.collection);
this.itemService.importExternalSourceEntry(this.externalSourceEntry, this.collectionId).subscribe((response) => { this.itemService.importExternalSourceEntry(this.externalSourceEntry, this.collectionId).subscribe((response) => {
console.log(response); console.log(response);
}); });