From 51f2b6cd8844faf2d698b8e8347cb581e403e78b Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 14 Feb 2023 10:47:16 +0100 Subject: [PATCH] Rename content property to content value in view model layer --- .../Mapping/Content/ContentMapDefinition.cs | 14 +- .../Mapping/Document/DocumentMapDefinition.cs | 4 +- src/Umbraco.Cms.Api.Management/OpenApi.json | 508 ++++++++++++++++++ .../Content/ContentViewModelBase.cs | 8 +- ...ViewModelBase.cs => ValueViewModelBase.cs} | 2 +- ...ViewModel.cs => DocumentValueViewModel.cs} | 2 +- .../ViewModels/Document/DocumentViewModel.cs | 2 +- 7 files changed, 524 insertions(+), 16 deletions(-) rename src/Umbraco.Cms.Api.Management/ViewModels/Content/{PropertyViewModelBase.cs => ValueViewModelBase.cs} (84%) rename src/Umbraco.Cms.Api.Management/ViewModels/Document/{DocumentPropertyViewModel.cs => DocumentValueViewModel.cs} (65%) diff --git a/src/Umbraco.Cms.Api.Management/Mapping/Content/ContentMapDefinition.cs b/src/Umbraco.Cms.Api.Management/Mapping/Content/ContentMapDefinition.cs index 7d701069b1..5d381d74da 100644 --- a/src/Umbraco.Cms.Api.Management/Mapping/Content/ContentMapDefinition.cs +++ b/src/Umbraco.Cms.Api.Management/Mapping/Content/ContentMapDefinition.cs @@ -5,20 +5,20 @@ using Umbraco.Extensions; namespace Umbraco.Cms.Api.Management.Mapping.Content; -public abstract class ContentMapDefinition +public abstract class ContentMapDefinition where TContent : IContentBase - where TPropertyViewModel : PropertyViewModelBase, new() + where TValueViewModel : ValueViewModelBase, new() where TVariantViewModel : VariantViewModelBase, new() { private readonly PropertyEditorCollection _propertyEditorCollection; protected ContentMapDefinition(PropertyEditorCollection propertyEditorCollection) => _propertyEditorCollection = propertyEditorCollection; - protected delegate void PropertyViewModelMapping(IDataEditor propertyEditor, TPropertyViewModel variantViewModel); + protected delegate void ValueViewModelMapping(IDataEditor propertyEditor, TValueViewModel variantViewModel); protected delegate void VariantViewModelMapping(string? culture, string? segment, TVariantViewModel variantViewModel); - protected IEnumerable MapPropertyViewModels(TContent source, PropertyViewModelMapping? additionalPropertyMapping = null) => + protected IEnumerable MapValueViewModels(TContent source, ValueViewModelMapping? additionalPropertyMapping = null) => source .Properties .SelectMany(property => property @@ -31,15 +31,15 @@ public abstract class ContentMapDefinition, IMapDefinition +public class DocumentMapDefinition : ContentMapDefinition, IMapDefinition { public DocumentMapDefinition(PropertyEditorCollection propertyEditorCollection) : base(propertyEditorCollection) @@ -22,7 +22,7 @@ public class DocumentMapDefinition : ContentMapDefinition diff --git a/src/Umbraco.Cms.Api.Management/OpenApi.json b/src/Umbraco.Cms.Api.Management/OpenApi.json index 328914ed1f..a3d8f5d2ce 100644 --- a/src/Umbraco.Cms.Api.Management/OpenApi.json +++ b/src/Umbraco.Cms.Api.Management/OpenApi.json @@ -1239,6 +1239,44 @@ } } }, + "/umbraco/management/api/v1/document-type/{key}": { + "get": { + "tags": [ + "Document Type" + ], + "operationId": "GetDocumentTypeByKey", + "parameters": [ + { + "name": "key", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentTypeModel" + } + ] + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, "/umbraco/management/api/v1/tree/document-type/children": { "get": { "tags": [ @@ -1383,6 +1421,44 @@ } } }, + "/umbraco/management/api/v1/document/{key}": { + "get": { + "tags": [ + "Document" + ], + "operationId": "GetDocumentByKey", + "parameters": [ + { + "name": "key", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentModel" + } + ] + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, "/umbraco/management/api/v1/recycle-bin/document/children": { "get": { "tags": [ @@ -5278,6 +5354,16 @@ }, "additionalProperties": false }, + "ContentStateModel": { + "enum": [ + "NotCreated", + "Draft", + "Published", + "PublishedPendingChanges" + ], + "type": "integer", + "format": "int32" + }, "ContentTreeItemModel": { "type": "object", "allOf": [ @@ -5295,6 +5381,189 @@ }, "additionalProperties": false }, + "ContentTypeCleanupModel": { + "type": "object", + "properties": { + "preventCleanup": { + "type": "boolean" + }, + "keepAllVersionsNewerThanDays": { + "type": "integer", + "format": "int32", + "nullable": true + }, + "keepLatestVersionPerDayForDays": { + "type": "integer", + "format": "int32", + "nullable": true + } + }, + "additionalProperties": false + }, + "ContentTypeCompositionModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "compositionType": { + "$ref": "#/components/schemas/ContentTypeCompositionTypeModel" + } + }, + "additionalProperties": false + }, + "ContentTypeCompositionTypeModel": { + "enum": [ + "Composition", + "Inheritance" + ], + "type": "integer", + "format": "int32" + }, + "ContentTypeSortModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "sortOrder": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "ContentTypeViewModelBaseDocumentTypePropertyTypeDocumentTypePropertyTypeContainerModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "alias": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "icon": { + "type": "string" + }, + "allowedAsRoot": { + "type": "boolean" + }, + "variesByCulture": { + "type": "boolean" + }, + "variesBySegment": { + "type": "boolean" + }, + "isElement": { + "type": "boolean" + }, + "properties": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentTypePropertyTypeModel" + } + ] + } + }, + "containers": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentTypePropertyTypeContainerModel" + } + ] + } + }, + "allowedContentTypes": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/ContentTypeSortModel" + } + ] + } + }, + "compositions": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/ContentTypeCompositionModel" + } + ] + } + }, + "cleanup": { + "oneOf": [ + { + "$ref": "#/components/schemas/ContentTypeCleanupModel" + } + ] + } + }, + "additionalProperties": false + }, + "ContentUrlInfoModel": { + "type": "object", + "properties": { + "culture": { + "type": "string", + "nullable": true + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "ContentViewModelBaseDocumentValueDocumentVariantModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "contentTypeKey": { + "type": "string", + "format": "uuid" + }, + "values": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentValueModel" + } + ] + } + }, + "variants": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/DocumentVariantModel" + } + ] + } + } + }, + "additionalProperties": false + }, "CultureModel": { "type": "object", "properties": { @@ -5719,6 +5988,32 @@ }, "additionalProperties": false }, + "DocumentModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/ContentViewModelBaseDocumentValueDocumentVariantModel" + } + ], + "properties": { + "urls": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/ContentUrlInfoModel" + } + ] + } + }, + "templateKey": { + "type": "string", + "format": "uuid", + "nullable": true + } + }, + "additionalProperties": false + }, "DocumentTreeItemModel": { "type": "object", "allOf": [ @@ -5739,6 +6034,47 @@ }, "additionalProperties": false }, + "DocumentTypeModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/ContentTypeViewModelBaseDocumentTypePropertyTypeDocumentTypePropertyTypeContainerModel" + } + ], + "properties": { + "allowedTemplateKeys": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "defaultTemplateKey": { + "type": "string", + "format": "uuid", + "nullable": true + } + }, + "additionalProperties": false + }, + "DocumentTypePropertyTypeContainerModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyTypeContainerViewModelBaseModel" + } + ], + "additionalProperties": false + }, + "DocumentTypePropertyTypeModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyTypeViewModelBaseModel" + } + ], + "additionalProperties": false + }, "DocumentTypeTreeItemModel": { "type": "object", "allOf": [ @@ -5753,6 +6089,34 @@ }, "additionalProperties": false }, + "DocumentValueModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/ValueViewModelBaseModel" + } + ], + "additionalProperties": false + }, + "DocumentVariantModel": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/VariantViewModelBaseModel" + } + ], + "properties": { + "state": { + "$ref": "#/components/schemas/ContentStateModel" + }, + "publishDate": { + "type": "string", + "format": "date-time", + "nullable": true + } + }, + "additionalProperties": false + }, "EntityTreeItemModel": { "type": "object", "allOf": [ @@ -7015,6 +7379,105 @@ }, "additionalProperties": false }, + "PropertyTypeAppearanceModel": { + "type": "object", + "properties": { + "labelOnTop": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "PropertyTypeContainerViewModelBaseModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "parentKey": { + "type": "string", + "format": "uuid", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "type": { + "type": "string" + }, + "sortOrder": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "PropertyTypeValidationModel": { + "type": "object", + "properties": { + "mandatory": { + "type": "boolean" + }, + "mandatoryMessage": { + "type": "string", + "nullable": true + }, + "regEx": { + "type": "string", + "nullable": true + }, + "regExMessage": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "PropertyTypeViewModelBaseModel": { + "type": "object", + "properties": { + "key": { + "type": "string", + "format": "uuid" + }, + "containerKey": { + "type": "string", + "format": "uuid", + "nullable": true + }, + "alias": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "dataTypeKey": { + "type": "string", + "format": "uuid" + }, + "validation": { + "oneOf": [ + { + "$ref": "#/components/schemas/PropertyTypeValidationModel" + } + ] + }, + "appearance": { + "oneOf": [ + { + "$ref": "#/components/schemas/PropertyTypeAppearanceModel" + } + ] + } + }, + "additionalProperties": false + }, "RecycleBinItemModel": { "type": "object", "properties": { @@ -7585,6 +8048,51 @@ }, "additionalProperties": false }, + "ValueViewModelBaseModel": { + "type": "object", + "properties": { + "culture": { + "type": "string", + "nullable": true + }, + "segment": { + "type": "string", + "nullable": true + }, + "alias": { + "type": "string" + }, + "value": { + "nullable": true + } + }, + "additionalProperties": false + }, + "VariantViewModelBaseModel": { + "type": "object", + "properties": { + "culture": { + "type": "string", + "nullable": true + }, + "segment": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string" + }, + "createDate": { + "type": "string", + "format": "date-time" + }, + "updateDate": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false + }, "VersionModel": { "type": "object", "properties": { diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Content/ContentViewModelBase.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Content/ContentViewModelBase.cs index ab29cd5088..8274e0a3e5 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Content/ContentViewModelBase.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Content/ContentViewModelBase.cs @@ -1,14 +1,14 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Content; -public abstract class ContentViewModelBase - where TPropertyViewModel : PropertyViewModelBase - where TVariantViewModel: VariantViewModelBase +public abstract class ContentViewModelBase + where TValueViewModelBase : ValueViewModelBase + where TVariantViewModel : VariantViewModelBase { public Guid Key { get; set; } public Guid ContentTypeKey { get; set; } - public IEnumerable Properties { get; set; } = Array.Empty(); + public IEnumerable Values { get; set; } = Array.Empty(); public IEnumerable Variants { get; set; } = Array.Empty(); } diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Content/PropertyViewModelBase.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Content/ValueViewModelBase.cs similarity index 84% rename from src/Umbraco.Cms.Api.Management/ViewModels/Content/PropertyViewModelBase.cs rename to src/Umbraco.Cms.Api.Management/ViewModels/Content/ValueViewModelBase.cs index d2d4195c25..9dacaa9f2b 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Content/PropertyViewModelBase.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Content/ValueViewModelBase.cs @@ -1,6 +1,6 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Content; -public abstract class PropertyViewModelBase +public abstract class ValueViewModelBase { public string? Culture { get; set; } diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentPropertyViewModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentValueViewModel.cs similarity index 65% rename from src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentPropertyViewModel.cs rename to src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentValueViewModel.cs index 47ec87c3b0..c8211460cb 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentPropertyViewModel.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentValueViewModel.cs @@ -2,6 +2,6 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Document; -public class DocumentPropertyViewModel : PropertyViewModelBase +public class DocumentValueViewModel : ValueViewModelBase { } diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentViewModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentViewModel.cs index 5742bb29d7..a036205959 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentViewModel.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentViewModel.cs @@ -2,7 +2,7 @@ namespace Umbraco.Cms.Api.Management.ViewModels.Document; -public class DocumentViewModel : ContentViewModelBase +public class DocumentViewModel : ContentViewModelBase { public IEnumerable Urls { get; set; } = Array.Empty();