diff --git a/client/src/app/core/core-services/data-store.service.ts b/client/src/app/core/core-services/data-store.service.ts index 1db3b254b..dbf51dd5a 100644 --- a/client/src/app/core/core-services/data-store.service.ts +++ b/client/src/app/core/core-services/data-store.service.ts @@ -109,6 +109,16 @@ export class UpdateSlot { return this.deletedModels; } + /** + * @returns all changed and deleted model ids in one array. If an id was + * changed and deleted, it will be there twice! But this should not be the case. + */ + public getAllModelsIdsForCollection(collection: string): number[] { + return this.getDeletedModelIdsForCollection(collection).concat( + this.getChangedModelIdsForCollection(collection) + ); + } + /** * Compares this object to another update slot. */ @@ -232,7 +242,7 @@ export class DataStoreUpdateManagerService { // Phase 2: updating all repositories repositories.forEach(repo => { - repo.commitUpdate(); + repo.commitUpdate(slot.getAllModelsIdsForCollection(repo.collectionString)); }); slot.DS.triggerModifiedObservable(); diff --git a/client/src/app/core/repositories/base-repository.ts b/client/src/app/core/repositories/base-repository.ts index e7a799acc..3d59f2272 100644 --- a/client/src/app/core/repositories/base-repository.ts +++ b/client/src/app/core/repositories/base-repository.ts @@ -172,7 +172,6 @@ export abstract class BaseRepository { delete this.viewModelStore[id]; - this.updateViewModelObservable(id); }); } @@ -185,7 +184,6 @@ export abstract class BaseRepository { this.viewModelStore[id] = this.createViewModelWithTitles(this.DS.get(this.collectionString, id)); - this.updateViewModelObservable(id); }); } @@ -282,7 +280,7 @@ export abstract class BaseRepository number): void { this.viewModelSortFn = fn; - this.commitUpdate(); + this.commitUpdate(Object.keys(this.viewModelSubjects).map(x => +x)); } /** @@ -356,7 +354,10 @@ export abstract class BaseRepository { + this.updateViewModelObservable(id); + }); } } diff --git a/client/src/app/core/repositories/motions/workflow-repository.service.ts b/client/src/app/core/repositories/motions/workflow-repository.service.ts index 4a4af3ba7..177e0d991 100644 --- a/client/src/app/core/repositories/motions/workflow-repository.service.ts +++ b/client/src/app/core/repositories/motions/workflow-repository.service.ts @@ -16,7 +16,7 @@ import { DataStoreService } from '../../core-services/data-store.service'; const WorkflowRelations: RelationDefinition[] = [ { - type: 'M2M', + type: 'O2M', ownIdKey: 'states_id', ownKey: 'states', foreignViewModel: ViewState