intermediate commit

This commit is contained in:
lotte
2020-02-03 12:58:24 +01:00
parent 28747314e6
commit 360abb78de
12 changed files with 114 additions and 84 deletions

View File

@@ -10,6 +10,7 @@ import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { CacheEntry } from './cache-entry'; import { CacheEntry } from './cache-entry';
import { ResourceType } from '../shared/resource-type'; import { ResourceType } from '../shared/resource-type';
import { applyPatch, Operation } from 'fast-json-patch'; import { applyPatch, Operation } from 'fast-json-patch';
import { NormalizedItem } from './models/normalized-item.model';
export enum DirtyType { export enum DirtyType {
Created = 'Created', Created = 'Created',
@@ -64,6 +65,7 @@ export class ObjectCacheEntry implements CacheEntry {
patches: Patch[] = []; patches: Patch[] = [];
isDirty: boolean; isDirty: boolean;
} }
/* tslint:enable:max-classes-per-file */ /* tslint:enable:max-classes-per-file */
/** /**
@@ -93,10 +95,14 @@ export function objectCacheReducer(state = initialState, action: ObjectCacheActi
switch (action.type) { switch (action.type) {
case ObjectCacheActionTypes.ADD: { case ObjectCacheActionTypes.ADD: {
if ((action.payload as any).objectToCache instanceof NormalizedItem) {
console.log('ADD', (action.payload as any).objectToCache.self);
}
return addToObjectCache(state, action as AddToObjectCacheAction); return addToObjectCache(state, action as AddToObjectCacheAction);
} }
case ObjectCacheActionTypes.REMOVE: { case ObjectCacheActionTypes.REMOVE: {
console.log('REMOVE', action.payload);
return removeFromObjectCache(state, action as RemoveFromObjectCacheAction) return removeFromObjectCache(state, action as RemoveFromObjectCacheAction)
} }

View File

@@ -9,7 +9,7 @@ import { RestRequestMethod } from '../data/rest-request-method';
/** /**
* An entry in the ServerSyncBufferState * An entry in the ServerSyncBufferState
* href: unique href of an ObjectCacheEntry * href: unique href of an ServerSyncBufferEntry
* method: RestRequestMethod type * method: RestRequestMethod type
*/ */
export class ServerSyncBufferEntry { export class ServerSyncBufferEntry {
@@ -48,6 +48,7 @@ export function serverSyncBufferReducer(state = initialState, action: ServerSync
case ServerSyncBufferActionTypes.EMPTY: { case ServerSyncBufferActionTypes.EMPTY: {
return emptyServerSyncQueue(state, action as EmptySSBAction); return emptyServerSyncQueue(state, action as EmptySSBAction);
} }
default: { default: {
return state; return state;
} }
@@ -69,6 +70,7 @@ function addToServerSyncQueue(state: ServerSyncBufferState, action: AddToSSBActi
if (hasNoValue(state.buffer.find((entry) => entry.href === actionEntry.href && entry.method === actionEntry.method))) { if (hasNoValue(state.buffer.find((entry) => entry.href === actionEntry.href && entry.method === actionEntry.method))) {
return Object.assign({}, state, { buffer: state.buffer.concat(actionEntry) }); return Object.assign({}, state, { buffer: state.buffer.concat(actionEntry) });
} }
return state;
} }
/** /**

View File

@@ -60,7 +60,7 @@ export class RelationshipService extends DataService<Relationship> {
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected http: HttpClient, protected http: HttpClient,
protected comparator: DefaultChangeAnalyzer<Relationship>, protected comparator: DefaultChangeAnalyzer<Relationship>,
protected appStore: Store<AppState>) { protected appStore: Store<AppState>,) {
super(); super();
} }
@@ -86,11 +86,11 @@ export class RelationshipService extends DataService<Relationship> {
return this.getRelationshipEndpoint(id).pipe( return this.getRelationshipEndpoint(id).pipe(
isNotEmptyOperator(), isNotEmptyOperator(),
take(1), take(1),
tap(() => this.removeRelationshipItemsFromCacheByRelationship(id)),
map((endpointURL: string) => new DeleteRequest(this.requestService.generateRequestId(), endpointURL)), map((endpointURL: string) => new DeleteRequest(this.requestService.generateRequestId(), endpointURL)),
configureRequest(this.requestService), configureRequest(this.requestService),
switchMap((restRequest: RestRequest) => this.requestService.getByUUID(restRequest.uuid)), switchMap((restRequest: RestRequest) => this.requestService.getByUUID(restRequest.uuid)),
getResponseFromEntry(), getResponseFromEntry(),
tap(() => this.refreshRelationshipItemsInCacheByRelationship(id)),
); );
} }
@@ -117,8 +117,8 @@ export class RelationshipService extends DataService<Relationship> {
configureRequest(this.requestService), configureRequest(this.requestService),
switchMap((restRequest: RestRequest) => this.requestService.getByUUID(restRequest.uuid)), switchMap((restRequest: RestRequest) => this.requestService.getByUUID(restRequest.uuid)),
getResponseFromEntry(), getResponseFromEntry(),
tap(() => this.removeRelationshipItemsFromCache(item1)), tap(() => this.refreshRelationshipItemsInCache(item1)),
tap(() => this.removeRelationshipItemsFromCache(item2)) tap(() => this.refreshRelationshipItemsInCache(item2))
) as Observable<RestResponse>; ) as Observable<RestResponse>;
} }
@@ -126,7 +126,7 @@ export class RelationshipService extends DataService<Relationship> {
* Method to remove two items of a relationship from the cache using the identifier of the relationship * Method to remove two items of a relationship from the cache using the identifier of the relationship
* @param relationshipId The identifier of the relationship * @param relationshipId The identifier of the relationship
*/ */
private removeRelationshipItemsFromCacheByRelationship(relationshipId: string) { private refreshRelationshipItemsInCacheByRelationship(relationshipId: string) {
this.findById(relationshipId).pipe( this.findById(relationshipId).pipe(
getSucceededRemoteData(), getSucceededRemoteData(),
getRemoteDataPayload(), getRemoteDataPayload(),
@@ -137,8 +137,8 @@ export class RelationshipService extends DataService<Relationship> {
), ),
take(1) take(1)
).subscribe(([item1, item2]) => { ).subscribe(([item1, item2]) => {
this.removeRelationshipItemsFromCache(item1); this.refreshRelationshipItemsInCache(item1);
this.removeRelationshipItemsFromCache(item2); this.refreshRelationshipItemsInCache(item2);
}) })
} }
@@ -146,17 +146,21 @@ export class RelationshipService extends DataService<Relationship> {
* Method to remove an item that's part of a relationship from the cache * Method to remove an item that's part of a relationship from the cache
* @param item The item to remove from the cache * @param item The item to remove from the cache
*/ */
private removeRelationshipItemsFromCache(item) { private refreshRelationshipItemsInCache(item) {
setTimeout(() => {
this.objectCache.remove(item.self); this.objectCache.remove(item.self);
this.requestService.removeByHrefSubstring(item.uuid); this.requestService.removeByHrefSubstring(item.uuid);
combineLatest( combineLatest(
this.objectCache.hasBySelfLinkObservable(item.self), this.objectCache.hasBySelfLinkObservable(item.self),
this.requestService.hasByHrefObservable(item.uuid) this.requestService.hasByHrefObservable(item.self)
).pipe( ).pipe(
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC), filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
take(1), take(1),
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1))) switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
).subscribe(); ).subscribe();
}, 1000)
} }
/** /**
@@ -288,16 +292,17 @@ export class RelationshipService extends DataService<Relationship> {
getSucceededRemoteData(), getSucceededRemoteData(),
isNotEmptyOperator(), isNotEmptyOperator(),
map((relationshipListRD: RemoteData<PaginatedList<Relationship>>) => relationshipListRD.payload.page), map((relationshipListRD: RemoteData<PaginatedList<Relationship>>) => relationshipListRD.payload.page),
mergeMap((relationships: Relationship[]) => { switchMap((relationships: Relationship[]) => {
return observableCombineLatest(...relationships.map((relationship: Relationship) => { return observableCombineLatest(...relationships.map((relationship: Relationship) => {
return observableCombineLatest( return observableCombineLatest(
this.isItemMatchWithItemRD(relationship.leftItem, item2), this.isItemMatchWithItemRD(this.itemService.findByHref(relationship._links.leftItem), item2),
this.isItemMatchWithItemRD(relationship.rightItem, item2) this.isItemMatchWithItemRD(this.itemService.findByHref(relationship._links.rightItem), item2)
).pipe( ).pipe(
map(([isLeftItem, isRightItem]) => isLeftItem || isRightItem), map(([isLeftItem, isRightItem]) => isLeftItem || isRightItem),
map((isMatch) => isMatch ? relationship : undefined) map((isMatch) => isMatch ? relationship : undefined)
); );
})) })
)
}), }),
map((relationships: Relationship[]) => relationships.find(((relationship) => hasValue(relationship)))) map((relationships: Relationship[]) => relationships.find(((relationship) => hasValue(relationship))))
) )
@@ -357,6 +362,7 @@ export class RelationshipService extends DataService<Relationship> {
* @param nameVariant The name variant to set for the matching relationship * @param nameVariant The name variant to set for the matching relationship
*/ */
public updateNameVariant(item1: Item, item2: Item, relationshipLabel: string, nameVariant: string): Observable<RemoteData<Relationship>> { public updateNameVariant(item1: Item, item2: Item, relationshipLabel: string, nameVariant: string): Observable<RemoteData<Relationship>> {
let count = 0
const update$: Observable<RemoteData<Relationship>> = this.getRelationshipByItemsAndLabel(item1, item2, relationshipLabel) const update$: Observable<RemoteData<Relationship>> = this.getRelationshipByItemsAndLabel(item1, item2, relationshipLabel)
.pipe( .pipe(
switchMap((relation: Relationship) => switchMap((relation: Relationship) =>
@@ -378,16 +384,15 @@ export class RelationshipService extends DataService<Relationship> {
} }
return this.update(updatedRelationship); return this.update(updatedRelationship);
}), }),
tap((relationshipRD: RemoteData<Relationship>) => {
console.log(relationshipRD);
if (relationshipRD.hasSucceeded && count < 1) {
count++;
this.refreshRelationshipItemsInCache(item1);
this.refreshRelationshipItemsInCache(item2);
}
})
); );
update$.pipe(
filter((relationshipRD: RemoteData<Relationship>) => relationshipRD.state === RemoteDataState.RequestPending),
take(1),
).subscribe(() => {
this.removeRelationshipItemsFromCache(item1);
this.removeRelationshipItemsFromCache(item2);
});
return update$ return update$
} }
@@ -411,7 +416,7 @@ export class RelationshipService extends DataService<Relationship> {
take(1), take(1),
).subscribe((relationshipRD: RemoteData<Relationship>) => { ).subscribe((relationshipRD: RemoteData<Relationship>) => {
if (relationshipRD.state === RemoteDataState.ResponsePending) { if (relationshipRD.state === RemoteDataState.ResponsePending) {
this.removeRelationshipItemsFromCacheByRelationship(reoRel.relationship.id); this.refreshRelationshipItemsInCacheByRelationship(reoRel.relationship.id);
} }
}); });

View File

@@ -4,6 +4,7 @@ import { RemoteData } from '../../data/remote-data';
import { ResourceType } from '../resource-type'; import { ResourceType } from '../resource-type';
import { RelationshipType } from './relationship-type.model'; import { RelationshipType } from './relationship-type.model';
import { Item } from '../item.model'; import { Item } from '../item.model';
import { deserialize } from 'cerialize';
/** /**
* Describes a Relationship between two Items * Describes a Relationship between two Items
@@ -60,4 +61,8 @@ export class Relationship implements CacheableObject {
* The type of Relationship * The type of Relationship
*/ */
relationshipType: Observable<RemoteData<RelationshipType>>; relationshipType: Observable<RemoteData<RelationshipType>>;
_links: {
[name: string]: string
};
} }

View File

@@ -37,7 +37,7 @@
<div *ngIf="isRelationship && context?.index < 1" class="col-auto text-center"> <div *ngIf="isRelationship && context?.index < 1" class="col-auto text-center">
<button class="btn btn-secondary" <button class="btn btn-secondary"
type="submit" type="button"
ngbTooltip="{{'form.lookup-help' | translate}}" ngbTooltip="{{'form.lookup-help' | translate}}"
placement="top" placement="top"
(click)="openLookup(); $event.stopPropagation();">{{'form.lookup' | translate}} (click)="openLookup(); $event.stopPropagation();">{{'form.lookup' | translate}}
@@ -47,7 +47,7 @@
<ng-container *ngTemplateOutlet="endTemplate?.templateRef; context: model"></ng-container> <ng-container *ngTemplateOutlet="endTemplate?.templateRef; context: model"></ng-container>
<ng-container *ngIf="relationshipValue$ | async"> <ng-container *ngIf="value?.isVirtual">
<ds-existing-metadata-list-element <ds-existing-metadata-list-element
[reoRel]="relationshipValue$ | async" [reoRel]="relationshipValue$ | async"
[submissionItem]="item" [submissionItem]="item"

View File

@@ -187,7 +187,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
item: Item; item: Item;
listId: string; listId: string;
searchConfig: string; searchConfig: string;
value: MetadataValue;
/** /**
* List of subscriptions to unsubscribe from * List of subscriptions to unsubscribe from
*/ */
@@ -235,23 +235,23 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
if (this.isRelationship) { if (this.isRelationship) {
this.listId = 'list-' + this.model.relationship.relationshipType; this.listId = 'list-' + this.model.relationship.relationshipType;
this.setItem(); this.setItem();
const value = Object.assign(new MetadataValue(), this.model.value); this.value = Object.assign(new MetadataValue(), this.model.value);
if (hasValue(value) && value.isVirtual) { if (hasValue(this.value) && this.value.isVirtual) {
const relationship$ = this.relationshipService.findById(value.virtualValue) const relationship$ = this.relationshipService.findById(this.value.virtualValue)
.pipe( .pipe(
getAllSucceededRemoteData(), getAllSucceededRemoteData(),
getRemoteDataPayload()); getRemoteDataPayload());
this.relationshipValue$ = relationship$.pipe( this.relationshipValue$ = relationship$.pipe(
switchMap((relationship: Relationship) => switchMap((relationship: Relationship) =>
relationship.leftItem.pipe( relationship.leftItem.pipe(
tap((t) => console.log(t)),
getSucceededRemoteData(), getSucceededRemoteData(),
getRemoteDataPayload(), getRemoteDataPayload(),
map((leftItem: Item) => { map((leftItem: Item) => {
return new ReorderableRelationship(relationship, leftItem.uuid !== this.item.uuid, this.relationshipService) return new ReorderableRelationship(relationship, leftItem.uuid !== this.item.uuid, this.relationshipService)
}), }),
) )
) ),
startWith(undefined)
); );
} }
} }
@@ -359,7 +359,6 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
) )
) )
); );
this.subs.push(item$.subscribe((item) => this.item = item)); this.subs.push(item$.subscribe((item) => this.item = item));
} }
} }

View File

@@ -1,6 +1,11 @@
<div *ngIf="metadataRepresentation" class="d-flex"> <div class="d-flex">
<span class="mr-auto text-contents"> <span class="mr-auto text-contents">
<ng-container *ngIf="!metadataRepresentation">
<ds-loading [showMessage]="false"></ds-loading>
</ng-container>
<ng-container *ngIf="metadataRepresentation">
<ds-metadata-representation-loader [mdRepresentation]="metadataRepresentation"></ds-metadata-representation-loader> <ds-metadata-representation-loader [mdRepresentation]="metadataRepresentation"></ds-metadata-representation-loader>
</ng-container>
</span> </span>
<button type="button" class="btn btn-secondary" <button type="button" class="btn btn-secondary"
(click)="removeSelection()"> (click)="removeSelection()">

View File

@@ -32,6 +32,7 @@ export class AddRelationshipAction implements Action {
* @param item1 The first item in the relationship * @param item1 The first item in the relationship
* @param item2 The second item in the relationship * @param item2 The second item in the relationship
* @param relationshipType The label of the relationshipType * @param relationshipType The label of the relationshipType
* @param submissionId The current submissionId
* @param nameVariant The nameVariant of the relationshipType * @param nameVariant The nameVariant of the relationshipType
*/ */
constructor( constructor(
@@ -62,6 +63,7 @@ export class UpdateRelationshipAction implements Action {
* @param item1 The first item in the relationship * @param item1 The first item in the relationship
* @param item2 The second item in the relationship * @param item2 The second item in the relationship
* @param relationshipType The label of the relationshipType * @param relationshipType The label of the relationshipType
* @param submissionId The current submissionId
* @param nameVariant The nameVariant of the relationshipType * @param nameVariant The nameVariant of the relationshipType
*/ */
constructor( constructor(
@@ -94,6 +96,7 @@ export class RemoveRelationshipAction implements Action {
* @param item1 The first item in the relationship * @param item1 The first item in the relationship
* @param item2 The second item in the relationship * @param item2 The second item in the relationship
* @param relationshipType The label of the relationshipType * @param relationshipType The label of the relationshipType
* @param submissionId The current submissionId
*/ */
constructor( constructor(
item1: Item, item1: Item,

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects'; import { Actions, Effect, ofType } from '@ngrx/effects';
import { debounceTime, filter, map, mergeMap, switchMap, take } from 'rxjs/operators'; import { debounceTime, filter, map, mergeMap, switchMap, take, tap } from 'rxjs/operators';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { RelationshipService } from '../../../../../core/data/relationship.service'; import { RelationshipService } from '../../../../../core/data/relationship.service';
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../core/shared/operators'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../core/shared/operators';
@@ -17,9 +17,10 @@ import { SubmissionState } from '../../../../../submission/submission.reducers';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { ObjectCacheService } from '../../../../../core/cache/object-cache.service'; import { ObjectCacheService } from '../../../../../core/cache/object-cache.service';
import { RequestService } from '../../../../../core/data/request.service'; import { RequestService } from '../../../../../core/data/request.service';
import { ServerSyncBufferActionTypes } from '../../../../../core/cache/server-sync-buffer.actions';
const DEBOUNCE_TIME = 5000; const DEBOUNCE_TIME = 5000;
let updateAfterPatchSubmissionId: string;
/** /**
* NGRX effects for RelationshipEffects * NGRX effects for RelationshipEffects
*/ */
@@ -68,7 +69,6 @@ export class RelationshipEffects {
} else { } else {
this.removeRelationship(item1, item2, relationshipType, submissionId); this.removeRelationship(item1, item2, relationshipType, submissionId);
} }
} }
delete this.debounceMap[identifier]; delete this.debounceMap[identifier];
delete this.initialActionMap[identifier]; delete this.initialActionMap[identifier];
@@ -91,19 +91,31 @@ export class RelationshipEffects {
.pipe( .pipe(
ofType(RelationshipActionTypes.UPDATE_RELATIONSHIP), ofType(RelationshipActionTypes.UPDATE_RELATIONSHIP),
map((action: UpdateRelationshipAction) => { map((action: UpdateRelationshipAction) => {
const { item1, item2, relationshipType, nameVariant } = action.payload; const { item1, item2, relationshipType, submissionId, nameVariant } = action.payload;
const identifier: string = this.createIdentifier(item1, item2, relationshipType); const identifier: string = this.createIdentifier(item1, item2, relationshipType);
const inProgress = hasValue(this.debounceMap[identifier]); const inProgress = hasValue(this.debounceMap[identifier]);
if (inProgress) { if (inProgress) {
this.nameVariantUpdates[identifier] = nameVariant; this.nameVariantUpdates[identifier] = nameVariant;
} else { } else {
this.relationshipService.updateNameVariant(item1, item2, relationshipType, nameVariant) this.relationshipService.updateNameVariant(item1, item2, relationshipType, nameVariant).pipe(take(1))
.subscribe(); .subscribe(() => {
updateAfterPatchSubmissionId = submissionId;
});
} }
} }
) )
); );
@Effect() commitServerSyncBuffer = this.actions$
.pipe(
ofType(ServerSyncBufferActionTypes.COMMIT),
filter(() => hasValue(updateAfterPatchSubmissionId)),
tap(() => console.log('id', updateAfterPatchSubmissionId)),
refreshWorkspaceItemInCache('bla' + updateAfterPatchSubmissionId, this.submissionObjectService, this.objectCache, this.requestService),
tap(() => console.log('id nog s', updateAfterPatchSubmissionId)),
map((submissionObject) => new SaveSubmissionSectionFormSuccessAction(updateAfterPatchSubmissionId, [submissionObject], false))
);
constructor(private actions$: Actions, constructor(private actions$: Actions,
private relationshipService: RelationshipService, private relationshipService: RelationshipService,
private relationshipTypeService: RelationshipTypeService, private relationshipTypeService: RelationshipTypeService,
@@ -133,7 +145,7 @@ export class RelationshipEffects {
} }
), ),
take(1), take(1),
this.removeWorkspaceItemFromCache(submissionId) refreshWorkspaceItemInCache(submissionId, this.submissionObjectService, this.objectCache, this.requestService)
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false))); ).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false)));
} }
@@ -143,25 +155,26 @@ export class RelationshipEffects {
hasValueOperator(), hasValueOperator(),
mergeMap((relationship: Relationship) => this.relationshipService.deleteRelationship(relationship.id)), mergeMap((relationship: Relationship) => this.relationshipService.deleteRelationship(relationship.id)),
take(1), take(1),
this.removeWorkspaceItemFromCache(submissionId) refreshWorkspaceItemInCache(submissionId, this.submissionObjectService, this.objectCache, this.requestService)
).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false))); ).subscribe((submissionObject: SubmissionObject) => this.store.dispatch(new SaveSubmissionSectionFormSuccessAction(submissionId, [submissionObject], false)));
} }
}
removeWorkspaceItemFromCache = (submissionId) => const refreshWorkspaceItemInCache = (submissionId, submissionObjectService, objectCache, requestService) =>
<T>(source: Observable<T>): Observable<SubmissionObject> => <T>(source: Observable<T>): Observable<SubmissionObject> =>
source.pipe( source.pipe(
switchMap(() => this.submissionObjectService.getHrefByID(submissionId).pipe(take(1))), tap(() => console.log(submissionId)),
switchMap(() => submissionObjectService.getHrefByID(submissionId).pipe(take(1))),
switchMap((href: string) => { switchMap((href: string) => {
this.objectCache.remove(href); objectCache.remove(href);
this.requestService.removeByHrefSubstring(submissionId); requestService.removeByHrefSubstring(submissionId);
return combineLatest( return combineLatest(
this.objectCache.hasBySelfLinkObservable(href), objectCache.hasBySelfLinkObservable(href),
this.requestService.hasByHrefObservable(href) requestService.hasByHrefObservable(href)
).pipe( ).pipe(
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC), filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
take(1), take(1),
switchMap(() => this.submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()) as Observable<SubmissionObject>) switchMap(() => submissionObjectService.findById(submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()) as Observable<SubmissionObject>)
) )
} }
)); ));
}

View File

@@ -295,7 +295,7 @@ export class FormComponent implements OnDestroy, OnInit {
removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void { removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
console.log(arrayContext, index); console.log(arrayContext, index);
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray; const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
this.removeArrayItem.emit(this.getEvent($event, arrayContext, index, 'remove')); this.removeArrayItem.emit(this.getEvent($event, arrayContext, index - 1, 'remove'));
this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext); this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
this.formService.changeForm(this.formId, this.formModel); this.formService.changeForm(this.formId, this.formModel);
} }

View File

@@ -259,10 +259,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
if (isNotEmpty(sectionData) && !isEqual(sectionData, this.sectionData.data)) { if (isNotEmpty(sectionData) && !isEqual(sectionData, this.sectionData.data)) {
this.sectionData.data = sectionData; this.sectionData.data = sectionData;
if (this.hasMetadataEnrichment(sectionData)) { if (this.hasMetadataEnrichment(sectionData)) {
const msg = this.translate.instant(
'submission.sections.general.metadata-extracted',
{ sectionId: this.sectionData.id });
this.notificationsService.info(null, msg, null, true);
this.isUpdating = true; this.isUpdating = true;
this.formModel = null; this.formModel = null;
this.cdr.detectChanges(); this.cdr.detectChanges();

View File

@@ -321,10 +321,6 @@ export class SectionsService {
take(1), take(1),
filter(([available, enabled]: [boolean, boolean]) => available)) filter(([available, enabled]: [boolean, boolean]) => available))
.subscribe(([available, enabled]: [boolean, boolean]) => { .subscribe(([available, enabled]: [boolean, boolean]) => {
if (!enabled) {
const msg = this.translate.instant('submission.sections.general.metadata-extracted-new-section', {sectionId});
this.notificationsService.info(null, msg, null, true);
}
this.store.dispatch(new UpdateSectionDataAction(submissionId, sectionId, data, errors)); this.store.dispatch(new UpdateSectionDataAction(submissionId, sectionId, data, errors));
}); });
} }