don't hard code path checks

This commit is contained in:
Mads Rasmussen
2024-09-24 21:47:53 +02:00
parent 363901ca11
commit 424828e8f6

View File

@@ -33,7 +33,8 @@ export class UmbLanguageWorkspaceContext
{
path: 'create',
component: UmbLanguageWorkspaceEditorElement,
setup: async () => {
setup: async (_component, info) => {
this._setActivePathSegment(info.match.fragments.consumed);
this.create({ parent: { entityType: UMB_LANGUAGE_ROOT_ENTITY_TYPE, unique: null } });
new UmbWorkspaceIsNewRedirectController(
@@ -49,19 +50,12 @@ export class UmbLanguageWorkspaceContext
setup: (_component, info) => {
this.removeUmbControllerByAlias('isNewRedirectController');
this.load(info.match.params.unique);
this._setActivePathSegment(info.match.fragments.consumed);
},
},
]);
}
protected override _checkWillNavigateAway(newUrl: string): boolean {
if (this.getIsNew()) {
return !newUrl.includes(`/create`) || super._checkWillNavigateAway(newUrl);
} else {
return !newUrl.includes(`/edit/${this.getUnique()}`) || super._checkWillNavigateAway(newUrl);
}
}
setName(name: string) {
this._data.updateCurrentData({ name });
}