1- import { UMB_ROUTE_CONTEXT } from '../index.js' ;
1+ import { UMB_ROUTE_CONTEXT , UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from '../index.js' ;
22import { encodeFolderName } from '../encode-folder-name.function.js' ;
33import type { UmbModalRouteRegistration } from './modal-route-registration.interface.js' ;
44import 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