From 3f592cfbf6743be9869009c16bb5f011b681577d Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Thu, 26 Nov 2020 13:45:34 +0100 Subject: [PATCH] Add locking interval to datapage --- .../data-page/data-page.component.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/components/data-page/data-page.component.ts b/src/app/components/data-page/data-page.component.ts index c2c26dd..432f674 100644 --- a/src/app/components/data-page/data-page.component.ts +++ b/src/app/components/data-page/data-page.component.ts @@ -48,6 +48,10 @@ export class DataPageComponent implements OnInit { @Input() propertyNameOfUpdateInput: string; + relockingInterval = null; + @Input() + relockingIntervalDuration = 1000 * 60 * 1; + @Output() lockEvent = new EventEmitter(); @Output() saveEvent = new EventEmitter(); @Output() cancelEvent = new EventEmitter(); @@ -67,6 +71,8 @@ export class DataPageComponent implements OnInit { this.id = this.route.snapshot.paramMap.get('id'); this.reloadPageData(); this.dataService.pageData.subscribe((data) => { + // dont overwrite data when in edit mode and relock is performed + if (this.data?.isLockedByMe && data?.isLockedByMe) return; this.data = flatten(data); }); this.dataService.isLoadingPageData.subscribe( @@ -75,6 +81,12 @@ export class DataPageComponent implements OnInit { this.dataService.loadingRowIds.subscribe((loadingRowIds) => { this.isSavingOrLocking = loadingRowIds.includes(this.id); }); + + this.relockingInterval = setInterval(() => { + if (this.data.isLockedByMe) { + this.lock(); + } + }, this.relockingIntervalDuration); } addPropertiesFromGQLSchemaToObject(infoObject: any) { @@ -84,8 +96,10 @@ export class DataPageComponent implements OnInit { } else if (prop.type === 'ReferenceTable') { prop.tableDataGQLType = prop.tableDataGQLType || - this.schemaService.getTypeInformation(this.pageDataGQLType, prop.dataPath) - .type; + this.schemaService.getTypeInformation( + this.pageDataGQLType, + prop.dataPath + ).type; prop.referenceIds = []; } else { const typeInformation = this.schemaService.getTypeInformation(