mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
78994: Remove setItem method
This commit is contained in:
@@ -12,11 +12,8 @@ import { RelationshipOptions } from '../../models/relationship-options.model';
|
|||||||
import { SearchResult } from '../../../../search/search-result.model';
|
import { SearchResult } from '../../../../search/search-result.model';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteData,
|
AddRelationshipAction, RemoveRelationshipAction, UpdateRelationshipNameVariantAction,
|
||||||
getAllSucceededRemoteDataPayload,
|
} from './relationship.actions';
|
||||||
getRemoteDataPayload
|
|
||||||
} from '../../../../../core/shared/operators';
|
|
||||||
import { AddRelationshipAction, RemoveRelationshipAction, UpdateRelationshipNameVariantAction } from './relationship.actions';
|
|
||||||
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
||||||
import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service';
|
import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@@ -27,12 +24,7 @@ import { ExternalSource } from '../../../../../core/shared/external-source.model
|
|||||||
import { ExternalSourceService } from '../../../../../core/data/external-source.service';
|
import { ExternalSourceService } from '../../../../../core/data/external-source.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service';
|
||||||
import { followLink } from '../../../../utils/follow-link-config.model';
|
import { getAllSucceededRemoteDataPayload } from '../../../../../core/shared/operators';
|
||||||
import { SubmissionObject } from '../../../../../core/submission/models/submission-object.model';
|
|
||||||
import { Collection } from '../../../../../core/shared/collection.model';
|
|
||||||
import { SubmissionService } from '../../../../../submission/submission.service';
|
|
||||||
import { SubmissionObjectDataService } from '../../../../../core/submission/submission-object-data.service';
|
|
||||||
import { RemoteData } from '../../../../../core/data/remote-data';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-dynamic-lookup-relation-modal',
|
selector: 'ds-dynamic-lookup-relation-modal',
|
||||||
@@ -122,10 +114,6 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
*/
|
*/
|
||||||
totalExternal$: Observable<number[]>;
|
totalExternal$: Observable<number[]>;
|
||||||
|
|
||||||
/**
|
|
||||||
* List of subscriptions to unsubscribe from
|
|
||||||
*/
|
|
||||||
private subs: Subscription[] = [];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public modal: NgbActiveModal,
|
public modal: NgbActiveModal,
|
||||||
@@ -136,17 +124,14 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
private lookupRelationService: LookupRelationService,
|
private lookupRelationService: LookupRelationService,
|
||||||
private searchConfigService: SearchConfigurationService,
|
private searchConfigService: SearchConfigurationService,
|
||||||
private rdbService: RemoteDataBuildService,
|
private rdbService: RemoteDataBuildService,
|
||||||
private submissionService: SubmissionService,
|
|
||||||
private submissionObjectService: SubmissionObjectDataService,
|
|
||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
private store: Store<AppState>,
|
private store: Store<AppState>,
|
||||||
private router: Router
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.setItem();
|
|
||||||
this.selection$ = this.selectableListService
|
this.selection$ = this.selectableListService
|
||||||
.getSelectableList(this.listId)
|
.getSelectableList(this.listId)
|
||||||
.pipe(map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []));
|
.pipe(map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []));
|
||||||
@@ -206,24 +191,6 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize this.item$ based on this.model.submissionId
|
|
||||||
*/
|
|
||||||
private setItem() {
|
|
||||||
const submissionObject$ = this.submissionObjectService
|
|
||||||
.findById(this.submissionId, true, true, followLink('item'), followLink('collection')).pipe(
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload()
|
|
||||||
);
|
|
||||||
|
|
||||||
const item$ = submissionObject$.pipe(switchMap((submissionObject: SubmissionObject) => (submissionObject.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload())));
|
|
||||||
const collection$ = submissionObject$.pipe(switchMap((submissionObject: SubmissionObject) => (submissionObject.collection as Observable<RemoteData<Collection>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload())));
|
|
||||||
|
|
||||||
this.subs.push(item$.subscribe((item) => this.item = item));
|
|
||||||
this.subs.push(collection$.subscribe((collection) => this.collection = collection));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a subscription updating relationships with name variants
|
* Add a subscription updating relationships with name variants
|
||||||
* @param sri The search result to track name variants for
|
* @param sri The search result to track name variants for
|
||||||
@@ -279,8 +246,5 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.router.navigate([], {});
|
this.router.navigate([], {});
|
||||||
Object.values(this.subMap).forEach((subscription) => subscription.unsubscribe());
|
Object.values(this.subMap).forEach((subscription) => subscription.unsubscribe());
|
||||||
this.subs
|
|
||||||
.filter((sub) => hasValue(sub))
|
|
||||||
.forEach((sub) => sub.unsubscribe());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user