diff --git a/src/Umbraco.Core/Constants-Conventions.cs b/src/Umbraco.Core/Constants-Conventions.cs index 9c069c4c2f..b22f6e2ef3 100644 --- a/src/Umbraco.Core/Constants-Conventions.cs +++ b/src/Umbraco.Core/Constants-Conventions.cs @@ -11,6 +11,16 @@ namespace Umbraco.Core /// public static class Conventions { + public static class PropertyTypes + { + public const string ListViewPropertyAlias = Constants.PropertyEditors.InternalGenericPropertiesPrefix + "containerView"; + } + + public static class PropertyGroups + { + public const string ListViewGroupName = "umbContainerView"; + } + /// /// Constants for Umbraco Content property aliases. /// diff --git a/src/Umbraco.Core/Models/MemberType.cs b/src/Umbraco.Core/Models/MemberType.cs index 527e379d17..6620843ab5 100644 --- a/src/Umbraco.Core/Models/MemberType.cs +++ b/src/Umbraco.Core/Models/MemberType.cs @@ -42,6 +42,10 @@ namespace Umbraco.Core.Models // leading underscores which we don't want in this case. // see : http://issues.umbraco.org/issue/U4-3968 + //TODO: BUT, I'm pretty sure we could do this with regards to underscores now: + // .ToCleanString(CleanStringType.Alias | CleanStringType.UmbracoCase) + // Need to ask Stephen + SetPropertyValueAndDetectChanges(o => { _alias = value == "_umbracoSystemDefaultProtectType" diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs index 28a34f0e5e..fb7e82b27e 100644 --- a/src/Umbraco.Core/Models/PropertyType.cs +++ b/src/Umbraco.Core/Models/PropertyType.cs @@ -95,9 +95,15 @@ namespace Umbraco.Core.Models get { return _alias; } set { + //NOTE: WE are doing this because we don't want to do a ToSafeAlias when the alias is the special case of + // being prefixed with Constants.PropertyEditors.InternalGenericPropertiesPrefix + // which is used internally + SetPropertyValueAndDetectChanges(o => { - _alias = value.ToCleanString(CleanStringType.Alias | CleanStringType.UmbracoCase); + _alias = value.StartsWith(Constants.PropertyEditors.InternalGenericPropertiesPrefix) + ? value + : value.ToCleanString(CleanStringType.Alias | CleanStringType.UmbracoCase); return _alias; }, _alias, AliasSelector); } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index ebf7fd1646..e3f6a2a7e5 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -663,7 +663,7 @@ namespace Umbraco.Core.Persistence.Repositories .AsQueryable(); // Now we need to ensure this result is also ordered by the same order by clause - var orderByProperty = GetIContentPropertyNameForOrderBy(orderBy); + var orderByProperty = GetEntityPropertyNameForOrderBy(orderBy); if (orderDirection == Direction.Ascending) { result = content.OrderBy(orderByProperty); @@ -685,28 +685,32 @@ namespace Umbraco.Core.Persistence.Repositories { // Translate the passed order by field (which were originally defined for in-memory object sorting // of ContentItemBasic instances) to the database field names. - switch (orderBy) + switch (orderBy.ToUpperInvariant()) { - case "Name": + case "NAME": return "cmsDocument.text"; - case "Owner": + case "OWNER": + //TODO: This isn't going to work very nicely because it's going to order by ID, not by letter return "umbracoNode.nodeUser"; - case "Updater": + case "UPDATER": + //TODO: This isn't going to work very nicely because it's going to order by ID, not by letter return "cmsDocument.documentUser"; default: return orderBy; } } - private string GetIContentPropertyNameForOrderBy(string orderBy) + private string GetEntityPropertyNameForOrderBy(string orderBy) { // Translate the passed order by field (which were originally defined for in-memory object sorting // of ContentItemBasic instances) to the IContent property names. - switch (orderBy) + switch (orderBy.ToUpperInvariant()) { - case "Owner": + case "OWNER": + //TODO: This isn't going to work very nicely because it's going to order by ID, not by letter return "CreatorId"; - case "Updater": + case "UPDATER": + //TODO: This isn't going to work very nicely because it's going to order by ID, not by letter return "WriterId"; default: return orderBy; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js index 8b5ad33082..d2dea98f2d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js @@ -10,7 +10,7 @@ function includePropsPreValsController($rootScope, $scope, localizationService, { value: "updateDate", name: "Last edited" }, { value: "updater", name: "Updated by" }, { value: "createDate", name: "Created" }, - { value: "creator", name: "Created by" } + { value: "owner", name: "Created by" } ]; $scope.getLocalizedKey = function(alias) { @@ -21,7 +21,7 @@ function includePropsPreValsController($rootScope, $scope, localizationService, return "content_updatedBy"; case "createDate": return "content_createDate"; - case "creator": + case "owner": return "content_createBy"; } return alias; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index 84117c5b23..4267f30a9e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -28,7 +28,7 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific totalPages: 0, items: [] }; - + $scope.options = { pageSize: $scope.model.config.pageSize ? $scope.model.config.pageSize : 10, pageNumber: 1, @@ -56,34 +56,6 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific } }); - //// Retrieve the container configuration for the content type and set options before presenting initial view - //contentTypeResource.getContainerConfig($routeParams.id) - // .then(function(config) { - // if (typeof config.pageSize !== 'undefined') { - // $scope.options.pageSize = config.pageSize; - // } - // if (typeof config.additionalColumns !== 'undefined') { - // $scope.options.additionalColumns = config.additionalColumns; - // } - // if (typeof config.orderBy !== 'undefined') { - // $scope.options.orderBy = config.orderBy; - // } - // if (typeof config.orderDirection !== 'undefined') { - // $scope.options.orderDirection = config.orderDirection; - // } - // if (typeof config.allowBulkPublish !== 'undefined') { - // $scope.options.allowBulkPublish = config.allowBulkPublish; - // } - // if (typeof config.allowBulkUnpublish !== 'undefined') { - // $scope.options.allowBulkUnpublish = config.allowBulkUnpublish; - // } - // if (typeof config.allowBulkDelete !== 'undefined') { - // $scope.options.allowBulkDelete = config.allowBulkDelete; - // } - - // $scope.initView(); - // }); - $scope.next = function() { if ($scope.options.pageNumber < $scope.listViewResultSet.totalPages) { $scope.options.pageNumber++; @@ -313,18 +285,6 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific } }; - $scope.includeProperties = $scope.model.config.includeProperties ? _.map($scope.model.config.includeProperties, function(i) { - if (!i.label) - i.label = i.value.replace(/([A-Z]?[a-z]+)/g, '$1 ').trim(' '); - if (typeof (i.isProperty) == "undefined") - i.isProperty = !i.value.match("contentTypeAlias|createDate|icon|owner|published|sortOrder|updateDate|updater"); - if (!i.isProperty && !i.sortBy) - i.sortBy = i.value.substring(0, 1).toUpperCase() + i.value.slice(1); - // TODO: Add sort logic for custom properties. - //else if (!i.sortBy) - // ; - return i; - }) : {}; /** This ensures that the correct value is set for each item in a row, we don't want to call a function during interpolation or ng-bind as performance is really bad that way */ function setPropertyValues(result) { @@ -400,7 +360,7 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific return "content_updatedBy"; case "createDate": return "content_createDate"; - case "creator": + case "owner": return "content_createBy"; } return alias; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html index d80a587aca..99818bae63 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html @@ -61,13 +61,6 @@ - -
diff --git a/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx b/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx index 69bcecff66..9ec9bbaca7 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/GenericProperties/GenericProperty.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="GenericProperty.ascx.cs" Inherits="umbraco.controls.GenericProperties.GenericProperty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> +<%@ Control Language="c#" AutoEventWireup="True" Inherits="umbraco.controls.GenericProperties.GenericProperty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
  • @@ -39,7 +39,6 @@ - diff --git a/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx b/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx index 324f8fb0fa..80b8313be3 100644 --- a/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx +++ b/src/Umbraco.Web.UI/umbraco/members/EditMemberType.aspx @@ -1,4 +1,4 @@ -<%@ Page Async="true" language="c#" MasterPageFile="../masterpages/umbracoPage.Master" Codebehind="EditMemberType.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.members.EditMemberType" %> +<%@ Page Async="true" language="c#" MasterPageFile="../masterpages/umbracoPage.Master" AutoEventWireup="True" Inherits="umbraco.cms.presentation.members.EditMemberType" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> <%@ Register TagPrefix="uc1" TagName="ContentTypeControlNew" Src="../controls/ContentTypeControlNew.ascx" %> <%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %> diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 3ff6c18854..265e4a6a86 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -127,7 +127,7 @@ namespace Umbraco.Web.Models.Mapping if (content.ContentType.IsContainer) { - TabsAndPropertiesResolver.AddContainerView(display, "content"); + TabsAndPropertiesResolver.AddListView(display, "content"); } TabsAndPropertiesResolver.MapGenericProperties( diff --git a/src/Umbraco.Web/Models/Mapping/MediaModelMapper.cs b/src/Umbraco.Web/Models/Mapping/MediaModelMapper.cs index 7ef6d92b22..aa548bc067 100644 --- a/src/Umbraco.Web/Models/Mapping/MediaModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/MediaModelMapper.cs @@ -88,7 +88,7 @@ namespace Umbraco.Web.Models.Mapping if (media.ContentType.IsContainer) { - TabsAndPropertiesResolver.AddContainerView(display, "media"); + TabsAndPropertiesResolver.AddListView(display, "media"); } TabsAndPropertiesResolver.MapGenericProperties(media, display); diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 41153be8b8..cd58485a19 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -4,6 +4,7 @@ using System.Linq; using AutoMapper; using Umbraco.Core; using Umbraco.Core.Dictionary; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Web.Models.ContentEditing; @@ -40,7 +41,7 @@ namespace Umbraco.Web.Models.Mapping /// /// /// The generic properties tab is mapped during AfterMap and is responsible for - /// setting up the properties such as Created date, udpated date, template selected, etc... + /// setting up the properties such as Created date, updated date, template selected, etc... /// public static void MapGenericProperties( TPersisted content, @@ -116,35 +117,62 @@ namespace Umbraco.Web.Models.Mapping /// /// /// This must be either 'content' or 'media' - internal static void AddContainerView(TabbedContentItem display, string entityType) + internal static void AddListView(TabbedContentItem display, string entityType) where TPersisted : IContentBase { - var listViewTab = new Tab(); - listViewTab.Alias = "umbContainerView"; - listViewTab.Label = ui.Text("content", "childItems"); - listViewTab.Id = 25; - listViewTab.IsActive = true; - var listViewProperties = new List(); - listViewProperties.Add(new ContentPropertyDisplay + var listViewProp = display.Properties.FirstOrDefault(x => x.Alias == Constants.Conventions.PropertyTypes.ListViewPropertyAlias); + + //check if the list view property is already there (it should be with 7.2+) + if (listViewProp != null) { - Alias = string.Format("{0}containerView", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = "", - Value = null, - View = "listview", - HideLabel = true, - Config = new Dictionary + //ensure label is hidden + listViewProp.HideLabel = true; + listViewProp.Value = null; + listViewProp.Label = ""; + + var defaultViewTab = display.Tabs.FirstOrDefault(x => x.Alias == Constants.Conventions.PropertyGroups.ListViewGroupName); + if (defaultViewTab != null) + { + //it's the default one, so localize the name + defaultViewTab.Label = ui.Text("content", "childItems"); + } + } + else + { + //something is a bit strange with the data, there should def be a list view property but seeing as there is not, we'll put a warning + // in the log and create one dynamically like we did pre 7.2 + + LogHelper.Warn("No list view property type was found on the content item, a dynamic one will be created. Since 7.2.0 there should be a real list view property type on a list view content type"); + + var listViewTab = new Tab(); + listViewTab.Alias = Constants.Conventions.PropertyGroups.ListViewGroupName; + listViewTab.Label = ui.Text("content", "childItems"); + listViewTab.Id = 25; + listViewTab.IsActive = true; + + var listViewProperties = new List(); + listViewProperties.Add(new ContentPropertyDisplay + { + Alias = Constants.Conventions.PropertyTypes.ListViewPropertyAlias, + Label = "", + Value = null, + View = "listview", + HideLabel = true, + Config = new Dictionary { {"entityType", entityType} } - }); - listViewTab.Properties = listViewProperties; + }); + listViewTab.Properties = listViewProperties; + + //Is there a better way? + var tabs = new List>(); + tabs.Add(listViewTab); + tabs.AddRange(display.Tabs); + display.Tabs = tabs; + } - //Is there a better way? - var tabs = new List>(); - tabs.Add(listViewTab); - tabs.AddRange(display.Tabs); - display.Tabs = tabs; } protected override IEnumerable> ResolveCore(IContentBase content) diff --git a/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs index b08f808f3c..e3423188f0 100644 --- a/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs +++ b/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Rdbms; @@ -11,10 +13,11 @@ using umbraco.interfaces; namespace Umbraco.Web.Strategies.Migrations { /// - /// Once the migration runner is run, this will ensure that the built in system list view data type exists if the + /// Once the migration runner is run, this will ensure that the content types that are flagged as list views, + /// have the special readonly list view property type on the readonly tab. This will ensure that the built in system list view data type exists if the /// current version is less than 7.2 (because previous to 7.2 we didn't ship with the system created list view data type) /// - public class EnsureListViewDataTypeIsCreated : ApplicationEventHandler + public class EnsureAllListViewContentTypesHaveListViewPropertyType : ApplicationEventHandler { /// /// Ensure this is run when not configured @@ -48,56 +51,100 @@ namespace Umbraco.Web.Strategies.Migrations if (e.ConfiguredVersion <= target720) { - var exists = e.MigrationContext.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoNode WHERE id=1037"); - if (exists > 0) return; + EnsureListViewDataTypeCreated(e); - using (var transaction = e.MigrationContext.Database.GetTransaction()) - { - //Turn on identity insert if db provider is not mysql - if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) - e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode")))); + var services = ApplicationContext.Current.Services; - e.MigrationContext.Database - .Insert("umbracoNode", "id", false, new NodeDto - { - NodeId = 1037, - Trashed = false, - ParentId = -1, - UserId = 0, - Level = 1, - Path = "-1,1037", - SortOrder = 2, - UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), - Text = "List View", - NodeObjectType = new Guid(Constants.ObjectTypes.DataType), - CreateDate = DateTime.Now - }); + var contentTypes = services.ContentTypeService.GetAllContentTypes().Where(x => x.IsContainer); + services.ContentTypeService.Save(AddListView(contentTypes)); - //Turn off identity insert if db provider is not mysql - if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) - e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode")))); - - //Turn on identity insert if db provider is not mysql - if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) - e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType")))); - - e.MigrationContext.Database - .Insert("cmsDataType", "pk", false, new DataTypeDto - { - PrimaryKey = 19, - DataTypeId = 1037, - PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, - DbType = "Nvarchar" - }); - - //Turn off identity insert if db provider is not mysql - if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) - e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType")))); - - transaction.Complete(); - } + var mediaTypes = services.ContentTypeService.GetAllMediaTypes().Where(x => x.IsContainer); + services.ContentTypeService.Save(AddListView(mediaTypes)); + var memberTypes = services.MemberTypeService.GetAll().Where(x => x.IsContainer); + services.MemberTypeService.Save(AddListView(memberTypes)); } } + + private void EnsureListViewDataTypeCreated(Core.Events.MigrationEventArgs e) + { + var exists = e.MigrationContext.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoNode WHERE id=1037"); + if (exists > 0) return; + + using (var transaction = e.MigrationContext.Database.GetTransaction()) + { + //Turn on identity insert if db provider is not mysql + if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) + e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode")))); + + e.MigrationContext.Database + .Insert("umbracoNode", "id", false, new NodeDto + { + NodeId = 1037, + Trashed = false, + ParentId = -1, + UserId = 0, + Level = 1, + Path = "-1,1037", + SortOrder = 2, + UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), + Text = "List View", + NodeObjectType = new Guid(Constants.ObjectTypes.DataType), + CreateDate = DateTime.Now + }); + + //Turn off identity insert if db provider is not mysql + if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) + e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode")))); + + //Turn on identity insert if db provider is not mysql + if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) + e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType")))); + + e.MigrationContext.Database + .Insert("cmsDataType", "pk", false, new DataTypeDto + { + PrimaryKey = 19, + DataTypeId = 1037, + PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, + DbType = "Nvarchar" + }); + + //Turn off identity insert if db provider is not mysql + if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert()) + e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType")))); + + transaction.Complete(); + } + } + + private static List AddListView(IEnumerable contentTypes) + where T: IContentTypeBase + { + var toSave = new List(); + foreach (var contentType in contentTypes) + { + if (contentType.PropertyGroups.Contains(Constants.Conventions.PropertyGroups.ListViewGroupName) == false) + { + contentType.PropertyGroups.Add(new PropertyGroup + { + Name = Constants.Conventions.PropertyGroups.ListViewGroupName, + SortOrder = contentType.PropertyGroups.Any() ? contentType.PropertyGroups.Max(x => x.SortOrder) + 1 : 1, + PropertyTypes = new PropertyTypeCollection(new[] + { + new PropertyType(Constants.PropertyEditors.ListViewAlias, DataTypeDatabaseType.Nvarchar) + { + Alias = Constants.Conventions.PropertyTypes.ListViewPropertyAlias, + Name = Constants.Conventions.PropertyTypes.ListViewPropertyAlias, + DataTypeDefinitionId = 1037 + } + }) + }); + toSave.Add(contentType); + } + } + return toSave; + } } + } \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index bd4ad60d35..dc77af3ad8 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -505,6 +505,9 @@ + + ASPXCodeBehind + ASPXCodeBehind @@ -1146,13 +1149,6 @@ UploadMediaImage.ascx - - GenericProperty.ascx - ASPXCodeBehind - - - GenericProperty.ascx - @@ -1892,9 +1888,6 @@ ASPXCodeBehind - - ASPXCodeBehind - ASPXCodeBehind 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 15ef6a76e0..4cf0dfe02e 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -29,6 +29,7 @@ using umbraco.controls.GenericProperties; using Umbraco.Core.IO; using umbraco.presentation; using umbraco.BasePages; +using Constants = Umbraco.Core.Constants; using ContentType = umbraco.cms.businesslogic.ContentType; using PropertyType = Umbraco.Core.Models.PropertyType; @@ -743,7 +744,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); var propertyGroupId = tab.Id; var propSort = new HtmlInputHidden(); - propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content"; + propSort.ID = "propSort_" + propertyGroupId + "_Content"; PropertyTypes.Controls.Add(propSort); _sortLists.Add(propSort); @@ -756,12 +757,13 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); //If the PropertyType doesn't belong on this ContentType skip it and continue to the next one if (pt.ContentTypeId != _contentType.Id) continue; - var gpw = GetPropertyWrapperForPropertyType(pt); + cms.businesslogic.datatype.DataTypeDefinition[] filteredDtds; + var gpw = GetPropertyWrapperForPropertyType(pt, dtds, out filteredDtds); gpw.ID = "gpw_" + pt.Id; gpw.PropertyType = pt; gpw.Tabs = tabs; gpw.TabId = propertyGroupId; - gpw.DataTypeDefinitions = dtds; + gpw.DataTypeDefinitions = filteredDtds; gpw.Delete += gpw_Delete; gpw.FullId = "t_" + propertyGroupId + "_Contents_" + +pt.Id; @@ -808,7 +810,8 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO //if (pt.ContentTypeId == _contentType.Id && pt.TabId == 0) { - var gpw = GetPropertyWrapperForPropertyType(pt); + cms.businesslogic.datatype.DataTypeDefinition[] filteredDtds; + var gpw = GetPropertyWrapperForPropertyType(pt, dtds, out filteredDtds); // Changed by duckie, was: // gpw.ID = "gpw_" + editPropertyType.Alias; @@ -817,7 +820,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); gpw.PropertyType = pt; gpw.Tabs = tabs; - gpw.DataTypeDefinitions = dtds; + gpw.DataTypeDefinitions = filteredDtds; gpw.Delete += new EventHandler(gpw_Delete); gpw.FullId = "t_general_Contents_" + pt.Id; @@ -857,8 +860,25 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); /// allowed to be editable. /// /// - private GenericPropertyWrapper GetPropertyWrapperForPropertyType(cms.businesslogic.propertytype.PropertyType pt) + private GenericPropertyWrapper GetPropertyWrapperForPropertyType( + cms.businesslogic.propertytype.PropertyType pt, + cms.businesslogic.datatype.DataTypeDefinition[] allDtds, + out cms.businesslogic.datatype.DataTypeDefinition[] filteredDefinitions) { + filteredDefinitions = allDtds; + + //special case if this is a list view, if so, filter the dtd's to only include other list view types, + // don't allow editing of anything except for the tab and data type + if (pt.Alias == Constants.Conventions.PropertyTypes.ListViewPropertyAlias) + { + //filter the dtds to only list view + filteredDefinitions = allDtds.Where(x => x.PropertyEditorAlias == Constants.PropertyEditors.ListViewAlias).ToArray(); + + var gpw = new GenericPropertyWrapper(false, true, false, true, false, false, false); + return gpw; + } + + //not editable if any of the built in member types if (_contentType.ContentTypeItem is IMemberType) { var builtInAliases = global::Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray(); @@ -866,6 +886,14 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); return gpw; } + //not editable if prefixed with the special internal prefix + if (pt.Alias.StartsWith(Constants.PropertyEditors.InternalGenericPropertiesPrefix)) + { + var gpw = new GenericPropertyWrapper(false); + return gpw; + } + + //the rest are editable return new GenericPropertyWrapper(); } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx deleted file mode 100644 index aa7571db52..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx +++ /dev/null @@ -1,67 +0,0 @@ -<%@ Control Language="c#" AutoEventWireup="True" Codebehind="GenericProperty.ascx.cs" Inherits="umbraco.controls.GenericProperties.GenericProperty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> - -
  • -
    -
    -
    - - - - - - - - - - - -
    -
    - - -
    -
  • \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs index 7ec152f5db..bffdb8b475 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs @@ -1,31 +1,27 @@ using System; +using System.Globalization; +using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; using System.Web.UI.WebControls; using ClientDependency.Core; -using umbraco.cms.businesslogic; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; using umbraco.BasePages; using umbraco.BusinessLogic; +using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.propertytype; +using Umbraco.Core; +using Umbraco.Core.Configuration; namespace umbraco.controls.GenericProperties { - - - /// - /// Summary description for GenericProperty. - /// - [ClientDependency(ClientDependencyType.Css, "GenericProperty/genericproperty.css", "UmbracoClient")] + /// + /// Summary description for GenericProperty. + /// + [ClientDependency(ClientDependencyType.Css, "GenericProperty/genericproperty.css", "UmbracoClient")] [ClientDependency(ClientDependencyType.Javascript, "GenericProperty/genericproperty.js", "UmbracoClient")] public partial class GenericProperty : System.Web.UI.UserControl - { + { /// /// Constructor @@ -36,86 +32,102 @@ namespace umbraco.controls.GenericProperties AllowPropertyEdit = true; } - private cms.businesslogic.datatype.DataTypeDefinition[] _dataTypeDefinitions; - private int _tabId = 0; + private cms.businesslogic.datatype.DataTypeDefinition[] _dataTypeDefinitions; + private int _tabId = 0; - public event EventHandler Delete; + public event EventHandler Delete; /// /// Defines whether the property can be edited in the UI /// - public bool AllowPropertyEdit { get; set; } + [Obsolete("Use the combination of AllowAliasEdit,AllowValidationEdit,AllowDelete,AllowDataTypeEdit instead")] + public bool AllowPropertyEdit + { + get { return AllowAliasEdit && AllowValidationEdit && AllowDelete && AllowDataTypeEdit; } + set { AllowAliasEdit = AllowValidationEdit = AllowDelete = AllowDataTypeEdit = true; } + } - public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions - { - set { _dataTypeDefinitions = value; } - } + /// + /// Defines whether the property's name can be edited in the UI + /// + public bool AllowNameEdit { get; set; } + public bool AllowAliasEdit { get; set; } + public bool AllowDataTypeEdit { get; set; } + public bool AllowTabEdit { get; set; } + public bool AllowValidationEdit { get; set; } + public bool AllowDescriptionEdit { get; set; } + public bool AllowDelete { get; set; } - public int TabId - { - set { _tabId = value; } - } + public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions + { + set { _dataTypeDefinitions = value; } + } - public PropertyType PropertyType { get; set; } + public int TabId + { + set { _tabId = value; } + } - public ContentType.TabI[] Tabs { get; set; } + public PropertyType PropertyType { get; set; } - public string Name - { - get { return tbName.Text; } - } + public ContentType.TabI[] Tabs { get; set; } - public string Alias - { - get {return tbAlias.Text;} // FIXME so we blindly trust the UI for safe aliases?! - } + public string Name + { + get { return tbName.Text; } + } - public string Description - { - get {return tbDescription.Text;} - } - public string Validation - { - get {return tbValidation.Text;} - } - public bool Mandatory - { - get {return checkMandatory.Checked;} - } - public int Tab - { - get {return int.Parse(ddlTab.SelectedValue);} - } + public string Alias + { + get { return tbAlias.Text; } // FIXME so we blindly trust the UI for safe aliases?! + } - public string FullId { get; set; } + public string Description + { + get { return tbDescription.Text; } + } + public string Validation + { + get { return tbValidation.Text; } + } + public bool Mandatory + { + get { return checkMandatory.Checked; } + } + public int Tab + { + get { return int.Parse(ddlTab.SelectedValue); } + } - public int Id { get; set; } + public string FullId { get; set; } - public int Type - { - get {return int.Parse(ddlTypes.SelectedValue);} - } + public int Id { get; set; } - public void Clear() - { - tbName.Text = ""; - tbAlias.Text = ""; - tbValidation.Text = ""; - tbDescription.Text = ""; - ddlTab.SelectedIndex = 0; + public int Type + { + get { return int.Parse(ddlTypes.SelectedValue); } + } + + public void Clear() + { + tbName.Text = ""; + tbAlias.Text = ""; + tbValidation.Text = ""; + tbDescription.Text = ""; + ddlTab.SelectedIndex = 0; SetDefaultDocumentTypeProperty(); - checkMandatory.Checked = false; - } + checkMandatory.Checked = false; + } - protected void Page_Load(object sender, System.EventArgs e) - { - if (!IsPostBack) - { - UpdateInterface(); - } - } - - //SD: this is temporary in v4, in v6 we have a proper user control hierarchy + protected void Page_Load(object sender, System.EventArgs e) + { + if (!IsPostBack) + { + UpdateInterface(); + } + } + + //SD: this is temporary in v4, in v6 we have a proper user control hierarchy //containing this property. //this is required due to this issue: http://issues.umbraco.org/issue/u4-493 //because we need to execute some code in async but due to the localization @@ -126,108 +138,117 @@ namespace umbraco.controls.GenericProperties //our calls to ui.text will include the current user and not rely on the //httpcontext.current. This also makes it perform better: // http://issues.umbraco.org/issue/U4-2142 - private User CurrentUser - { - get { return ((BasePage) Page).getUser(); } - } + private User CurrentUser + { + get { return ((BasePage)Page).getUser(); } + } - public void UpdateInterface() - { - // Name and alias - if (PropertyType != null) - { + public void UpdateInterface() + { + // Name and alias + if (PropertyType != null) + { Id = PropertyType.Id; - //form.Attributes.Add("style", "display: none;"); - tbName.Text = PropertyType.GetRawName(); - tbAlias.Text = PropertyType.Alias; - FullHeader.Text = PropertyType.GetRawName() + " (" + PropertyType.Alias + "), Type: " + PropertyType.DataTypeDefinition.Text;; - Header.Text = PropertyType.GetRawName(); - + //form.Attributes.Add("style", "display: none;"); + tbName.Text = PropertyType.GetRawName(); + tbAlias.Text = PropertyType.Alias; + FullHeader.Text = PropertyType.GetRawName() + " (" + PropertyType.Alias + "), Type: " + PropertyType.DataTypeDefinition.Text; ; + Header.Text = PropertyType.GetRawName(); + DeleteButton.CssClass = "delete-button"; DeleteButton.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');"); - + DeleteButton2.CssClass = "delete-button"; DeleteButton2.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');"); - DeleteButton.Visible = AllowPropertyEdit; - DeleteButton2.Visible = AllowPropertyEdit; - tbAlias.Visible = AllowPropertyEdit; - PropertyPanel5.Visible = AllowPropertyEdit; - PropertyPanel6.Visible = AllowPropertyEdit; - PropertyPanel3.Visible = AllowPropertyEdit; - } - else - { - // Add new header - FullHeader.Text = "Click here to add a new property"; - Header.Text = "Create new property"; + DeleteButton.Visible = AllowDelete; + DeleteButton2.Visible = AllowDelete; - // Hide image button - DeleteButton.Visible = false; - DeleteButton2.Visible = false; - } + //alias visibility + PropertyPanel2.Visible = AllowAliasEdit; + //chk mandatory visibility + PropertyPanel5.Visible = AllowValidationEdit; + // validation visibility + PropertyPanel6.Visible = AllowValidationEdit; + // drop down data types visibility + PropertyPanel3.Visible = AllowDataTypeEdit; + // name visibility + PropertyPanel1.Visible = AllowNameEdit; + // desc visibility + PropertyPanel7.Visible = AllowDescriptionEdit; + } + else + { + // Add new header + FullHeader.Text = "Click here to add a new property"; + Header.Text = "Create new property"; + + // Hide image button + DeleteButton.Visible = false; + DeleteButton2.Visible = false; + } validationLink.NavigateUrl = "#"; validationLink.Attributes["onclick"] = ClientTools.Scripts.OpenModalWindow("dialogs/regexWs.aspx?target=" + tbValidation.ClientID, "Search for regular expression", 600, 500) + ";return false;"; - // Data type definitions - if (_dataTypeDefinitions != null) - { - ddlTypes.Items.Clear(); + // Data type definitions + if (_dataTypeDefinitions != null) + { + ddlTypes.Items.Clear(); var itemSelected = false; - foreach(cms.businesslogic.datatype.DataTypeDefinition dt in _dataTypeDefinitions) - { - var li = new ListItem(dt.Text, dt.Id.ToString()); + foreach (cms.businesslogic.datatype.DataTypeDefinition dt in _dataTypeDefinitions) + { + var li = new ListItem(dt.Text, dt.Id.ToString(CultureInfo.InvariantCulture)); if ((PropertyType != null && PropertyType.DataTypeDefinition.Id == dt.Id)) { li.Selected = true; itemSelected = true; } - ddlTypes.Items.Add(li); - } + ddlTypes.Items.Add(li); + } // If item not selected from previous edit or load, set to default according to settings if (!itemSelected) { SetDefaultDocumentTypeProperty(); } - } + } - // tabs - if (Tabs != null) - { - ddlTab.Items.Clear(); - for (int i=0;i() .FirstOrDefault(item => item.Text.ToLowerInvariant() == UmbracoConfig.For.UmbracoSettings().Content.DefaultDocumentTypeProperty.ToLowerInvariant()); - + if (itemToSelect != null) { itemToSelect.Selected = true; @@ -238,34 +259,198 @@ namespace umbraco.controls.GenericProperties } } - protected void defaultDeleteHandler(object sender, EventArgs e) - { - - } - - override protected void OnInit(EventArgs e) - { + protected void defaultDeleteHandler(object sender, EventArgs e) + { + + } + + override protected void OnInit(EventArgs e) + { base.OnInit(e); DeleteButton.Click += DeleteButton_Click; DeleteButton2.Click += DeleteButton2_Click; - Delete += defaultDeleteHandler; + Delete += defaultDeleteHandler; // [ClientDependency(ClientDependencyType.Javascript, "js/UmbracoCasingRules.aspx", "UmbracoRoot")] - var loader = ClientDependency.Core.Controls.ClientDependencyLoader.GetInstance(new HttpContextWrapper(Context)); - var helper = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())); + var loader = ClientDependency.Core.Controls.ClientDependencyLoader.GetInstance(new HttpContextWrapper(Context)); + var helper = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())); loader.RegisterDependency(helper.GetCoreStringsControllerPath() + "ServicesJavaScript", ClientDependencyType.Javascript); - } - + } + void DeleteButton2_Click(object sender, EventArgs e) { - Delete(this,new EventArgs()); + Delete(this, new EventArgs()); } void DeleteButton_Click(object sender, EventArgs e) { - Delete(this,new EventArgs()); + Delete(this, new EventArgs()); } - } -} + /// + /// DeleteButton2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton DeleteButton2; + + /// + /// FullHeader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal FullHeader; + + /// + /// DeleteButton control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton DeleteButton; + + /// + /// Header control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal Header; + + /// + /// tbName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox tbName; + + /// + /// PropertyPanel1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel1; + + /// + /// tbAlias control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox tbAlias; + + /// + /// PropertyPanel2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel2; + + /// + /// ddlTypes control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlTypes; + + /// + /// PropertyPanel3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel3; + + /// + /// ddlTab control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlTab; + + /// + /// PropertyPanel4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel4; + + /// + /// checkMandatory control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox checkMandatory; + + /// + /// PropertyPanel5 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel5; + + /// + /// tbValidation control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox tbValidation; + + /// + /// validationLink control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HyperLink validationLink; + + /// + /// PropertyPanel6 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel6; + + /// + /// tbDescription control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox tbDescription; + + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel7; + + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs deleted file mode 100644 index 8c7a0b01b7..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs +++ /dev/null @@ -1,177 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.controls.GenericProperties { - - - public partial class GenericProperty { - - /// - /// DeleteButton2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton DeleteButton2; - - /// - /// FullHeader control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal FullHeader; - - /// - /// DeleteButton control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.LinkButton DeleteButton; - - /// - /// Header control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal Header; - - /// - /// tbName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbName; - - /// - /// PropertyPanel1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel1; - - /// - /// tbAlias control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbAlias; - - /// - /// PropertyPanel2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel2; - - /// - /// ddlTypes control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList ddlTypes; - - /// - /// PropertyPanel3 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel3; - - /// - /// ddlTab control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList ddlTab; - - /// - /// PropertyPanel4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel4; - - /// - /// checkMandatory control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox checkMandatory; - - /// - /// PropertyPanel5 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel5; - - /// - /// tbValidation control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbValidation; - - /// - /// validationLink control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.HyperLink validationLink; - - /// - /// PropertyPanel6 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel PropertyPanel6; - - /// - /// tbDescription control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox tbDescription; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs index 88db25829d..b76bfe452f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/GenericProperties/GenericPropertyWrapper.cs @@ -10,7 +10,13 @@ namespace umbraco.controls.GenericProperties /// public class GenericPropertyWrapper : System.Web.UI.WebControls.PlaceHolder { - private readonly bool _allowModification; + private readonly bool _allowNameEdit = true; + private readonly bool _allowDataTypeEdit = true; + private readonly bool _allowAliasEdit = true; + private readonly bool _allowTabEdit = true; + private readonly bool _allowValidationEdit = true; + private readonly bool _allowDescEdit = true; + private readonly bool _allowDelete = true; private GenericProperty _gp; private cms.businesslogic.ContentType.TabI[] _tabs; @@ -55,7 +61,24 @@ namespace umbraco.controls.GenericProperties public GenericPropertyWrapper(bool allowModification) { - _allowModification = allowModification; + if (allowModification == false) + { + _allowAliasEdit = false; + _allowValidationEdit = false; + _allowDelete = false; + _allowDataTypeEdit = false; + } + } + + public GenericPropertyWrapper(bool allowNameEdit, bool allowDataTypeEdit, bool allowAliasEdit, bool allowTabEdit, bool allowValidationEdit, bool allowDescEdit, bool allowDelete) + { + _allowNameEdit = allowNameEdit; + _allowDataTypeEdit = allowDataTypeEdit; + _allowAliasEdit = allowAliasEdit; + _allowTabEdit = allowTabEdit; + _allowValidationEdit = allowValidationEdit; + _allowDescEdit = allowDescEdit; + _allowDelete = allowDelete; } public void UpdateEditControl() @@ -82,11 +105,18 @@ namespace umbraco.controls.GenericProperties { base.OnInit(e); var u = (GenericProperty)Page.LoadControl(SystemDirectories.Umbraco + "/controls/genericProperties/GenericProperty.ascx"); - u.AllowPropertyEdit = _allowModification; + + u.AllowAliasEdit = _allowAliasEdit; + u.AllowDataTypeEdit = _allowDataTypeEdit; + u.AllowDelete = _allowDelete; + u.AllowDescriptionEdit = _allowDescEdit; + u.AllowNameEdit = _allowNameEdit; + u.AllowTabEdit = _allowTabEdit; + u.AllowValidationEdit = _allowValidationEdit; u.ID = ID + "_control"; - if (_allowModification) + if (_allowDelete) { u.Delete += GenericPropertyWrapper_Delete; } diff --git a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs index 4e0a48ad93..821a50342a 100644 --- a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs +++ b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs @@ -31,7 +31,8 @@ namespace umbraco.cms.businesslogic.datatype public class DataTypeDefinition : CMSNode { #region Private fields - private string _propertyEditorAlias; + + internal string PropertyEditorAlias { get; private set; } private static readonly Guid ObjectType = new Guid(Constants.ObjectTypes.DataType); private string _text1; @@ -69,7 +70,7 @@ namespace umbraco.cms.businesslogic.datatype { get { - if (_propertyEditorAlias.IsNullOrWhiteSpace()) + if (PropertyEditorAlias.IsNullOrWhiteSpace()) return null; //Attempt to resolve a legacy control id from the alias. If one is not found we'll generate one - @@ -78,7 +79,7 @@ namespace umbraco.cms.businesslogic.datatype //So, we'll generate an id for it based on the alias which will remain consistent, but then we'll try to resolve a legacy // IDataType which of course will not exist. In this case we'll have to create a new one on the fly for backwards compatibility but // this instance will have limited capabilities and will really only work for saving data so the legacy APIs continue to work. - var controlId = LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(_propertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.GenerateId); + var controlId = LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(PropertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.GenerateId); var dt = DataTypesResolver.Current.GetById(controlId.Value); @@ -90,7 +91,7 @@ namespace umbraco.cms.businesslogic.datatype { //Ok so it was not found, we can only assume that this is because this is a new property editor that does not have a legacy predecessor. //we'll have to attempt to generate one at runtime. - dt = BackwardsCompatibleDataType.Create(_propertyEditorAlias, controlId.Value, Id); + dt = BackwardsCompatibleDataType.Create(PropertyEditorAlias, controlId.Value, Id); } @@ -110,7 +111,7 @@ namespace umbraco.cms.businesslogic.datatype - _propertyEditorAlias = alias; + PropertyEditorAlias = alias; } } @@ -375,7 +376,7 @@ WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("te { if (dr.Read()) { - _propertyEditorAlias = dr.GetString("propertyEditorAlias"); + PropertyEditorAlias = dr.GetString("propertyEditorAlias"); DbType = dr.GetString("dbType"); } else diff --git a/src/umbraco.controls/Property.cs b/src/umbraco.controls/PropertyPanel.cs similarity index 82% rename from src/umbraco.controls/Property.cs rename to src/umbraco.controls/PropertyPanel.cs index 1877a71997..a06a9818e7 100644 --- a/src/umbraco.controls/Property.cs +++ b/src/umbraco.controls/PropertyPanel.cs @@ -1,69 +1,69 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Web.UI; - -namespace umbraco.uicontrols -{ - public class PropertyPanel : System.Web.UI.WebControls.Panel - { - public PropertyPanel() - { - - } - - private string m_Text = string.Empty; - public string Text - { - get { return m_Text; } - set { m_Text = value; } - } - - protected override void OnLoad(System.EventArgs EventArguments) - { - } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - this.ViewStateMode = ViewStateMode.Disabled; - this.CreateChildControls(); - string styleString = ""; - - foreach (string key in this.Style.Keys) - { - styleString += key + ":" + this.Style[key] + ";"; - } - - var inGroup = this.Parent.GetType() == typeof(PropertyGroup); - - if (string.IsNullOrEmpty(m_Text)) - CssClass += " hidelabel"; - - - writer.WriteLine("
    "); - - - if (m_Text != string.Empty) - { - writer.WriteLine(""); - } - - writer.WriteLine("
    "); - - try - { - this.RenderChildren(writer); - } - catch (Exception ex) - { - writer.WriteLine("Error creating control
    "); - writer.WriteLine(ex.ToString()); - } - - writer.WriteLine("
    "); - - } - - } - +using System; +using System.Collections.Generic; +using System.Text; +using System.Web.UI; + +namespace umbraco.uicontrols +{ + public class PropertyPanel : System.Web.UI.WebControls.Panel + { + public PropertyPanel() + { + + } + + private string _text = string.Empty; + public string Text + { + get { return _text; } + set { _text = value; } + } + + protected override void OnLoad(System.EventArgs EventArguments) + { + } + + protected override void Render(System.Web.UI.HtmlTextWriter writer) + { + this.ViewStateMode = ViewStateMode.Disabled; + this.CreateChildControls(); + string styleString = ""; + + foreach (string key in this.Style.Keys) + { + styleString += key + ":" + this.Style[key] + ";"; + } + + var inGroup = this.Parent.GetType() == typeof(PropertyGroup); + + if (string.IsNullOrEmpty(_text)) + CssClass += " hidelabel"; + + + writer.WriteLine("
    "); + + + if (_text != string.Empty) + { + writer.WriteLine(""); + } + + writer.WriteLine("
    "); + + try + { + this.RenderChildren(writer); + } + catch (Exception ex) + { + writer.WriteLine("Error creating control
    "); + writer.WriteLine(ex.ToString()); + } + + writer.WriteLine("
    "); + + } + + } + } \ No newline at end of file diff --git a/src/umbraco.controls/umbraco.controls.csproj b/src/umbraco.controls/umbraco.controls.csproj index d085fb6e42..cc1536a3d0 100644 --- a/src/umbraco.controls/umbraco.controls.csproj +++ b/src/umbraco.controls/umbraco.controls.csproj @@ -1,4 +1,4 @@ - + Debug @@ -115,7 +115,7 @@ - +