ability to define controller alias

This commit is contained in:
Niels Lyngsø
2024-08-14 11:17:53 +02:00
parent fd6402a4bc
commit e8bbb863b3

View File

@@ -2,12 +2,16 @@ import { UMB_VALIDATION_CONTEXT } from '../context/validation.context-token.js';
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
const CtrlSymbol = Symbol();
const ObserveSymbol = Symbol();
export class UmbObserveValidationStateController extends UmbControllerBase {
constructor(host: UmbControllerHost, dataPath: string | undefined, callback: (messages: boolean) => void) {
super(host, CtrlSymbol);
constructor(
host: UmbControllerHost,
dataPath: string | undefined,
callback: (messages: boolean) => void,
controllerAlias?: string,
) {
super(host, controllerAlias ?? 'observeValidationState_' + dataPath);
if (dataPath) {
this.consumeContext(UMB_VALIDATION_CONTEXT, (context) => {
this.observe(context.messages.hasMessagesOfPathAndDescendant(dataPath), callback, ObserveSymbol);