From 76dd141d866151b91aa9a74631bdf1ff8dfc2a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 26 Mar 2025 10:12:25 +0100 Subject: [PATCH] implement validation context (#18808) --- .../src/packages/core/property-type/index.ts | 1 + .../src/packages/core/property-type/utils/index.ts | 11 +++++++++++ .../workspace/property-type-workspace.context.ts | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/property-type/utils/index.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/index.ts index 7a20184c1a..4d8ddde711 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/index.ts @@ -1,3 +1,4 @@ export * from './constants.js'; +export * from './utils/index.js'; export * from './workspace/index.js'; export type * from './types.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/utils/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/utils/index.ts new file mode 100644 index 0000000000..05b3611367 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/utils/index.ts @@ -0,0 +1,11 @@ +import type { UmbPropertyTypeData } from '../types.js'; + +/** + * Validation Data Path Query generator for Property Type. + * write a JSON-Path filter similar to `?(@.id == '1234-1224-1244')` + * @param {UmbPropertyTypeData} value - the object holding Property Type. + * @returns {string} - a JSON-path query + */ +export function UmbDataPathPropertyTypeQuery(value: Pick): string { + return `?(@.id == '${value.id}')`; +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts index 01224eb0f5..7c759ca1d8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/property-type-workspace.context.ts @@ -19,6 +19,8 @@ import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type' import { UMB_CONTENT_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/content-type'; import { UmbId } from '@umbraco-cms/backoffice/id'; import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs'; +import { UmbValidationContext } from '@umbraco-cms/backoffice/validation'; +import { UmbDataPathPropertyTypeQuery } from '../utils/index.js'; export class UmbPropertyTypeWorkspaceContext extends UmbSubmittableWorkspaceContextBase @@ -32,6 +34,8 @@ export class UmbPropertyTypeWorkspaceContext(undefined); @@ -53,6 +57,15 @@ export class UmbPropertyTypeWorkspaceContext { + if (unique) { + this.validationgContext.setDataPath(UmbDataPathPropertyTypeQuery({ id: unique })); + } + }); + this.#init = this.consumeContext(UMB_CONTENT_TYPE_WORKSPACE_CONTEXT, (context) => { this.#contentTypeContext = context; }) @@ -217,6 +230,7 @@ export class UmbPropertyTypeWorkspaceContext