add scaffold model

This commit is contained in:
Mads Rasmussen
2024-01-30 14:38:35 +01:00
parent 0c1c8890df
commit 539e0bf06b
2 changed files with 11 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import type { UmbContentTypeModel, UmbPropertyTypeModel } from './types.js';
import type { UmbContentTypeModel, UmbPropertyTypeModel, UmbPropertyTypeScaffoldModel } from './types.js';
import type { UmbDetailRepository } from '@umbraco-cms/backoffice/repository';
import { UmbId } from '@umbraco-cms/backoffice/id';
import type { PropertyTypeContainerModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
@@ -273,13 +273,12 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
}
createPropertyScaffold(containerId: string | null = null, sortOrder?: number) {
const property: UmbPropertyTypeModel = {
const property: UmbPropertyTypeScaffoldModel = {
id: UmbId.new(),
containerId: containerId,
container: containerId ? { id: containerId } : null,
alias: '',
name: '',
description: '',
dataTypeId: '',
variesByCulture: false,
variesBySegment: false,
validation: {
@@ -292,7 +291,7 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
labelOnTop: false,
},
sortOrder: sortOrder ?? 0,
} as any; // Sort order was not allowed when this was written.
};
return property;
}
@@ -301,11 +300,12 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
await this.#init;
contentTypeUnique = contentTypeUnique ?? this.#ownerContentTypeUnique!;
const property: UmbPropertyTypeModel = this.createPropertyScaffold(containerId, sortOrder);
const property = this.createPropertyScaffold(containerId, sortOrder);
const properties = [
const properties: Array<UmbPropertyTypeScaffoldModel | UmbPropertyTypeModel> = [
...(this.#contentTypes.getValue().find((x) => x.unique === contentTypeUnique)?.properties ?? []),
];
properties.push(property);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

View File

@@ -22,6 +22,10 @@ export interface UmbContentTypeModel {
compositions: Array<UmbContentTypeCompositionModel>;
}
export interface UmbPropertyTypeScaffoldModel extends Omit<UmbPropertyTypeModel, 'dataType'> {
dataType?: UmbPropertyTypeModel['dataType'];
}
export interface UmbPropertyTypeModel extends Omit<PropertyTypeModelBaseModel, 'dataType'> {
dataType: { unique: string };
}