Commits

Art Lowel authored a8d5ad9c372
fix adding of metadata only fields, and styling
No tags

src/app/core/data/relationship.service.ts

Modified
1 1 import { HttpClient, HttpHeaders } from '@angular/common/http';
2 2 import { Injectable } from '@angular/core';
3 3 import { MemoizedSelector, select, Store } from '@ngrx/store';
4 -import { combineLatest, combineLatest as observableCombineLatest } from 'rxjs';
4 +import { combineLatest as observableCombineLatest } from 'rxjs';
5 5 import { Observable } from 'rxjs/internal/Observable';
6 6 import { distinctUntilChanged, filter, map, startWith, switchMap, take, tap } from 'rxjs/operators';
7 7 import {
8 8 compareArraysUsingIds,
9 9 paginatedRelationsToItems,
10 10 relationsToItems
11 11 } from '../../+item-page/simple/item-types/shared/item-relationships-utils';
12 12 import { AppState, keySelector } from '../../app.reducer';
13 13 import { hasValue, hasValueOperator, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
14 14 import { ReorderableRelationship } from '../../shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component';
131 131 tap(() => this.refreshRelationshipItemsInCache(item1)),
132 132 tap(() => this.refreshRelationshipItemsInCache(item2))
133 133 ) as Observable<RestResponse>;
134 134 }
135 135
136 136 /**
137 137 * Method to remove two items of a relationship from the cache using the identifier of the relationship
138 138 * @param relationshipId The identifier of the relationship
139 139 */
140 140 private refreshRelationshipItemsInCacheByRelationship(relationshipId: string) {
141 - this.findById(relationshipId).pipe(
141 + this.findById(relationshipId, followLink('leftItem'), followLink('rightItem')).pipe(
142 142 getSucceededRemoteData(),
143 143 getRemoteDataPayload(),
144 - switchMap((rel: Relationship) => combineLatest(
144 + switchMap((rel: Relationship) => observableCombineLatest(
145 145 rel.leftItem.pipe(getSucceededRemoteData(), getRemoteDataPayload()),
146 146 rel.rightItem.pipe(getSucceededRemoteData(), getRemoteDataPayload())
147 147 )
148 148 ),
149 149 take(1)
150 150 ).subscribe(([item1, item2]) => {
151 151 this.refreshRelationshipItemsInCache(item1);
152 152 this.refreshRelationshipItemsInCache(item2);
153 153 })
154 154 }
155 155
156 156 /**
157 157 * Method to remove an item that's part of a relationship from the cache
158 158 * @param item The item to remove from the cache
159 159 */
160 160 private refreshRelationshipItemsInCache(item) {
161 161 this.objectCache.remove(item._links.self.href);
162 162 this.requestService.removeByHrefSubstring(item.uuid);
163 - combineLatest(
163 + observableCombineLatest(
164 164 this.objectCache.hasBySelfLinkObservable(item._links.self.href),
165 165 this.requestService.hasByHrefObservable(item.self)
166 166 ).pipe(
167 167 filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
168 168 take(1),
169 169 switchMap(() => this.itemService.findByHref(item._links.self.href).pipe(take(1)))
170 170 ).subscribe();
171 171 }
172 172
173 173 /**

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut