fix issue where namvariants wouldn't work

This commit is contained in:
Art Lowel
2020-04-02 14:14:36 +02:00
parent f93df688e4
commit 924e623b6a
5 changed files with 61 additions and 23 deletions

View File

@@ -167,14 +167,14 @@ export class ReorderableRelationship extends Reorderable {
templateUrl: './existing-metadata-list-element.component.html',
styleUrls: ['./existing-metadata-list-element.component.scss']
})
export class ExistingMetadataListElementComponent implements OnChanges, OnDestroy {
export class ExistingMetadataListElementComponent implements OnInit, OnChanges, OnDestroy {
@Input() listId: string;
@Input() submissionItem: Item;
@Input() reoRel: ReorderableRelationship;
@Input() metadataFields: string[];
@Input() relationshipOptions: RelationshipOptions;
@Input() submissionId: string;
metadataRepresentation$: BehaviorSubject<MetadataRepresentation>;
metadataRepresentation$: BehaviorSubject<MetadataRepresentation> = new BehaviorSubject<MetadataRepresentation>(undefined);
relatedItem: Item;
/**
@@ -188,6 +188,10 @@ export class ExistingMetadataListElementComponent implements OnChanges, OnDestro
) {
}
ngOnInit(): void {
this.ngOnChanges();
}
/**
* Change callback for the component
*/
@@ -208,11 +212,7 @@ export class ExistingMetadataListElementComponent implements OnChanges, OnDestro
new ItemMetadataRepresentation(metadataRepresentationMD),
this.relatedItem
);
if (hasValue(this.metadataRepresentation$)) {
this.metadataRepresentation$.next(nextValue);
} else {
this.metadataRepresentation$ = new BehaviorSubject<MetadataRepresentation>(nextValue);
}
this.metadataRepresentation$.next(nextValue);
}
}));
}

View File

@@ -2,7 +2,7 @@ import { Component, EventEmitter, NgZone, OnDestroy, OnInit, Output } from '@ang
import { combineLatest, Observable, Subscription, zip as observableZip } from 'rxjs';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { hasValue } from '../../../../empty.util';
import { map, skip, switchMap, take } from 'rxjs/operators';
import { map, skip, switchMap, take, tap, filter } from 'rxjs/operators';
import { SEARCH_CONFIG_SERVICE } from '../../../../../+my-dspace-page/my-dspace-page.component';
import { SearchConfigurationService } from '../../../../../core/shared/search/search-configuration.service';
import { SelectableListService } from '../../../../object-list/selectable-list/selectable-list.service';
@@ -165,7 +165,6 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
.subscribe((arr: any[]) => {
return arr.forEach((object: any) => {
const addRelationshipAction = new AddRelationshipAction(this.item, object.item, this.relationshipOptions.relationshipType, this.submissionId, object.nameVariant);
console.log('addRelationshipAction', addRelationshipAction);
this.store.dispatch(addRelationshipAction);
}
);

View File

@@ -98,7 +98,7 @@ export class RelationshipEffects {
const { item1, item2, relationshipType, submissionId, nameVariant } = action.payload;
const identifier: string = this.createIdentifier(item1, item2, relationshipType);
const inProgress = hasValue(this.debounceMap[identifier]);
if (inProgress) {
if (inProgress) {
this.nameVariantUpdates[identifier] = nameVariant;
} else {
this.relationshipService.updateNameVariant(item1, item2, relationshipType, nameVariant).pipe(take(1))