Aligns the UmbMediaTypeWorkspaceContext with UmbDocumentTypeWorkspaceContext
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { UmbDocumentTypeDetailRepository } from '../repository/detail/document-type-detail.repository.js';
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../entity.js';
|
||||
import type { UmbDocumentTypeDetailModel } from '../types.js';
|
||||
import { UmbContentTypePropertyStructureManager } from '@umbraco-cms/backoffice/content-type';
|
||||
import { UmbEditableWorkspaceContextBase } from '@umbraco-cms/backoffice/workspace';
|
||||
@@ -90,15 +91,17 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
}
|
||||
|
||||
getEntityType() {
|
||||
return 'document-type';
|
||||
return UMB_DOCUMENT_TYPE_ENTITY_TYPE;
|
||||
}
|
||||
|
||||
setName(name: string) {
|
||||
this.structure.updateOwnerContentType({ name });
|
||||
}
|
||||
|
||||
setAlias(alias: string) {
|
||||
this.structure.updateOwnerContentType({ alias });
|
||||
}
|
||||
|
||||
setDescription(description: string) {
|
||||
this.structure.updateOwnerContentType({ description });
|
||||
}
|
||||
@@ -111,21 +114,27 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
setAllowedAtRoot(allowedAtRoot: boolean) {
|
||||
this.structure.updateOwnerContentType({ allowedAtRoot });
|
||||
}
|
||||
|
||||
setVariesByCulture(variesByCulture: boolean) {
|
||||
this.structure.updateOwnerContentType({ variesByCulture });
|
||||
}
|
||||
|
||||
setVariesBySegment(variesBySegment: boolean) {
|
||||
this.structure.updateOwnerContentType({ variesBySegment });
|
||||
}
|
||||
|
||||
setIsElement(isElement: boolean) {
|
||||
this.structure.updateOwnerContentType({ isElement });
|
||||
}
|
||||
|
||||
setAllowedContentTypes(allowedContentTypes: Array<UmbContentTypeSortModel>) {
|
||||
this.structure.updateOwnerContentType({ allowedContentTypes });
|
||||
}
|
||||
|
||||
setCompositions(compositions: Array<UmbContentTypeCompositionModel>) {
|
||||
this.structure.updateOwnerContentType({ compositions });
|
||||
}
|
||||
|
||||
setCollection(collection: UmbReferenceByUnique) {
|
||||
this.structure.updateOwnerContentType({ collection });
|
||||
}
|
||||
@@ -134,6 +143,7 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
setAllowedTemplateIds(allowedTemplates: Array<{ id: string }>) {
|
||||
this.structure.updateOwnerContentType({ allowedTemplates });
|
||||
}
|
||||
|
||||
setDefaultTemplate(defaultTemplate: { id: string }) {
|
||||
this.structure.updateOwnerContentType({ defaultTemplate });
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { UmbMediaTypeDetailRepository } from '../repository/detail/media-type-detail.repository.js';
|
||||
import type { UmbMediaTypeDetailModel } from '../types.js';
|
||||
import { UMB_MEDIA_TYPE_ENTITY_TYPE } from '../entity.js';
|
||||
import type { UmbSaveableWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
import type { UmbMediaTypeDetailModel } from '../types.js';
|
||||
import { UmbEditableWorkspaceContextBase } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbContentTypePropertyStructureManager } from '@umbraco-cms/backoffice/content-type';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbBooleanState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbContentTypeCompositionModel, UmbContentTypeSortModel } from '@umbraco-cms/backoffice/content-type';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models';
|
||||
import type { UmbSaveableWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
|
||||
type EntityType = UmbMediaTypeDetailModel;
|
||||
export class UmbMediaTypeWorkspaceContext
|
||||
@@ -29,6 +31,7 @@ export class UmbMediaTypeWorkspaceContext
|
||||
readonly allowedAtRoot;
|
||||
readonly allowedContentTypes;
|
||||
readonly compositions;
|
||||
readonly collection;
|
||||
|
||||
readonly structure = new UmbContentTypePropertyStructureManager<EntityType>(this, this.repository);
|
||||
|
||||
@@ -47,6 +50,7 @@ export class UmbMediaTypeWorkspaceContext
|
||||
this.allowedAtRoot = this.structure.ownerContentTypeObservablePart((data) => data?.allowedAtRoot);
|
||||
this.allowedContentTypes = this.structure.ownerContentTypeObservablePart((data) => data?.allowedContentTypes);
|
||||
this.compositions = this.structure.ownerContentTypeObservablePart((data) => data?.compositions);
|
||||
this.collection = this.structure.ownerContentTypeObservablePart((data) => data?.collection);
|
||||
}
|
||||
|
||||
protected resetState() {
|
||||
@@ -74,6 +78,39 @@ export class UmbMediaTypeWorkspaceContext
|
||||
return UMB_MEDIA_TYPE_ENTITY_TYPE;
|
||||
}
|
||||
|
||||
setName(name: string) {
|
||||
this.structure.updateOwnerContentType({ name });
|
||||
}
|
||||
|
||||
setAlias(alias: string) {
|
||||
this.structure.updateOwnerContentType({ alias });
|
||||
}
|
||||
|
||||
setDescription(description: string) {
|
||||
this.structure.updateOwnerContentType({ description });
|
||||
}
|
||||
|
||||
// TODO: manage setting icon color alias?
|
||||
setIcon(icon: string) {
|
||||
this.structure.updateOwnerContentType({ icon });
|
||||
}
|
||||
|
||||
setAllowedAtRoot(allowedAtRoot: boolean) {
|
||||
this.structure.updateOwnerContentType({ allowedAtRoot });
|
||||
}
|
||||
|
||||
setAllowedContentTypes(allowedContentTypes: Array<UmbContentTypeSortModel>) {
|
||||
this.structure.updateOwnerContentType({ allowedContentTypes });
|
||||
}
|
||||
|
||||
setCompositions(compositions: Array<UmbContentTypeCompositionModel>) {
|
||||
this.structure.updateOwnerContentType({ compositions });
|
||||
}
|
||||
|
||||
setCollection(collection: UmbReferenceByUnique) {
|
||||
this.structure.updateOwnerContentType({ collection });
|
||||
}
|
||||
|
||||
updateProperty<PropertyName extends keyof EntityType>(propertyName: PropertyName, value: EntityType[PropertyName]) {
|
||||
this.structure.updateOwnerContentType({ [propertyName]: value });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user