forked from hazza/dspace-angular
bug fixing
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { getSucceededRemoteData } from '../../../../core/shared/operators';
|
||||
import { getAllSucceededRemoteData, getFinishedRemoteData, getSucceededRemoteData } from '../../../../core/shared/operators';
|
||||
import { hasValue } from '../../../../shared/empty.util';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { distinctUntilChanged, flatMap, map, switchMap } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, filter, flatMap, map, switchMap } from 'rxjs/operators';
|
||||
import { combineLatest as observableCombineLatest, zip as observableZip } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
@@ -18,7 +18,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
|
||||
export const compareArraysUsing = <T>(mapFn: (t: T) => any) =>
|
||||
(a: T[], b: T[]): boolean => {
|
||||
if (!Array.isArray(a) || ! Array.isArray(b)) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
const aIds = a.map(mapFn);
|
||||
@@ -72,10 +72,9 @@ export const relationsToItems = (thisId: string) =>
|
||||
export const paginatedRelationsToItems = (thisId: string) =>
|
||||
(source: Observable<RemoteData<PaginatedList<Relationship>>>): Observable<RemoteData<PaginatedList<Item>>> =>
|
||||
source.pipe(
|
||||
getSucceededRemoteData(),
|
||||
switchMap((relationshipsRD: RemoteData<PaginatedList<Relationship>>) => {
|
||||
return observableZip(
|
||||
...relationshipsRD.payload.page.map((rel: Relationship) => observableCombineLatest(rel.leftItem, rel.rightItem))
|
||||
return observableCombineLatest(
|
||||
...relationshipsRD.payload.page.map((rel: Relationship) => observableCombineLatest(rel.leftItem.pipe(getFinishedRemoteData()), rel.rightItem.pipe(getFinishedRemoteData())))
|
||||
).pipe(
|
||||
map((arr) =>
|
||||
arr
|
||||
|
@@ -23,6 +23,7 @@ import {
|
||||
} from '../../shared/operators';
|
||||
import { CacheableObject, TypedObject } from '../object-cache.reducer';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
||||
import { deepClone } from 'fast-json-patch';
|
||||
|
||||
@Injectable()
|
||||
export class RemoteDataBuildService {
|
||||
@@ -124,7 +125,6 @@ export class RemoteDataBuildService {
|
||||
});
|
||||
}));
|
||||
}),
|
||||
startWith([]),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
const pageInfo$ = requestEntry$.pipe(
|
||||
|
@@ -227,7 +227,7 @@ export abstract class DataService<T extends CacheableObject> {
|
||||
),
|
||||
switchMap((href) => this.requestService.getByHref(href)),
|
||||
skipWhile((requestEntry) => hasValue(requestEntry) && requestEntry.completed),
|
||||
switchMap((href) =>
|
||||
switchMap(() =>
|
||||
this.rdbService.buildList<T>(hrefObs) as Observable<RemoteData<PaginatedList<T>>>
|
||||
)
|
||||
);
|
||||
@@ -348,4 +348,7 @@ export abstract class DataService<T extends CacheableObject> {
|
||||
this.requestService.commit(method);
|
||||
}
|
||||
|
||||
getLinkPath() {
|
||||
return this.linkPath;
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,9 @@ import { SubmissionObject } from './models/submission-object.model';
|
||||
import { SubmissionScopeType } from './submission-scope-type';
|
||||
import { WorkflowItemDataService } from './workflowitem-data.service';
|
||||
import { WorkspaceitemDataService } from './workspaceitem-data.service';
|
||||
import { DataService } from '../data/data.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
|
||||
/**
|
||||
* A service to retrieve submission objects (WorkspaceItem/WorkflowItem)
|
||||
@@ -19,10 +22,22 @@ export class SubmissionObjectDataService {
|
||||
constructor(
|
||||
private workspaceitemDataService: WorkspaceitemDataService,
|
||||
private workflowItemDataService: WorkflowItemDataService,
|
||||
private submissionService: SubmissionService
|
||||
private submissionService: SubmissionService,
|
||||
private halService: HALEndpointService
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the HREF for a specific object based on its identifier
|
||||
* @param id The identifier for the object
|
||||
*/
|
||||
getHrefByID(id): Observable<string> {
|
||||
const dataService: DataService<SubmissionObject> = this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkspaceItem ? this.workspaceitemDataService : this.workflowItemDataService;
|
||||
|
||||
return this.halService.getEndpoint(dataService.getLinkPath()).pipe(
|
||||
map((endpoint: string) => dataService.getIDHref(endpoint, encodeURIComponent(id))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a submission object based on its ID.
|
||||
*
|
||||
|
@@ -73,7 +73,7 @@ import { DsDynamicFormArrayComponent } from './models/array-group/dynamic-form-a
|
||||
import { DsDynamicRelationGroupComponent } from './models/relation-group/dynamic-relation-group.components';
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './models/relation-group/dynamic-relation-group.model';
|
||||
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
|
||||
import { map, startWith, switchMap, find, take } from 'rxjs/operators';
|
||||
import { map, startWith, switchMap, find, take, tap } from 'rxjs/operators';
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import { SearchResult } from '../../../search/search-result.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
@@ -96,6 +96,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search-
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { FormService } from '../../form.service';
|
||||
import { deepClone } from 'fast-json-patch';
|
||||
|
||||
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
||||
switch (model.type) {
|
||||
@@ -253,8 +254,11 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
}
|
||||
}
|
||||
if (this.model.relationshipConfig) {
|
||||
this.listId = 'list-' + this.model.relationshipConfig.relationshipType;
|
||||
this.setItem();
|
||||
this.relationService.getRelatedItemsByLabel(this.item, this.model.relationshipConfig.relationshipType).pipe(
|
||||
tap((t: any) => console.log(deepClone(t))),
|
||||
getSucceededRemoteData(),
|
||||
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
||||
).subscribe((relatedItems: Array<SearchResult<Item>>) => this.selectableListService.select(this.listId, relatedItems));
|
||||
}
|
||||
|
@@ -9,8 +9,9 @@
|
||||
<ng-container *ngTemplateOutlet="endTemplate?.templateRef; context: model.groups[0]"></ng-container>
|
||||
</div>
|
||||
<div cdkDropList cdkDropListLockAxis="y" (cdkDropListDropped)="moveSelection($event)">
|
||||
<div *ngFor="let groupModel of model.groups; let idx = index" role="group"
|
||||
[formGroupName]="idx" [ngClass]="{'pt-2 pb-2': idx > 0}" cdkDrag cdkDragHandle [class]="getClass('element', 'group') + ' ' + getClass('grid', 'group')">
|
||||
<div *ngFor="let groupModel of model.groups; let idx = index"
|
||||
[ngClass]="{'pt-2 pb-2': idx > 0}" cdkDrag cdkDragHandle>
|
||||
<div [formGroupName]="idx" [class]="getClass('element', 'group') + ' ' + getClass('grid', 'group')">
|
||||
<ng-container *ngIf="idx > 0">
|
||||
<i class="drag-icon fas fa-grip-vertical fa-fw"></i>
|
||||
<ng-container *ngTemplateOutlet="startTemplate?.templateRef; context: groupModel"></ng-container>
|
||||
@@ -20,6 +21,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
|
||||
|
@@ -1,13 +1,16 @@
|
||||
@import './../../../../../../../styles/variables';
|
||||
|
||||
.cdk-drag {
|
||||
margin-left: -(1.5 * $spacer);
|
||||
margin-left: -(2 * $spacer);
|
||||
margin-right: -(0.5 * $spacer);
|
||||
padding-right: (0.5 * $spacer);
|
||||
.drag-icon {
|
||||
visibility: hidden;
|
||||
width: (1.5 * $spacer);
|
||||
width: (2 * $spacer);
|
||||
color: $gray-600;
|
||||
margin: $btn-padding-y 0;
|
||||
line-height: $btn-line-height;
|
||||
text-indent: 0.5 * $spacer
|
||||
}
|
||||
|
||||
&:hover, &:focus {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||
import { debounceTime, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { debounceTime, filter, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
|
||||
import { RelationshipService } from '../../../../../core/data/relationship.service';
|
||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../core/shared/operators';
|
||||
import { AddRelationshipAction, RelationshipAction, RelationshipActionTypes, UpdateRelationshipAction } from './relationship.actions';
|
||||
@@ -15,6 +15,8 @@ import { SaveSubmissionSectionFormSuccessAction } from '../../../../../submissio
|
||||
import { SubmissionObject } from '../../../../../core/submission/models/submission-object.model';
|
||||
import { SubmissionState } from '../../../../../submission/submission.reducers';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { ObjectCacheService } from '../../../../../core/cache/object-cache.service';
|
||||
import { RequestService } from '../../../../../core/data/request.service';
|
||||
|
||||
const DEBOUNCE_TIME = 5000;
|
||||
|
||||
@@ -106,7 +108,9 @@ export class RelationshipEffects {
|
||||
private relationshipService: RelationshipService,
|
||||
private relationshipTypeService: RelationshipTypeService,
|
||||
private submissionObjectService: SubmissionObjectDataService,
|
||||
private store: Store<SubmissionState>
|
||||
private store: Store<SubmissionState>,
|
||||
private objectCache: ObjectCacheService,
|
||||
private requestService: RequestService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -127,8 +131,9 @@ export class RelationshipEffects {
|
||||
return this.relationshipService.addRelationship(type.id, item1, item2, undefined, nameVariant);
|
||||
}
|
||||
}
|
||||
)
|
||||
).pipe(take(1), switchMap(() => this.submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()))
|
||||
),
|
||||
take(1),
|
||||
this.removeWorkspaceItemFromCache(submissionId)
|
||||
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false)));
|
||||
}
|
||||
|
||||
@@ -138,7 +143,25 @@ export class RelationshipEffects {
|
||||
hasValueOperator(),
|
||||
mergeMap((relationship: Relationship) => this.relationshipService.deleteRelationship(relationship.id)),
|
||||
take(1),
|
||||
switchMap(() => this.submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()))
|
||||
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject])));
|
||||
this.removeWorkspaceItemFromCache(submissionId)
|
||||
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false)));
|
||||
}
|
||||
|
||||
removeWorkspaceItemFromCache = (submissionId) =>
|
||||
<T>(source: Observable<T>): Observable<SubmissionObject> =>
|
||||
source.pipe(
|
||||
switchMap(() => this.submissionObjectService.getHrefByID(submissionId).pipe(take(1))),
|
||||
switchMap((href: string) => {
|
||||
this.objectCache.remove(href);
|
||||
this.requestService.removeByHrefSubstring(submissionId);
|
||||
return combineLatest(
|
||||
this.objectCache.hasBySelfLinkObservable(href),
|
||||
this.requestService.hasByHrefObservable(href)
|
||||
).pipe(
|
||||
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||
take(1),
|
||||
switchMap(() => this.submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()) as Observable<SubmissionObject>)
|
||||
)
|
||||
}
|
||||
));
|
||||
}
|
||||
|
@@ -42,8 +42,3 @@
|
||||
.right-addon input {
|
||||
padding-right: $spacer * 2.25;
|
||||
}
|
||||
|
||||
.ds-form-qualdrop-hint {
|
||||
top: -$spacer;
|
||||
position: relative;
|
||||
}
|
||||
|
Reference in New Issue
Block a user