Fixes saving of RegEx in DocTypes.
Fixes loading and saving of properties on inherited tabs. Adjusts logic around the creation of tabs/property groups
This commit is contained in:
@@ -329,6 +329,14 @@ namespace Umbraco.Core.Models
|
||||
/// <returns>Returns <c>True</c> if a PropertyType with the passed in alias exists, otherwise <c>False</c></returns>
|
||||
public abstract bool PropertyTypeExists(string propertyTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
public abstract bool AddPropertyGroup(string groupName);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType to a specific PropertyGroup
|
||||
/// </summary>
|
||||
|
||||
@@ -125,6 +125,35 @@ namespace Umbraco.Core.Models
|
||||
return CompositionPropertyTypes.Any(x => x.Alias == propertyTypeAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
public override bool AddPropertyGroup(string groupName)
|
||||
{
|
||||
if (PropertyGroups.Any(x => x.Name == groupName))
|
||||
return false;
|
||||
|
||||
var propertyGroup = new PropertyGroup {Name = groupName, SortOrder = 0};
|
||||
|
||||
if (CompositionPropertyGroups.Any(x => x.Name == groupName))
|
||||
{
|
||||
var first = CompositionPropertyGroups.First(x => x.Name == groupName && x.ParentId.HasValue == false);
|
||||
propertyGroup.ParentId = first.Id;
|
||||
}
|
||||
|
||||
if (PropertyGroups.Any())
|
||||
{
|
||||
var last = PropertyGroups.Last();
|
||||
propertyGroup.SortOrder = last.SortOrder + 1;
|
||||
}
|
||||
|
||||
PropertyGroups.Add(propertyGroup);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyType to a specific PropertyGroup
|
||||
/// </summary>
|
||||
|
||||
@@ -91,5 +91,13 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="propertyType"><see cref="PropertyType"/> to add</param>
|
||||
/// <returns>Returns <c>True</c> if PropertyType was added, otherwise <c>False</c></returns>
|
||||
bool AddPropertyType(PropertyType propertyType);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a PropertyGroup.
|
||||
/// This method will also check if a group already exists with the same name and link it to the parent.
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the PropertyGroup to add</param>
|
||||
/// <returns>Returns <c>True</c> if a PropertyGroup with the passed in name was added, otherwise <c>False</c></returns>
|
||||
bool AddPropertyGroup(string groupName);
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
HelpText = typeDto.HelpText,
|
||||
Mandatory = typeDto.Mandatory,
|
||||
SortOrder = typeDto.SortOrder,
|
||||
ValidationRegExp = typeDto.ValidationRegExp,
|
||||
PropertyGroupId = groupDto.Id
|
||||
};
|
||||
|
||||
@@ -106,7 +107,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
HelpText = propertyType.HelpText,
|
||||
Mandatory = propertyType.Mandatory,
|
||||
Name = propertyType.Name,
|
||||
SortOrder = propertyType.SortOrder
|
||||
SortOrder = propertyType.SortOrder,
|
||||
ValidationRegExp = propertyType.ValidationRegExp
|
||||
};
|
||||
|
||||
if (tabId != default(int))
|
||||
|
||||
@@ -259,14 +259,6 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
: Convert.ToInt32(Database.Insert(tabDto));
|
||||
if (propertyGroup.HasIdentity == false)
|
||||
propertyGroup.Id = groupPrimaryKey; //Set Id on new PropertyGroup
|
||||
|
||||
//Ensure that the PropertyGroup's Id is set on the PropertyTypes within a group
|
||||
//unless the PropertyGroupId has already been changed.
|
||||
foreach (var propertyType in propertyGroup.PropertyTypes)
|
||||
{
|
||||
if ((propertyType.IsPropertyDirty("PropertyGroupId") && propertyType.PropertyGroupId == 0) == false)
|
||||
propertyType.PropertyGroupId = propertyGroup.Id;
|
||||
}
|
||||
}
|
||||
|
||||
//Run through all PropertyTypes to insert or update entries
|
||||
@@ -337,7 +329,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Name = dto.Name,
|
||||
HelpText = dto.HelpText,
|
||||
Mandatory = dto.Mandatory,
|
||||
SortOrder = dto.SortOrder
|
||||
SortOrder = dto.SortOrder,
|
||||
ValidationRegExp = dto.ValidationRegExp
|
||||
}).ToList();
|
||||
|
||||
//Reset dirty properties
|
||||
|
||||
@@ -314,6 +314,7 @@ namespace umbraco.controls
|
||||
if (defaultData != null)
|
||||
{
|
||||
defaultData.PropertyTypeAlias = property.Key;
|
||||
defaultData.NodeId = _content.Id;
|
||||
}
|
||||
property.Value.DataEditor.Save();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Web.UI.WebControls;
|
||||
using ClientDependency.Core;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.cms.helpers;
|
||||
using umbraco.controls.GenericProperties;
|
||||
@@ -17,6 +18,7 @@ using umbraco.IO;
|
||||
using umbraco.presentation;
|
||||
using umbraco.BasePages;
|
||||
using ContentType = umbraco.cms.businesslogic.ContentType;
|
||||
using PropertyType = Umbraco.Core.Models.PropertyType;
|
||||
|
||||
namespace umbraco.controls
|
||||
{
|
||||
@@ -394,6 +396,15 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
{
|
||||
var tabs = _contentType.getVirtualTabs;
|
||||
var propertyTypeGroups = _contentType.PropertyTypeGroups.ToList();
|
||||
/*if (_contentType.ContentTypeItem != null)
|
||||
{
|
||||
var compositionIds = _contentType.ContentTypeItem.CompositionIds();
|
||||
foreach (var compositionId in compositionIds)
|
||||
{
|
||||
var groupsFromContentType = PropertyTypeGroup.GetPropertyTypeGroupsFromContentType(compositionId);
|
||||
propertyTypeGroups.AddRange(groupsFromContentType);
|
||||
}
|
||||
}*/
|
||||
var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll();
|
||||
|
||||
PropertyTypes.Controls.Clear();
|
||||
@@ -405,7 +416,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
gp = new GenericPropertyWrapper();
|
||||
gp.ID = "GenericPropertyNew";
|
||||
gp.Tabs = tabs;
|
||||
gp.PropertyGroups = propertyTypeGroups;
|
||||
//gp.PropertyGroups = propertyTypeGroups;
|
||||
gp.DataTypeDefinitions = dtds;
|
||||
PropertyTypeNew.Controls.Add(gp);
|
||||
PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
|
||||
@@ -415,7 +426,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1];
|
||||
gp.ID = "GenericPropertyNew";
|
||||
gp.Tabs = tabs;
|
||||
gp.PropertyGroups = propertyTypeGroups;
|
||||
//gp.PropertyGroups = propertyTypeGroups;
|
||||
gp.DataTypeDefinitions = dtds;
|
||||
gp.UpdateEditControl();
|
||||
gp.GenricPropertyControl.UpdateInterface();
|
||||
@@ -432,7 +443,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
string tabCaption = tab.ContentType == _contentType.Id ? tab.GetRawCaption() : tab.GetRawCaption() + " (inherited from " + new ContentType(tab.ContentType).Text + ")";
|
||||
PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));
|
||||
|
||||
var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.Id == tab.Id || x.ParentId == tab.Id);
|
||||
var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id);
|
||||
var propertyTypes = propertyGroup == null
|
||||
? tab.GetPropertyTypes(_contentType.Id, false)
|
||||
: propertyGroup.GetPropertyTypes();
|
||||
@@ -441,7 +452,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
if (propertyGroup != null && propertyGroup.ParentId > 0)
|
||||
propertyGroupId = propertyGroup.Id;
|
||||
|
||||
if (propertyTypes.Any())
|
||||
if (propertyTypes.Any(x => x.ContentTypeId == _contentType.Id))
|
||||
{
|
||||
var propSort = new HtmlInputHidden();
|
||||
propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content";
|
||||
@@ -453,13 +464,13 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
|
||||
{
|
||||
//If the PropertyType doesn't belong on this ContentType skip it and continue to the next one
|
||||
if(pt.ContentTypeId != _contentType.Id) continue;
|
||||
//if(pt.ContentTypeId != _contentType.Id) continue;
|
||||
|
||||
var gpw = new GenericPropertyWrapper();
|
||||
gpw.ID = "gpw_" + pt.Id;
|
||||
gpw.PropertyType = pt;
|
||||
gpw.Tabs = tabs;
|
||||
gp.PropertyGroups = propertyTypeGroups;
|
||||
//gpw.PropertyGroups = propertyTypeGroups;
|
||||
gpw.TabId = propertyGroupId;
|
||||
gpw.DataTypeDefinitions = dtds;
|
||||
gpw.Delete += new EventHandler(gpw_Delete);
|
||||
@@ -535,7 +546,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
|
||||
gpw.PropertyType = pt;
|
||||
gpw.Tabs = tabs;
|
||||
gpw.PropertyGroups = propertyTypeGroups;
|
||||
//gpw.PropertyGroups = propertyTypeGroups;
|
||||
gpw.DataTypeDefinitions = dtds;
|
||||
gpw.Delete += new EventHandler(gpw_Delete);
|
||||
gpw.FullId = "t_general_Contents_" + pt.Id;
|
||||
@@ -650,11 +661,43 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
propertyType.Description = gpw.GenricPropertyControl.Description;
|
||||
propertyType.ValidationRegExp = gpw.GenricPropertyControl.Validation;
|
||||
propertyType.Mandatory = gpw.GenricPropertyControl.Mandatory;
|
||||
propertyType.PropertyGroupId = gpw.GenricPropertyControl.Tab;
|
||||
propertyType.DataTypeDatabaseType = dataTypeDefinition.DatabaseType;
|
||||
propertyType.DataTypeDefinitionId = dataTypeDefinition.Id;
|
||||
propertyType.DataTypeId = dataTypeDefinition.ControlId;
|
||||
|
||||
if (propertyType.PropertyGroupId != gpw.GenricPropertyControl.Tab)
|
||||
{
|
||||
if (gpw.GenricPropertyControl.Tab == 0)
|
||||
{
|
||||
propertyType.PropertyGroupId = 0;
|
||||
}
|
||||
else if (contentTypeItem.PropertyGroups.Any(x => x.Id == gpw.GenricPropertyControl.Tab))
|
||||
{
|
||||
propertyType.PropertyGroupId = gpw.GenricPropertyControl.Tab;
|
||||
}
|
||||
else if (contentTypeItem.PropertyGroups.Any(x => x.ParentId == gpw.GenricPropertyControl.Tab))
|
||||
{
|
||||
var propertyGroup = contentTypeItem.PropertyGroups.First(x => x.ParentId == gpw.GenricPropertyControl.Tab);
|
||||
propertyType.PropertyGroupId = propertyGroup.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (
|
||||
contentTypeItem.CompositionPropertyGroups.Any(
|
||||
x => x.ParentId == gpw.GenricPropertyControl.Tab))
|
||||
{
|
||||
var propertyGroups = contentTypeItem.CompositionPropertyGroups.Where(x => x.ParentId == gpw.GenricPropertyControl.Tab);
|
||||
var propertyGroup = propertyGroups.First();
|
||||
propertyType.PropertyGroupId = propertyGroup.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
var propertyGroup = contentTypeItem.CompositionPropertyGroups.First(x => x.Id == gpw.GenricPropertyControl.Tab);
|
||||
contentTypeItem.AddPropertyGroup(propertyGroup.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Is only called to flush cache since gpw.PropertyType.Save() isn't called
|
||||
// clear local cache
|
||||
cms.businesslogic.cache.Cache.ClearCacheItem("UmbracoPropertyTypeCache" + gpw.PropertyType.Id);
|
||||
@@ -961,13 +1004,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
{
|
||||
if (_contentType.ContentTypeItem is IContentType || _contentType.ContentTypeItem is IMediaType)
|
||||
{
|
||||
var propertyGroup = new PropertyGroup { Name = txtNewTab.Text };
|
||||
if (_contentType.ContentTypeItem.PropertyGroups.Any())
|
||||
{
|
||||
var last = _contentType.ContentTypeItem.PropertyGroups.OrderBy(x => x.SortOrder).Last();
|
||||
propertyGroup.SortOrder = last.SortOrder + 1;
|
||||
}
|
||||
_contentType.ContentTypeItem.PropertyGroups.Add(propertyGroup);
|
||||
_contentType.ContentTypeItem.AddPropertyGroup(txtNewTab.Text);
|
||||
_contentType.Save();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -210,6 +210,7 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
}
|
||||
return _nodeId.Value;
|
||||
}
|
||||
internal set { _nodeId = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user