Skip to content

Commit 989781c

Browse files
committed
use addendum
1 parent 756fa05 commit 989781c

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/router/components/router-slot/router-slot.element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import '@umbraco-cms/backoffice/external/router-slot';
2+
import { UmbRoutePathAddendumResetContext } from '../../contexts/route-path-addendum-reset.context.js';
23
import { UmbRouterSlotInitEvent } from './router-slot-init.event.js';
34
import { UmbRouterSlotChangeEvent } from './router-slot-change.event.js';
45
import type { UmbRoute } from './route.interface.js';
@@ -61,6 +62,9 @@ export class UmbRouterSlotElement extends UmbLitElement {
6162

6263
constructor() {
6364
super();
65+
66+
new UmbRoutePathAddendumResetContext(this);
67+
6468
this.#modalRouter.parent = this.#router;
6569
this.#modalRouter.style.display = 'none';
6670
this.#router.addEventListener('changestate', this._updateRouterPath.bind(this));

src/Umbraco.Web.UI.Client/src/packages/core/router/modal-registration/modal-route-registration.controller.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UMB_ROUTE_CONTEXT } from '../index.js';
1+
import { UMB_ROUTE_CONTEXT, UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from '../index.js';
22
import { encodeFolderName } from '../encode-folder-name.function.js';
33
import type { UmbModalRouteRegistration } from './modal-route-registration.interface.js';
44
import type {
@@ -51,6 +51,7 @@ export class UmbModalRouteRegistrationController<
5151
#init;
5252
#contextConsumer;
5353

54+
#addendum?: string;
5455
#additionalPath?: string;
5556
#uniquePaths: Map<string, string | undefined> = new Map();
5657

@@ -89,9 +90,19 @@ export class UmbModalRouteRegistrationController<
8990
super(host, ctrlAlias ?? alias.toString());
9091
this.#key = UmbId.new();
9192
this.#modalAlias = alias;
92-
//this.#path = path;
9393

94-
this.#contextConsumer = new UmbContextConsumerController(this, UMB_ROUTE_CONTEXT, (_routeContext) => {
94+
this.consumeContext(UMB_ROUTE_PATH_ADDENDUM_CONTEXT, (context) => {
95+
this.observe(
96+
context.addendum,
97+
(addendum) => {
98+
this.#addendum = addendum;
99+
this.#registerModal();
100+
},
101+
'observeAddendum',
102+
);
103+
});
104+
105+
this.#contextConsumer = this.consumeContext(UMB_ROUTE_CONTEXT, (_routeContext) => {
95106
this.#routeContext = _routeContext;
96107
this.#registerModal();
97108
});
@@ -176,6 +187,7 @@ export class UmbModalRouteRegistrationController<
176187
async #registerModal() {
177188
await this.#init;
178189
if (!this.#routeContext) return;
190+
if (this.#addendum === undefined) return;
179191

180192
const pathParts = Array.from(this.#uniquePaths.values());
181193

@@ -184,6 +196,11 @@ export class UmbModalRouteRegistrationController<
184196
this.#unregisterModal();
185197
}
186198

199+
if (this.#addendum !== '') {
200+
// append in the start of pathParts:
201+
pathParts.unshift(this.#addendum);
202+
}
203+
187204
if (this.#additionalPath) {
188205
// Add the configured part of the path:
189206
pathParts.push(this.#additionalPath);

0 commit comments

Comments
 (0)