From d87a42629487ef800e2aa429cc3b861c07947330 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 22 Sep 2014 18:18:09 +1000 Subject: [PATCH] Implements the ability to have customized and configurable list views for specific content types --- src/Umbraco.Core/Services/DataTypeService.cs | 15 ++- .../Services/IContentTypeService.cs | 1 + src/Umbraco.Core/Services/IDataTypeService.cs | 9 +- .../common/resources/contenttype.resource.js | 39 ++---- .../src/common/resources/datatype.resource.js | 16 +-- .../contenttype.listview.controller.js | 50 ++++++++ .../src/views/contenttype/listview.html | 43 +++++++ .../services/content-type-factory.spec.js | 15 +-- src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 4 + .../umbraco/config/lang/en_us.xml | 6 +- .../controls/ContentTypeControlNew.ascx | 33 ++++- .../Editors/ContentTypeControllerBase.cs | 114 ++++++------------ src/Umbraco.Web/Editors/DataTypeController.cs | 6 + .../ContentTypeContainerConfiguration.cs | 78 ------------ .../Models/ContentEditing/DataTypeBasic.cs | 19 +++ .../Models/ContentEditing/DataTypeDisplay.cs | 11 +- .../Models/Mapping/DataTypeModelMapper.cs | 5 + .../Mapping/TabsAndPropertiesResolver.cs | 10 +- src/Umbraco.Web/Umbraco.Web.csproj | 2 +- .../controls/ContentTypeControlNew.ascx.cs | 9 ++ 20 files changed, 253 insertions(+), 232 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/contenttype/contenttype.listview.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/contenttype/listview.html delete mode 100644 src/Umbraco.Web/Models/ContentEditing/ContentTypeContainerConfiguration.cs create mode 100644 src/Umbraco.Web/Models/ContentEditing/DataTypeBasic.cs diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs index f1bf4d1321..6a451bd073 100644 --- a/src/Umbraco.Core/Services/DataTypeService.cs +++ b/src/Umbraco.Core/Services/DataTypeService.cs @@ -15,7 +15,7 @@ using umbraco.interfaces; namespace Umbraco.Core.Services { /// - /// Represents the DataType Service, which is an easy access to operations involving and + /// Represents the DataType Service, which is an easy access to operations involving /// public class DataTypeService : IDataTypeService { @@ -43,6 +43,19 @@ namespace Umbraco.Core.Services _uowProvider = provider; } + /// + /// Gets a by its Name + /// + /// Name of the + /// + public IDataTypeDefinition GetDataTypeDefinitionByName(string name) + { + using (var repository = _repositoryFactory.CreateDataTypeDefinitionRepository(_uowProvider.GetUnitOfWork())) + { + return repository.GetByQuery(new Query().Where(x => x.Name == name)).FirstOrDefault(); + } + } + /// /// Gets a by its Id /// diff --git a/src/Umbraco.Core/Services/IContentTypeService.cs b/src/Umbraco.Core/Services/IContentTypeService.cs index e07e1e288a..9e2d179bb0 100644 --- a/src/Umbraco.Core/Services/IContentTypeService.cs +++ b/src/Umbraco.Core/Services/IContentTypeService.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Xml.Linq; using Umbraco.Core.Models; diff --git a/src/Umbraco.Core/Services/IDataTypeService.cs b/src/Umbraco.Core/Services/IDataTypeService.cs index 7bf938aa25..00873c0f45 100644 --- a/src/Umbraco.Core/Services/IDataTypeService.cs +++ b/src/Umbraco.Core/Services/IDataTypeService.cs @@ -6,10 +6,17 @@ using umbraco.interfaces; namespace Umbraco.Core.Services { /// - /// Defines the DataType Service, which is an easy access to operations involving and + /// Defines the DataType Service, which is an easy access to operations involving /// public interface IDataTypeService : IService { + /// + /// Gets a by its Name + /// + /// Name of the + /// + IDataTypeDefinition GetDataTypeDefinitionByName(string name); + /// /// Gets a by its Id /// diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index 63a94407ba..deaa857e94 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -7,38 +7,17 @@ function contentTypeResource($q, $http, umbRequestHelper) { return { - /** - * @ngdoc method - * @name umbraco.resources.contentTypeResource#getContentType - * @methodOf umbraco.resources.contentTypeResource - * - * @description - * Returns a content type with a given ID - * - * ##usage - *
-         * contentTypeResource.getContentType(1234)
-         *    .then(function(type) {
-         *        $scope.type = type;
-         *    });
-         * 
- * @param {Int} id id of the content type to retrieve - * @returns {Promise} resourcePromise object. - * - */ - getContentType: function (id) { + getAssignedListViewDataType: function (contentTypeId) { - var deferred = $q.defer(); - var data = { - name: "News Article", - alias: "newsArticle", - id: id, - tabs: [] - }; - - deferred.resolve(data); - return deferred.promise; + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "contentTypeApiBaseUrl", + "GetAssignedListViewDataType", + [{ contentTypeId: contentTypeId }])), + 'Failed to retrieve data for content id ' + contentTypeId); }, + /** * @ngdoc method diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js index ed7c2e726a..3bd8548990 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/datatype.resource.js @@ -152,23 +152,11 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) { /** * @ngdoc method - * @name umbraco.resources.dataTypeResource#deleteById + * @name umbraco.resources.dataTypeResource#save * @methodOf umbraco.resources.dataTypeResource * * @description - * Saves or update a data typw - * - * ##usage - *
-         * dataTypeResource.getById(1234)
-         *    .then(function(type) {
-         *        type.name ="hibba";
-         *  
-         *        dataTypeResource.save(type, type.preValues, false).then(function(type){
-         *          alert('its done!');
-         *        }): 
-         *    });
-         * 
+ * Saves or update a data type * * @param {Object} dataType data type object to create/update * @param {Array} preValues collection of prevalues on the datatype diff --git a/src/Umbraco.Web.UI.Client/src/views/contenttype/contenttype.listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/contenttype/contenttype.listview.controller.js new file mode 100644 index 0000000000..252d063add --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/contenttype/contenttype.listview.controller.js @@ -0,0 +1,50 @@ +/** + * @ngdoc controller + * @name Umbraco.Editors.ContentType.ListViewController + * @function + * + * @description + * The controller for the customize list view dialog for content types + */ +function ContentTypeListViewController($scope, contentTypeResource, dataTypeResource) { + + + function init() { + contentTypeResource.getAssignedListViewDataType($scope.dialogOptions.contentTypeId) + .then(function(d) { + $scope.listViewName = d.name; + $scope.isSystem = d.isSystem; + $scope.dataTypeId = d.id; + }); + } + + $scope.listViewName = ""; + $scope.isSystem = true; + $scope.dataTypeId = 0; + + $scope.createCustom = function() { + dataTypeResource.save({ + id: 0, + name: "List View - " + $scope.dialogOptions.contentTypeAlias, + selectedEditor: "Umbraco.ListView" + }, [], true) + .then(function(d) { + $scope.listViewName = d.name; + $scope.isSystem = d.isSystem; + $scope.dataTypeId = d.id; + }); + } + + $scope.removeCustom = function() { + if (!$scope.isSystem && $scope.dataTypeId > 0) { + dataTypeResource.deleteById($scope.dataTypeId) + .then(function() { + init(); + }); + } + } + + init(); +} + +angular.module("umbraco").controller("Umbraco.Editors.ContentType.ListViewController", ContentTypeListViewController); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/contenttype/listview.html b/src/Umbraco.Web.UI.Client/src/views/contenttype/listview.html new file mode 100644 index 0000000000..25ee20fcfb --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/contenttype/listview.html @@ -0,0 +1,43 @@ +
+ + + +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-factory.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-factory.spec.js index 32cc192a4c..ce0921a3fb 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-factory.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-factory.spec.js @@ -19,20 +19,7 @@ describe('content type factory tests', function () { })); describe('global content type factory crud', function () { - - it('should return a content type object, given an id', function () { - var ct1; - contentTypeResource.getContentType(1234).then(function(result){ - ct1 = result; - }); - - $rootScope.$digest(); - - expect(ct1).toNotBe(undefined); - expect(ct1.id).toBe(1234); - }); - - + it('should return a allowed content type collection given a document id', function(){ // m.expectAllowedChildren(); diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index ebeef02ae1..7865f749b8 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -256,6 +256,10 @@ Tab Thumbnail Enable list view + Customize list view + Current list view + Create custom list view + Remove custom list view Add prevalue diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 4267911bcf..2a7505b562 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -251,7 +251,7 @@ - Allowed child nodetypes + Allowed child node types Document Type Compositions Create Delete tab @@ -260,6 +260,10 @@ Tab Thumbnail Enable list view + Customize list view + Current list view + Create custom list view + Remove custom list view Add prevalue diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index 1caf31bf5f..0266a9eab7 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -78,8 +78,39 @@ -
+ + + <%if (cb_isContainer.Checked) { %> +

+ Configure list view... +

+ <%--Scripting to show hide the button if the doc type is already configured to be a list view--%> + + + <%} %> +
+ diff --git a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs index db5afe8ad2..0c3b61d9eb 100644 --- a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs @@ -4,10 +4,13 @@ using System.Linq; using System.Net; using System.Text.RegularExpressions; using System.Web.Http; +using AutoMapper; using Newtonsoft.Json; using Umbraco.Core; +using Umbraco.Core.Models; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; +using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { @@ -20,7 +23,7 @@ namespace Umbraco.Web.Editors /// /// Constructor /// - public ContentTypeControllerBase() + protected ContentTypeControllerBase() : this(UmbracoContext.Current) { } @@ -29,91 +32,42 @@ namespace Umbraco.Web.Editors /// Constructor /// /// - public ContentTypeControllerBase(UmbracoContext umbracoContext) + protected ContentTypeControllerBase(UmbracoContext umbracoContext) : base(umbracoContext) { } - /// - /// Returns the container configuration JSON structure for the content item id passed in - /// - /// - public ContentTypeContainerConfiguration GetContainerConfig(int contentId) + public DataTypeBasic GetAssignedListViewDataType(int contentTypeId) { - //var contentItem = Services.ContentService.GetById(contentId); - //if (contentItem == null) - //{ - // throw new HttpResponseException(HttpStatusCode.NotFound); - //} + var objectType = Services.EntityService.GetObjectType(contentTypeId); - //if (!string.IsNullOrEmpty(contentItem.ContentType.ContainerConfig)) - //{ - // var containerConfig = JsonConvert.DeserializeObject(contentItem.ContentType.ContainerConfig); - // containerConfig.AdditionalColumns = new List(); - - // // Populate the column headings and localization keys - // if (!string.IsNullOrEmpty(containerConfig.AdditionalColumnAliases)) - // { - // // Find all the properties for doc types that might be in the list - // var allowedContentTypeIds = contentItem.ContentType.AllowedContentTypes - // .Select(x => x.Id.Value) - // .ToArray(); - // var allPropertiesOfAllowedContentTypes = Services.ContentTypeService - // .GetAllContentTypes(allowedContentTypeIds) - // .SelectMany(x => x.PropertyTypes) - // .ToList(); - - // foreach (var alias in containerConfig.AdditionalColumnAliases.Split(',')) - // { - // var column = new ContentTypeContainerConfiguration.AdditionalColumnDetail - // { - // Alias = alias, - // LocalizationKey = string.Empty, - // AllowSorting = true, - // }; - - // // Try to find heading from custom property (getting the name from the alias) - // // - need to look in children of the current content's content type - // var property = allPropertiesOfAllowedContentTypes - // .FirstOrDefault(x => x.Alias == alias.ToFirstLower()); - // if (property != null) - // { - // column.Header = property.Name; - // column.AllowSorting = false; // can't sort on custom property columns - // } - // else if (alias == "UpdateDate") - // { - // // Special case to restore hard-coded column titles - // column.Header = "Last edited"; - // column.LocalizationKey = "defaultdialogs_lastEdited"; - // } - // else if (alias == "Updater") - // { - // // Special case to restore hard-coded column titles (2) - // column.Header = "Updated by"; - // column.LocalizationKey = "content_updatedBy"; - // } - // else if (alias == "Owner") - // { - // // Special case to restore hard-coded column titles (3) - // column.Header = "Created by"; - // column.LocalizationKey = "content_createBy"; - // } - // else - // { - // // For others just sentence case the alias and camel case for the key - // column.Header = alias.ToFirstUpper().SplitPascalCasing(); - // column.LocalizationKey = "content_" + alias.ToFirstLower(); - // } - - // containerConfig.AdditionalColumns.Add(column); - // } - // } - - // return containerConfig; - //} - - return null; + switch (objectType) + { + case UmbracoObjectTypes.MemberType: + var memberType = Services.MemberTypeService.Get(contentTypeId); + var dtMember = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + memberType.Alias); + return dtMember == null + ? Mapper.Map( + Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + "Member")) + : Mapper.Map(dtMember); + case UmbracoObjectTypes.MediaType: + var mediaType = Services.ContentTypeService.GetMediaType(contentTypeId); + var dtMedia = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + mediaType.Alias); + return dtMedia == null + ? Mapper.Map( + Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + "Media")) + : Mapper.Map(dtMedia); + case UmbracoObjectTypes.DocumentType: + var docType = Services.ContentTypeService.GetContentType(contentTypeId); + var dtDoc = Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + docType.Alias); + return dtDoc == null + ? Mapper.Map( + Services.DataTypeService.GetDataTypeDefinitionByName(Constants.Conventions.DataTypes.ListViewPrefix + "Content")) + : Mapper.Map(dtDoc); + default: + throw new ArgumentOutOfRangeException(); + } } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Editors/DataTypeController.cs b/src/Umbraco.Web/Editors/DataTypeController.cs index fb48858318..2b3c75838b 100644 --- a/src/Umbraco.Web/Editors/DataTypeController.cs +++ b/src/Umbraco.Web/Editors/DataTypeController.cs @@ -33,6 +33,12 @@ namespace Umbraco.Web.Editors [UmbracoTreeAuthorize(Constants.Trees.DataTypes)] public class DataTypeController : UmbracoAuthorizedJsonController { + public DataTypeDisplay GetByName(string name) + { + var dataType = Services.DataTypeService.GetDataTypeDefinitionByName(name); + return dataType == null ? null : Mapper.Map(dataType); + } + /// /// Gets the content json for the content id /// diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentTypeContainerConfiguration.cs b/src/Umbraco.Web/Models/ContentEditing/ContentTypeContainerConfiguration.cs deleted file mode 100644 index 3c34c0c7fa..0000000000 --- a/src/Umbraco.Web/Models/ContentEditing/ContentTypeContainerConfiguration.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; - -namespace Umbraco.Web.Models.ContentEditing -{ - /// - /// A model representing the configuration for a content type defined as a list container - /// - [DataContract(Name = "config", Namespace = "")] - public class ContentTypeContainerConfiguration - { - /// - /// The page size for the list - /// - [DataMember(Name = "pageSize")] - public int PageSize { get; set; } - - /// - /// The aliases additional columns displayed after the node name in the list - /// - [DataMember(Name = "additionalColumnAliases")] - public string AdditionalColumnAliases { get; set; } - - /// - /// The default order by column for the list - /// - [DataMember(Name = "orderBy")] - public string OrderBy { get; set; } - - /// - /// The default order direction for the list - /// - [DataMember(Name = "orderDirection")] - public string OrderDirection { get; set; } - - /// - /// Flag for whether bulk publishing is allowed - /// - [DataMember(Name = "allowBulkPublish")] - public bool AllowBulkPublish { get; set; } - - /// - /// Flag for whether bulk unpublishing is allowed - /// - [DataMember(Name = "allowBulkUnpublish")] - public bool AllowBulkUnpublish { get; set; } - - /// - /// Flag for whether bulk deletion is allowed - /// - [DataMember(Name = "allowBulkDelete")] - public bool AllowBulkDelete { get; set; } - - /// - /// The column details for the additional columns displayed after the node name in the list - /// - /// This isn't persisted, but is calculated from the aliases when passed to the UI - [DataMember(Name = "additionalColumns")] - public IList AdditionalColumns { get; set; } - - [DataContract(Namespace = "")] - public class AdditionalColumnDetail - { - [DataMember(Name = "alias")] - public string Alias { get; set; } - - [DataMember(Name = "header")] - public string Header { get; set; } - - [DataMember(Name = "localizationKey")] - public string LocalizationKey { get; set; } - - [DataMember(Name = "allowSorting")] - public bool AllowSorting { get; set; } - } - } -} diff --git a/src/Umbraco.Web/Models/ContentEditing/DataTypeBasic.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeBasic.cs new file mode 100644 index 0000000000..0efb67f567 --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeBasic.cs @@ -0,0 +1,19 @@ +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.ContentEditing +{ + /// + /// The basic data type information + /// + [DataContract(Name = "dataType", Namespace = "")] + public class DataTypeBasic : EntityBasic + { + /// + /// Whether or not this is a system data type, in which case it cannot be deleted + /// + [DataMember(Name = "isSystem")] + [ReadOnly(true)] + public bool IsSystemDataType { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs index b58773a621..795d334e71 100644 --- a/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; @@ -10,7 +9,7 @@ namespace Umbraco.Web.Models.ContentEditing /// Represents a data type that is being edited /// [DataContract(Name = "dataType", Namespace = "")] - public class DataTypeDisplay : EntityBasic, INotificationModel + public class DataTypeDisplay : DataTypeBasic, INotificationModel { public DataTypeDisplay() { @@ -35,12 +34,6 @@ namespace Umbraco.Web.Models.ContentEditing /// [DataMember(Name = "notifications")] public List Notifications { get; private set; } - - /// - /// Whether or not this is a system data type, in which case it cannot be deleted - /// - [DataMember(Name = "isSystem")] - [ReadOnly(true)] - public bool IsSystemDataType { get; set; } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Models/Mapping/DataTypeModelMapper.cs b/src/Umbraco.Web/Models/Mapping/DataTypeModelMapper.cs index 2ec97b6b3b..8652cfb8c6 100644 --- a/src/Umbraco.Web/Models/Mapping/DataTypeModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/DataTypeModelMapper.cs @@ -34,6 +34,11 @@ namespace Umbraco.Web.Models.Mapping Constants.System.DefaultMembersListViewDataTypeId }; + config.CreateMap() + .ForMember(x => x.Icon, expression => expression.Ignore()) + .ForMember(x => x.Alias, expression => expression.Ignore()) + .ForMember(x => x.IsSystemDataType, expression => expression.MapFrom(definition => systemIds.Contains(definition.Id))); + config.CreateMap() .ForMember(display => display.AvailableEditors, expression => expression.ResolveUsing()) .ForMember(display => display.PreValues, expression => expression.ResolveUsing( diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 62e7bc58e4..264d90f36d 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -118,14 +118,17 @@ namespace Umbraco.Web.Models.Mapping /// /// /// This must be either 'content' or 'media' + /// internal static void AddListView(TabbedContentItem display, string entityType, IDataTypeService dataTypeService) where TPersisted : IContentBase { int dtdId; + var customDtdName = Constants.Conventions.DataTypes.ListViewPrefix + display.ContentTypeAlias; switch (entityType) { case "content": dtdId = Constants.System.DefaultContentListViewDataTypeId; + break; case "media": dtdId = Constants.System.DefaultMediaListViewDataTypeId; @@ -137,8 +140,11 @@ namespace Umbraco.Web.Models.Mapping throw new ArgumentOutOfRangeException("entityType does not match a required value"); } - var dt = dataTypeService.GetDataTypeDefinitionById(dtdId); - var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(dtdId); + //first try to get the custom one if there is one + var dt = dataTypeService.GetDataTypeDefinitionByName(customDtdName) + ?? dataTypeService.GetDataTypeDefinitionById(dtdId); + + var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(dt.Id); var editor = PropertyEditorResolver.Current.GetByAlias(dt.PropertyEditorAlias); if (editor == null) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c4a3f20a17..90f190a179 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -306,6 +306,7 @@ + @@ -320,7 +321,6 @@ - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 008e836f8a..928335cf13 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -49,6 +49,15 @@ namespace umbraco.controls public bool HideStructure { get; set; } public Func DocumentTypeCallback { get; set; } + protected string ContentTypeAlias + { + get { return _contentType.Alias; } + } + protected int ContentTypeId + { + get { return _contentType.Id; } + } + // "Tab" tab protected uicontrols.Pane Pane8;