From 270cd20083e7aaae763064672aaad1eea0ff639e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 21:09:15 +0200 Subject: [PATCH 1/7] bind server feedback with validation system --- .../server-model-validation.context.ts | 40 +++++-------------- .../document-validation.repository.ts | 8 +--- .../document-validation.server.data-source.ts | 16 +------- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts index ca7834b738..8a39682c50 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts @@ -4,7 +4,7 @@ import { UMB_VALIDATION_CONTEXT } from './validation.context-token.js'; import { UMB_SERVER_MODEL_VALIDATION_CONTEXT } from './server-model-validation.context-token.js'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import type { ApiError, CancelError } from '@umbraco-cms/backoffice/external/backend-api'; +import type { UmbDataSourceResponse } from '@umbraco-cms/backoffice/repository'; type ServerFeedbackEntry = { path: string; messages: Array }; @@ -40,10 +40,7 @@ export class UmbServerModelValidationContext }); } - async askServerForValidation( - data: unknown, - requestPromise: Promise<{ data: unknown; error: ApiError | CancelError | undefined }>, - ): Promise { + async askServerForValidation(data: unknown, requestPromise: Promise>): Promise { this.#context?.messages.removeMessagesByType('server'); this.#serverFeedback = []; @@ -54,38 +51,22 @@ export class UmbServerModelValidationContext }); // Ask the server for validation... - //const { data: feedback, error } = await requestPromise; - await requestPromise; - - //console.log('VALIDATE — Got server response:'); - //console.log(data, error); + const { error } = await requestPromise; // Store this state of the data for translator look ups: this.#data = data; - /* - const fixedData = { - type: 'Error', - title: 'Validation failed', - status: 400, - detail: 'One or more properties did not pass validation', - operationStatus: 'PropertyValidationError', - errors: { - '$.values[0].value': ['#validation.invalidPattern'], - } as Record>, - missingProperties: [], - }; - Object.keys(fixedData.errors).forEach((path) => { - this.#serverFeedback.push({ path, messages: fixedData.errors[path] }); - });*/ + // We are missing some typing here, but we will just go wild: [NL] + const readErrorBody = (error as any).body; + Object.keys(readErrorBody.errors).forEach((path) => { + this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] }); + }); - //this.#isValid = data ? true : false; - //this.#isValid = false; - this.#isValid = true; + this.#isValid = data ? true : false; this.#validatePromiseResolve?.(); this.#validatePromiseResolve = undefined; - //this.#validatePromise = undefined; + // Translate feedback: this.#serverFeedback = this.#serverFeedback.flatMap(this.#executeTranslatorsOnFeedback); } @@ -113,6 +94,7 @@ export class UmbServerModelValidationContext if (this.#translators.indexOf(translator) === -1) { this.#translators.push(translator); } + // execute translators here? } removeTranslator(translator: UmbValidationMessageTranslator): void { diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.repository.ts index e58c62e3ea..8ec8e6ea73 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.repository.ts @@ -24,9 +24,7 @@ export class UmbDocumentValidationRepository extends UmbRepositoryBase { async validateCreate(model: DetailModelType, parentUnique: string | null) { if (!model) throw new Error('Data is missing'); - const { data, error } = await this.#validationDataSource.validateCreate(model, parentUnique); - - return { data, error }; + return this.#validationDataSource.validateCreate(model, parentUnique); } /** @@ -39,8 +37,6 @@ export class UmbDocumentValidationRepository extends UmbRepositoryBase { if (!model) throw new Error('Data is missing'); if (!model.unique) throw new Error('Unique is missing'); - const { data, error } = await this.#validationDataSource.validateUpdate(model); - - return { data, error }; + return this.#validationDataSource.validateUpdate(model); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.server.data-source.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.server.data-source.ts index cfedd19c97..02b354d9b1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.server.data-source.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/validation/document-validation.server.data-source.ts @@ -45,18 +45,12 @@ export class UmbDocumentValidationServerDataSource { }; // Maybe use: tryExecuteAndNotify - const { data, error } = await tryExecute( + return tryExecute( //this.#host, DocumentService.postDocumentValidate({ requestBody, }), ); - - if (data) { - return { data }; - } - - return { error }; } /** @@ -75,18 +69,12 @@ export class UmbDocumentValidationServerDataSource { }; // Maybe use: tryExecuteAndNotify - const { data, error } = await tryExecute( + return tryExecute( //this.#host, DocumentService.putDocumentByIdValidate({ id: model.unique, requestBody, }), ); - - if (!error) { - return { data }; - } - - return { error }; } } From 2c7199fda00006903cba5c0360d90b82c02d3fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 21:29:36 +0200 Subject: [PATCH 2/7] translation refactor --- .../server-model-validation.context.ts | 5 ++-- ...validation-message-translator.interface.ts | 3 +-- ...alidation-message-translator.controller.ts | 27 ++++++++++++------- .../workspace/document-workspace.context.ts | 8 ++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts index 8a39682c50..2c0d51cd08 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts @@ -72,9 +72,8 @@ export class UmbServerModelValidationContext #executeTranslatorsOnFeedback = (feedback: ServerFeedbackEntry) => { return this.#translators.flatMap((translator) => { - if (translator.match(feedback.path)) { - const newPath = translator.translate(feedback.path); - + let newPath: string | undefined; + if ((newPath = translator.translate(feedback.path))) { // TODO: I might need to restructure this part for adjusting existing feedback with a part-translation. // Detect if some part is unhandled? // If so only make a partial translation on the feedback, add a message for the handled part. diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/validation-message-translator.interface.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/validation-message-translator.interface.ts index 0004a924f3..80b66fa608 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/validation-message-translator.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/validation-message-translator.interface.ts @@ -1,4 +1,3 @@ export interface UmbValidationMessageTranslator { - match(message: string): boolean; - translate(message: string): string; + translate(message: string): undefined | string; } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/variant-values-validation-message-translator.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/variant-values-validation-message-translator.controller.ts index 2cc965eace..709c534a77 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/variant-values-validation-message-translator.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/translators/variant-values-validation-message-translator.controller.ts @@ -17,15 +17,24 @@ export class UmbVariantValuesValidationMessageTranslator this.#context = context; } - match(message: string): boolean { - //return message.startsWith('values['); - // regex match, which starts with "$.values[" and then a number and then continues: - return message.indexOf('$.values[') === 0; - } - translate(path: string): string { - // retrieve the number from the message values index: - const index = parseInt(path.substring(9, path.indexOf(']'))); - // + translate(path: string) { + if (path.indexOf('$.values[') !== 0) { + // No translation anyway. + return; + } + const pathEnd = path.indexOf(']'); + if (pathEnd === -1) { + // No translation anyway. + return; + } + // retrieve the number from the message values index: [NL] + const index = parseInt(path.substring(9, pathEnd)); + + if (isNaN(index)) { + // No translation anyway. + return; + } + // Get the data from the validation request, the context holds that for us: [NL] const data = this.#context.getData(); const specificValue = data.values[index]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts index c41e96a116..2c4d81cb51 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts @@ -54,6 +54,7 @@ import { UmbVariantValuesValidationMessageTranslator, } from '@umbraco-cms/backoffice/validation'; import { UmbDocumentBlueprintDetailRepository } from '@umbraco-cms/backoffice/document-blueprint'; +import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'; type EntityType = UmbDocumentDetailModel; export class UmbDocumentWorkspaceContext @@ -649,6 +650,13 @@ export class UmbDocumentWorkspaceContext async () => { // If data of the selection is not valid Then just save: await this.#performSaveOrCreate(saveData); + // Notifying that the save was successful, but we did not publish, which is what we want to symbolize here. [NL] + const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT); + // TODO: Get rid of the save notification. + // TODO: Translate this message [NL] + notificationContext.peek('danger', { + data: { message: 'Document was not published, but we saved it for you.' }, + }); // Reject even thought the save was successful, but we did not publish, which is what we want to symbolize here. [NL] return await Promise.reject(); }, From ece9ba408bbd40081a35b5043f5baa9f2163365a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 22:06:02 +0200 Subject: [PATCH 3/7] retrieve messages --- .../property-layout/property-layout.element.ts | 10 ++++++++++ .../core/property/property/property.element.ts | 11 +++++++---- .../context/server-model-validation.context.ts | 18 ++++++++++-------- .../context/validation-messages.manager.ts | 4 ++-- .../observe-validation-state.controller.ts | 9 +++++++-- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts index cdc2c5fc07..2b28c03dba 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts @@ -56,6 +56,16 @@ export class UmbPropertyLayoutElement extends LitElement { @property({ type: Boolean, reflect: true }) public invalid?: boolean; + /** + * @description Describe why the property is invalid. + * @type {boolean} + * @attr + * @default undefined + */ + @property({ type: String, attribute: 'invalid-message' }) + public invalidMessage?: string; + // TODO: put the invalidMessage in some hover tooltip or something. [NL] + render() { // TODO: Only show alias on label if user has access to DocumentType within settings: return html` diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts index e6397911a7..c3d3cb72b3 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts @@ -109,8 +109,10 @@ export class UmbPropertyElement extends UmbLitElement { @property({ type: String, attribute: false }) public set dataPath(dataPath: string | undefined) { this.#dataPath = dataPath; - new UmbObserveValidationStateController(this, dataPath, (invalid) => { - this._invalid = invalid; + new UmbObserveValidationStateController(this, dataPath, (feedback) => { + // TODO: Join in a pretty way, and localized way(how to join one or more items varies depending on the language. [NL] + // TODO: Also wrap in a general localized message, like "Contains these errors: ..."; [NL] + this._validationMessage = feedback.length > 0 ? feedback.map((x) => x.message).join(', ') : undefined; }); } public get dataPath(): string | undefined { @@ -125,7 +127,7 @@ export class UmbPropertyElement extends UmbLitElement { private _element?: ManifestPropertyEditorUi['ELEMENT_TYPE']; @state() - private _invalid?: boolean; + private _validationMessage?: string; @state() private _alias?: string; @@ -276,7 +278,8 @@ export class UmbPropertyElement extends UmbLitElement { alias="${ifDefined(this._alias)}" label="${ifDefined(this._label)}" description="${ifDefined(this._description)}" - ?invalid=${this._invalid}> + ?invalid=${this._validationMessage !== undefined} + .invalidMessage=${this._validationMessage}> ${this._renderPropertyActionMenu()} ${this._variantDifference ? html`${this._variantDifference}` diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts index 2c0d51cd08..21f0d827fc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts @@ -50,19 +50,21 @@ export class UmbServerModelValidationContext this.#validatePromiseResolve = resolve; }); + // Store this state of the data for translator look ups: + this.#data = data; // Ask the server for validation... const { error } = await requestPromise; - // Store this state of the data for translator look ups: - this.#data = data; + this.#isValid = error ? false : true; - // We are missing some typing here, but we will just go wild: [NL] - const readErrorBody = (error as any).body; - Object.keys(readErrorBody.errors).forEach((path) => { - this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] }); - }); + if (!this.#isValid) { + // We are missing some typing here, but we will just go wild with 'as any': [NL] + const readErrorBody = (error as any).body; + Object.keys(readErrorBody.errors).forEach((path) => { + this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] }); + }); + } - this.#isValid = data ? true : false; this.#validatePromiseResolve?.(); this.#validatePromiseResolve = undefined; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts index 4a26bf1b10..03b31ce790 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts @@ -34,7 +34,7 @@ export class UmbValidationMessagesManager { return this.#messages.getValue().length !== 0; } - /*messagesOf(path: string): Observable> { + messagesOfPathAndDescendant(path: string): Observable> { // Find messages that starts with the given path, if the path is longer then require a dot or [ as the next character. using a more performant way than Regex: return this.#messages.asObservablePart((msgs) => msgs.filter( @@ -43,7 +43,7 @@ export class UmbValidationMessagesManager { (x.path.length === path.length || x.path[path.length] === '.' || x.path[path.length] === '['), ), ); - }*/ + } messagesOfTypeAndPath(type: UmbValidationMessageType, path: string): Observable> { // Find messages that matches the given type and path. diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts index 737c26f1dd..e31d8b720f 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts @@ -1,4 +1,5 @@ import { UMB_VALIDATION_CONTEXT } from '../context/validation.context-token.js'; +import type { UmbValidationMessage } from '../context/validation-messages.manager.js'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; @@ -6,11 +7,15 @@ const CtrlSymbol = Symbol(); const ObserveSymbol = Symbol(); export class UmbObserveValidationStateController extends UmbControllerBase { - constructor(host: UmbControllerHost, dataPath: string | undefined, callback: (invalid: boolean) => void) { + constructor( + host: UmbControllerHost, + dataPath: string | undefined, + callback: (messages: Array) => void, + ) { super(host, CtrlSymbol); if (dataPath) { this.consumeContext(UMB_VALIDATION_CONTEXT, (context) => { - this.observe(context.messages.hasMessagesOfPathAndDescendant(dataPath), callback, ObserveSymbol); + this.observe(context.messages.messagesOfPathAndDescendant(dataPath), callback, ObserveSymbol); }); } } From 6e0fd5a8d8e8b0143f779602f1353e018ade044b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 22:14:22 +0200 Subject: [PATCH 4/7] clean up --- .../property-layout/property-layout.element.ts | 10 ---------- .../core/property/property/property.element.ts | 11 ++++------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts index 2b28c03dba..cdc2c5fc07 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-layout/property-layout.element.ts @@ -56,16 +56,6 @@ export class UmbPropertyLayoutElement extends LitElement { @property({ type: Boolean, reflect: true }) public invalid?: boolean; - /** - * @description Describe why the property is invalid. - * @type {boolean} - * @attr - * @default undefined - */ - @property({ type: String, attribute: 'invalid-message' }) - public invalidMessage?: string; - // TODO: put the invalidMessage in some hover tooltip or something. [NL] - render() { // TODO: Only show alias on label if user has access to DocumentType within settings: return html` diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts index c3d3cb72b3..e6397911a7 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.element.ts @@ -109,10 +109,8 @@ export class UmbPropertyElement extends UmbLitElement { @property({ type: String, attribute: false }) public set dataPath(dataPath: string | undefined) { this.#dataPath = dataPath; - new UmbObserveValidationStateController(this, dataPath, (feedback) => { - // TODO: Join in a pretty way, and localized way(how to join one or more items varies depending on the language. [NL] - // TODO: Also wrap in a general localized message, like "Contains these errors: ..."; [NL] - this._validationMessage = feedback.length > 0 ? feedback.map((x) => x.message).join(', ') : undefined; + new UmbObserveValidationStateController(this, dataPath, (invalid) => { + this._invalid = invalid; }); } public get dataPath(): string | undefined { @@ -127,7 +125,7 @@ export class UmbPropertyElement extends UmbLitElement { private _element?: ManifestPropertyEditorUi['ELEMENT_TYPE']; @state() - private _validationMessage?: string; + private _invalid?: boolean; @state() private _alias?: string; @@ -278,8 +276,7 @@ export class UmbPropertyElement extends UmbLitElement { alias="${ifDefined(this._alias)}" label="${ifDefined(this._label)}" description="${ifDefined(this._description)}" - ?invalid=${this._validationMessage !== undefined} - .invalidMessage=${this._validationMessage}> + ?invalid=${this._invalid}> ${this._renderPropertyActionMenu()} ${this._variantDifference ? html`${this._variantDifference}` From 07d64bdcf27113dd488407858ea1815b4e0660cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 22:15:11 +0200 Subject: [PATCH 5/7] clean up --- .../core/validation/context/validation-messages.manager.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts index 03b31ce790..252f716e92 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/validation-messages.manager.ts @@ -34,6 +34,7 @@ export class UmbValidationMessagesManager { return this.#messages.getValue().length !== 0; } + /* messagesOfPathAndDescendant(path: string): Observable> { // Find messages that starts with the given path, if the path is longer then require a dot or [ as the next character. using a more performant way than Regex: return this.#messages.asObservablePart((msgs) => @@ -44,6 +45,7 @@ export class UmbValidationMessagesManager { ), ); } + */ messagesOfTypeAndPath(type: UmbValidationMessageType, path: string): Observable> { // Find messages that matches the given type and path. From dfb7620254bee556d7428f897b55c133af93a73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 22:16:30 +0200 Subject: [PATCH 6/7] use hasMessagesOfPathAndDescendant --- .../controllers/observe-validation-state.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts index e31d8b720f..2b2c66e66a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts @@ -15,7 +15,7 @@ export class UmbObserveValidationStateController extends UmbControllerBase { super(host, CtrlSymbol); if (dataPath) { this.consumeContext(UMB_VALIDATION_CONTEXT, (context) => { - this.observe(context.messages.messagesOfPathAndDescendant(dataPath), callback, ObserveSymbol); + this.observe(context.messages.hasMessagesOfPathAndDescendant(dataPath), callback, ObserveSymbol); }); } } From 040fe1e9f083ebf2c613197a198b7624cbad1b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 15 Apr 2024 22:46:21 +0200 Subject: [PATCH 7/7] boolean --- .../controllers/observe-validation-state.controller.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts index 2b2c66e66a..3c4ee10667 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/observe-validation-state.controller.ts @@ -1,5 +1,4 @@ import { UMB_VALIDATION_CONTEXT } from '../context/validation.context-token.js'; -import type { UmbValidationMessage } from '../context/validation-messages.manager.js'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; @@ -7,11 +6,7 @@ const CtrlSymbol = Symbol(); const ObserveSymbol = Symbol(); export class UmbObserveValidationStateController extends UmbControllerBase { - constructor( - host: UmbControllerHost, - dataPath: string | undefined, - callback: (messages: Array) => void, - ) { + constructor(host: UmbControllerHost, dataPath: string | undefined, callback: (messages: boolean) => void) { super(host, CtrlSymbol); if (dataPath) { this.consumeContext(UMB_VALIDATION_CONTEXT, (context) => {