fix rule validation

This commit is contained in:
Niels Lyngsø
2024-09-02 14:13:48 +02:00
parent 5d8e0a969d
commit 9c84fabed3
3 changed files with 7 additions and 5 deletions

View File

@@ -490,7 +490,7 @@ export class UmbBlockGridEntriesContext
.filter((blockType) => blockType.groupKey === rule.groupKey && blockType.allowInAreas === true)
.map((x) => x.contentElementTypeKey) ?? [];
const groupAmount = layoutEntries.filter((entry) => {
const contentTypeKey = this._manager!.getContentTypeKeyOf(entry.contentUdi);
const contentTypeKey = this._manager!.getContentTypeKeyOfContentUdi(entry.contentUdi);
return contentTypeKey ? groupElementTypeKeys.indexOf(contentTypeKey) !== -1 : false;
}).length;
@@ -503,6 +503,7 @@ export class UmbBlockGridEntriesContext
maxRequirement: maxAllowed,
};
}
return undefined;
}
// For specific elementTypes:
else if (rule.elementTypeKey) {
@@ -519,6 +520,7 @@ export class UmbBlockGridEntriesContext
maxRequirement: maxAllowed,
};
}
return undefined;
}
// Lets fail cause the rule was bad.

View File

@@ -14,7 +14,7 @@ export const UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL = new UmbModalToken<
type: 'sidebar',
size: 'large',
},
data: { entityType: UMB_BLOCK_GRID_TYPE, preset: { allowAtRoot: true } },
data: { entityType: UMB_BLOCK_GRID_TYPE, preset: { allowAtRoot: true, allowInAreas: true } },
},
// Recast the type, so the entityType data prop is not required:
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType' | 'preset'>, UmbWorkspaceModalValue>;

View File

@@ -139,6 +139,9 @@ export abstract class UmbBlockManagerContext<
this.#contentTypes.appendOne(data);
}
getContentTypeKeyOfContentUdi(contentUdi: string) {
return this.getContentOf(contentUdi)?.contentTypeKey;
}
contentTypeOf(contentTypeKey: string) {
return this.#contentTypes.asObservablePart((source) => source.find((x) => x.unique === contentTypeKey));
}
@@ -148,9 +151,6 @@ export abstract class UmbBlockManagerContext<
getContentTypeNameOf(contentTypeKey: string) {
return this.#contentTypes.getValue().find((x) => x.unique === contentTypeKey)?.name;
}
getContentTypeKeyOf(contentTypeKey: string) {
return this.#contentTypes.getValue().find((x) => x.unique === contentTypeKey)?.unique;
}
getContentTypeHasProperties(contentTypeKey: string) {
const properties = this.#contentTypes.getValue().find((x) => x.unique === contentTypeKey)?.properties;
return properties ? properties.length > 0 : false;