simplify check

This commit is contained in:
Mads Rasmussen
2024-09-24 19:18:39 +02:00
parent 41ccbf621c
commit 37c4ede076
3 changed files with 6 additions and 18 deletions

View File

@@ -114,14 +114,10 @@ export class UmbDataTypeWorkspaceContext
}
protected override _checkWillNavigateAway(newUrl: string): boolean {
super._checkWillNavigateAway(newUrl);
const workspacePathBase = UMB_WORKSPACE_PATH_PATTERN.generateLocal({ entityType: this.getEntityType() });
if (this.getIsNew()) {
return !newUrl.includes(`${workspacePathBase}/create`);
return !newUrl.includes(`/create`) || super._checkWillNavigateAway(newUrl);
} else {
return !newUrl.includes(`${workspacePathBase}/edit/${this.getUnique()}`);
return !newUrl.includes(`/edit/${this.getUnique()}`) || super._checkWillNavigateAway(newUrl);
}
}

View File

@@ -56,14 +56,10 @@ export class UmbLanguageWorkspaceContext
}
protected override _checkWillNavigateAway(newUrl: string): boolean {
super._checkWillNavigateAway(newUrl);
const workspacePathBase = UMB_WORKSPACE_PATH_PATTERN.generateLocal({ entityType: this.getEntityType() });
if (this.getIsNew()) {
return !newUrl.includes(`${workspacePathBase}/create`);
return !newUrl.includes(`/create`) || super._checkWillNavigateAway(newUrl);
} else {
return !newUrl.includes(`${workspacePathBase}/edit/${this.getUnique()}`);
return !newUrl.includes(`/edit/${this.getUnique()}`) || super._checkWillNavigateAway(newUrl);
}
}

View File

@@ -56,14 +56,10 @@ export class UmbUserWorkspaceContext
}
protected override _checkWillNavigateAway(newUrl: string): boolean {
super._checkWillNavigateAway(newUrl);
const workspacePathBase = UMB_WORKSPACE_PATH_PATTERN.generateLocal({ entityType: this.getEntityType() });
if (this.getIsNew()) {
return !newUrl.includes(`${workspacePathBase}/create`);
return !newUrl.includes(`/create`) || super._checkWillNavigateAway(newUrl);
} else {
return !newUrl.includes(`${workspacePathBase}/edit/${this.getUnique()}`);
return !newUrl.includes(`/edit/${this.getUnique()}`) || super._checkWillNavigateAway(newUrl);
}
}