Skip to content

Commit

Permalink
fix: correct change detection on task def
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Apr 30, 2024
1 parent fee0dc8 commit 55daff2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/app/api/models/task-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export class TaskDefinition extends Entity {

private originalSaveData: string;

public get hasOriginalSaveData(): boolean {
return this.originalSaveData !== undefined && this.originalSaveData !== null;
}

/**
* To check if things have changed, we need to get the initial save data... as it
* isn't empty by default. We can then use
Expand All @@ -90,9 +94,7 @@ export class TaskDefinition extends Entity {
* @param mapping the mapping to get changes
*/
public setOriginalSaveData(mapping: EntityMapping<TaskDefinition>) {
if (!this.originalSaveData) {
this.originalSaveData = JSON.stringify(this.toJson(mapping));
}
this.originalSaveData = JSON.stringify(this.toJson(mapping));
}

public hasChanges<T extends Entity>(mapping: EntityMapping<T>): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export class UnitTaskEditorComponent implements AfterViewInit {
} else {
this.selectedTaskDefinition = taskDefinition;

this.selectedTaskDefinition.setOriginalSaveData(this.taskDefinitionService.mapping);
// Record original save data if none present
if (!this.selectedTaskDefinition.hasOriginalSaveData) {
this.selectedTaskDefinition.setOriginalSaveData(this.taskDefinitionService.mapping);
}
}
}

Expand Down

0 comments on commit 55daff2

Please sign in to comment.