Ensures that member properties are created when member type property type's are added (same as U4-1407), streamlines how this occurs on the base class. Streamlines how empty aliases are validated at the repo level for members, media, content. Makes built-in member property type's non-editable
This commit is contained in:
@@ -577,33 +577,6 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return content;
|
||||
}
|
||||
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IContentType contentType, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>()
|
||||
.On<PropertyDataDto, PropertyTypeDto>(left => left.PropertyTypeId, right => right.Id)
|
||||
.Where<PropertyDataDto>(x => x.NodeId == id)
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
|
||||
var propertyDataDtos = Database.Fetch<PropertyDataDto, PropertyTypeDto>(sql);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id, createDate, updateDate);
|
||||
var properties = propertyFactory.BuildEntity(propertyDataDtos);
|
||||
|
||||
var newProperties = properties.Where(x => x.HasIdentity == false);
|
||||
foreach (var property in newProperties)
|
||||
{
|
||||
var propertyDataDto = new PropertyDataDto{ NodeId = id, PropertyTypeId = property.PropertyTypeId, VersionId = versionId };
|
||||
int primaryKey = Convert.ToInt32(Database.Insert(propertyDataDto));
|
||||
|
||||
property.Version = versionId;
|
||||
property.Id = primaryKey;
|
||||
}
|
||||
|
||||
return new PropertyCollection(properties);
|
||||
}
|
||||
|
||||
private string EnsureUniqueNodeName(int parentId, string nodeName, int id = 0)
|
||||
{
|
||||
if (EnsureUniqueNaming == false)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -304,6 +305,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var datatype = Database.FirstOrDefault<DataTypeDto>("WHERE controlId = @Id", new { Id = propertyType.DataTypeId });
|
||||
propertyType.DataTypeDefinitionId = datatype.DataTypeId;
|
||||
}
|
||||
|
||||
//validate the alias!
|
||||
ValidateAlias(propertyType);
|
||||
|
||||
var propertyTypeDto = propertyGroupFactory.BuildPropertyTypeDto(tabId, propertyType);
|
||||
int typePrimaryKey = propertyType.HasIdentity
|
||||
? Database.Update(propertyTypeDto)
|
||||
@@ -381,5 +386,39 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
return new PropertyTypeCollection(list);
|
||||
}
|
||||
|
||||
protected void ValidateAlias(PropertyType pt)
|
||||
{
|
||||
Mandate.That<InvalidOperationException>(string.IsNullOrEmpty(pt.Alias) == false,
|
||||
() =>
|
||||
{
|
||||
var message =
|
||||
string.Format(
|
||||
"{0} '{1}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
|
||||
"Property Type",
|
||||
pt.Name);
|
||||
var exception = new InvalidOperationException(message);
|
||||
|
||||
LogHelper.Error<ContentTypeBaseRepository<TId, TEntity>>(message, exception);
|
||||
throw exception;
|
||||
});
|
||||
}
|
||||
|
||||
protected void ValidateAlias(TEntity entity)
|
||||
{
|
||||
Mandate.That<InvalidOperationException>(string.IsNullOrEmpty(entity.Alias) == false,
|
||||
() =>
|
||||
{
|
||||
var message =
|
||||
string.Format(
|
||||
"{0} '{1}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
|
||||
typeof(TEntity).Name,
|
||||
entity.Name);
|
||||
var exception = new InvalidOperationException(message);
|
||||
|
||||
LogHelper.Error<ContentTypeBaseRepository<TId, TEntity>>(message, exception);
|
||||
throw exception;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,18 +208,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IContentType entity)
|
||||
{
|
||||
Mandate.That<Exception>(string.IsNullOrEmpty(entity.Alias) == false,
|
||||
() =>
|
||||
{
|
||||
var message =
|
||||
string.Format(
|
||||
"ContentType '{0}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
|
||||
entity.Name);
|
||||
var exception = new Exception(message);
|
||||
|
||||
LogHelper.Error<ContentTypeRepository>(message, exception);
|
||||
throw exception;
|
||||
});
|
||||
ValidateAlias(entity);
|
||||
|
||||
//Updates Modified date
|
||||
((ContentType)entity).UpdatingEntity();
|
||||
|
||||
@@ -358,34 +358,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PropertyCollection GetPropertyCollection(int id, Guid versionId, IMediaType contentType, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>()
|
||||
.On<PropertyDataDto, PropertyTypeDto>(left => left.PropertyTypeId, right => right.Id)
|
||||
.Where<PropertyDataDto>(x => x.NodeId == id)
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
|
||||
var propertyDataDtos = Database.Fetch<PropertyDataDto, PropertyTypeDto>(sql);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id, createDate, updateDate);
|
||||
var properties = propertyFactory.BuildEntity(propertyDataDtos);
|
||||
|
||||
var newProperties = properties.Where(x => x.HasIdentity == false);
|
||||
foreach (var property in newProperties)
|
||||
{
|
||||
var propertyDataDto = new PropertyDataDto { NodeId = id, PropertyTypeId = property.PropertyTypeId, VersionId = versionId };
|
||||
int primaryKey = Convert.ToInt32(Database.Insert(propertyDataDto));
|
||||
|
||||
property.Version = versionId;
|
||||
property.Id = primaryKey;
|
||||
}
|
||||
|
||||
return new PropertyCollection(properties);
|
||||
}
|
||||
|
||||
|
||||
private string EnsureUniqueNodeName(int parentId, string nodeName, int id = 0)
|
||||
{
|
||||
if (EnsureUniqueNaming == false)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -162,6 +163,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IMediaType entity)
|
||||
{
|
||||
ValidateAlias(entity);
|
||||
|
||||
//Updates Modified date
|
||||
((MediaType)entity).UpdatingEntity();
|
||||
|
||||
|
||||
@@ -600,6 +600,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var factory = new MemberReadOnlyFactory(memberTypes);
|
||||
var member = factory.BuildEntity(dto);
|
||||
|
||||
member.Properties = GetPropertyCollection(dto.NodeId, dto.VersionId, member.ContentType, dto.CreateDate, dto.UpdateDate);
|
||||
|
||||
return member;
|
||||
}
|
||||
|
||||
@@ -613,8 +615,15 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var memberTypeList = _memberTypeRepository.GetAll();
|
||||
memberTypeList.ForEach(x => memberTypes.Add(x.Alias, x));
|
||||
|
||||
var entities = new List<IMember>();
|
||||
var factory = new MemberReadOnlyFactory(memberTypes);
|
||||
return dtos.Select(factory.BuildEntity);
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var entity = factory.BuildEntity(dto);
|
||||
entity.Properties = GetPropertyCollection(dto.NodeId, dto.VersionId, entity.ContentType, dto.CreateDate, dto.UpdateDate);
|
||||
entities.Add(entity);
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -194,6 +195,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IMemberType entity)
|
||||
{
|
||||
ValidateAlias(entity);
|
||||
|
||||
//Updates Modified date
|
||||
((MemberType)entity).UpdatingEntity();
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Persistence.Factories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Repositories
|
||||
@@ -90,5 +92,42 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
protected abstract void PerformDeleteVersion(int id, Guid versionId);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// This is a fix for U4-1407 - when property types are added to a content type - the property of the entity are not actually created
|
||||
/// and we get YSODs
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="versionId"></param>
|
||||
/// <param name="contentType"></param>
|
||||
/// <param name="createDate"></param>
|
||||
/// <param name="updateDate"></param>
|
||||
/// <returns></returns>
|
||||
protected PropertyCollection GetPropertyCollection(int id, Guid versionId, IContentTypeComposition contentType, DateTime createDate, DateTime updateDate)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>()
|
||||
.On<PropertyDataDto, PropertyTypeDto>(left => left.PropertyTypeId, right => right.Id)
|
||||
.Where<PropertyDataDto>(x => x.NodeId == id)
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
|
||||
var propertyDataDtos = Database.Fetch<PropertyDataDto, PropertyTypeDto>(sql);
|
||||
var propertyFactory = new PropertyFactory(contentType, versionId, id, createDate, updateDate);
|
||||
var properties = propertyFactory.BuildEntity(propertyDataDtos).ToArray();
|
||||
|
||||
var newProperties = properties.Where(x => x.HasIdentity == false);
|
||||
foreach (var property in newProperties)
|
||||
{
|
||||
var propertyDataDto = new PropertyDataDto { NodeId = id, PropertyTypeId = property.PropertyTypeId, VersionId = versionId };
|
||||
int primaryKey = Convert.ToInt32(Database.Insert(propertyDataDto));
|
||||
|
||||
property.Version = versionId;
|
||||
property.Id = primaryKey;
|
||||
}
|
||||
|
||||
return new PropertyCollection(properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,9 @@
|
||||
style="padding: 0px; display: block; margin: 0px;">
|
||||
|
||||
<h3 style="padding: 0px; margin: 0px;">
|
||||
|
||||
<asp:ImageButton ID="DeleteButton2" Runat="server"></asp:ImageButton>
|
||||
|
||||
|
||||
<a href="javascript:expandCollapse('<%=this.ClientID%>');"><img src="<%= Umbraco.Core.IO.IOHelper.ResolveUrl( Umbraco.Core.IO.SystemDirectories.Umbraco )%>/images/expand.png" style="FLOAT: right"/>
|
||||
<asp:Literal ID="FullHeader" Runat="server"></asp:Literal>
|
||||
</a>
|
||||
@@ -20,7 +21,7 @@
|
||||
<div id="edit<%=this.ClientID%>" style="DISPLAY: none;">
|
||||
|
||||
<h3 style="padding: 0px; margin: 0px;">
|
||||
<asp:ImageButton ID="DeleteButton" Runat="server"></asp:ImageButton>
|
||||
<asp:ImageButton ID="DeleteButton" Runat="server" Visible='<%#AllowPropertyEdit %>'></asp:ImageButton>
|
||||
<a href="javascript:expandCollapse('<%=this.ClientID%>');"><img src="<%= Umbraco.Core.IO.IOHelper.ResolveUrl( Umbraco.Core.IO.SystemDirectories.Umbraco )%>/images/collapse.png" id="<%=this.ClientID%>_fold" style="FLOAT: right" />
|
||||
Edit "<asp:Literal ID="Header" Runat="server"></asp:Literal>"</a>
|
||||
</h3>
|
||||
@@ -31,7 +32,8 @@
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="PropertyPanel2" runat="server" Text="Alias">
|
||||
<asp:TextBox id="tbAlias" runat="server" CssClass="propertyFormInput"></asp:TextBox>
|
||||
<asp:TextBox id="tbAlias" runat="server" CssClass="propertyFormInput" ></asp:TextBox>
|
||||
<asp:Label ID="lblAlias" runat="server" ></asp:Label>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="PropertyPanel3" runat="server" Text="Type">
|
||||
@@ -42,7 +44,7 @@
|
||||
<asp:DropDownList id="ddlTab" runat="server" CssClass="propertyFormInput"></asp:DropDownList>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="PropertyPanel5" runat="server" Text="Mandatory">
|
||||
<cc1:PropertyPanel ID="PropertyPanel5" runat="server" Text="Mandatory" >
|
||||
<asp:CheckBox id="checkMandatory" runat="server"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
@@ -288,85 +289,43 @@ namespace umbraco.controls
|
||||
//we need to re-set the UmbracoContext since it will be nulled and our cache handlers need it
|
||||
global::Umbraco.Web.UmbracoContext.Current = asyncState.UmbracoContext;
|
||||
|
||||
//NOTE The saving of the 5 properties (Name, Alias, Icon, Description and Thumbnail) are divided
|
||||
//to avoid the multiple cache flushing when each property is set using the legacy ContentType class,
|
||||
//which has been reduced to the else-clause.
|
||||
//For IContentType and IMediaType the cache will only be flushed upon saving.
|
||||
//if (_contentType.ContentTypeItem is IContentType
|
||||
// || _contentType.ContentTypeItem is IMediaType
|
||||
// || _contentType.ContentTypeItem is IMemberType)
|
||||
//{
|
||||
_contentType.ContentTypeItem.Name = txtName.Text;
|
||||
_contentType.ContentTypeItem.Alias = txtAlias.Text;
|
||||
_contentType.ContentTypeItem.Icon = ddlIcons.SelectedValue;
|
||||
_contentType.ContentTypeItem.Description = description.Text;
|
||||
_contentType.ContentTypeItem.Thumbnail = ddlThumbnails.SelectedValue;
|
||||
_contentType.ContentTypeItem.AllowedAsRoot = allowAtRoot.Checked;
|
||||
_contentType.ContentTypeItem.Name = txtName.Text;
|
||||
_contentType.ContentTypeItem.Alias = txtAlias.Text;
|
||||
_contentType.ContentTypeItem.Icon = ddlIcons.SelectedValue;
|
||||
_contentType.ContentTypeItem.Description = description.Text;
|
||||
_contentType.ContentTypeItem.Thumbnail = ddlThumbnails.SelectedValue;
|
||||
_contentType.ContentTypeItem.AllowedAsRoot = allowAtRoot.Checked;
|
||||
|
||||
int i = 0;
|
||||
var ids = SaveAllowedChildTypes();
|
||||
_contentType.ContentTypeItem.AllowedContentTypes = ids.Select(x => new ContentTypeSort {Id = new Lazy<int>(() => x), SortOrder = i++});
|
||||
int i = 0;
|
||||
var ids = SaveAllowedChildTypes();
|
||||
_contentType.ContentTypeItem.AllowedContentTypes = ids.Select(x => new ContentTypeSort {Id = new Lazy<int>(() => x), SortOrder = i++});
|
||||
|
||||
var tabs = SaveTabs();
|
||||
foreach (var tab in tabs)
|
||||
var tabs = SaveTabs();
|
||||
foreach (var tab in tabs)
|
||||
{
|
||||
if (_contentType.ContentTypeItem.PropertyGroups.Contains(tab.Item2))
|
||||
{
|
||||
if (_contentType.ContentTypeItem.PropertyGroups.Contains(tab.Item2))
|
||||
{
|
||||
_contentType.ContentTypeItem.PropertyGroups[tab.Item2].SortOrder = tab.Item3;
|
||||
}
|
||||
else
|
||||
{
|
||||
_contentType.ContentTypeItem.PropertyGroups.Add(new PropertyGroup {Id = tab.Item1, Name = tab.Item2, SortOrder = tab.Item3});
|
||||
}
|
||||
_contentType.ContentTypeItem.PropertyGroups[tab.Item2].SortOrder = tab.Item3;
|
||||
}
|
||||
|
||||
SavePropertyType(asyncState.SaveArgs, _contentType.ContentTypeItem);
|
||||
UpdatePropertyTypes(_contentType.ContentTypeItem);
|
||||
|
||||
if (DocumentTypeCallback != null)
|
||||
else
|
||||
{
|
||||
var documentType = _contentType as DocumentType;
|
||||
if (documentType != null)
|
||||
{
|
||||
var result = DocumentTypeCallback(documentType);
|
||||
}
|
||||
_contentType.ContentTypeItem.PropertyGroups.Add(new PropertyGroup {Id = tab.Item1, Name = tab.Item2, SortOrder = tab.Item3});
|
||||
}
|
||||
}
|
||||
|
||||
_contentType.Save();
|
||||
//}
|
||||
//else //Legacy approach for supporting MemberType
|
||||
//{
|
||||
// if (asyncState.HasNameChanged())
|
||||
// _contentType.Text = txtName.Text;
|
||||
SavePropertyType(asyncState.SaveArgs, _contentType.ContentTypeItem);
|
||||
UpdatePropertyTypes(_contentType.ContentTypeItem);
|
||||
|
||||
// if (asyncState.HasAliasChanged())
|
||||
// _contentType.Alias = txtAlias.Text;
|
||||
if (DocumentTypeCallback != null)
|
||||
{
|
||||
var documentType = _contentType as DocumentType;
|
||||
if (documentType != null)
|
||||
{
|
||||
var result = DocumentTypeCallback(documentType);
|
||||
}
|
||||
}
|
||||
|
||||
// _contentType.IconUrl = ddlIcons.SelectedValue;
|
||||
// _contentType.Description = description.Text;
|
||||
// _contentType.Thumbnail = ddlThumbnails.SelectedValue;
|
||||
|
||||
// SavePropertyTypesLegacy(asyncState.SaveArgs);
|
||||
|
||||
// var tabs = SaveTabs();
|
||||
// foreach (var tab in tabs)
|
||||
// {
|
||||
// _contentType.SetTabName(tab.Item1, tab.Item2);
|
||||
// _contentType.SetTabSortOrder(tab.Item1, tab.Item3);
|
||||
// }
|
||||
|
||||
// _contentType.AllowedChildContentTypeIDs = SaveAllowedChildTypes();
|
||||
// _contentType.AllowAtRoot = allowAtRoot.Checked;
|
||||
|
||||
// _contentType.Save();
|
||||
|
||||
// // Only if the doctype alias changed, cause a regeneration of the xml cache file since
|
||||
// // the xml element names will need to be updated to reflect the new alias
|
||||
// if (asyncState.HasAliasChanged() || asyncState.HasAnyPropertyAliasChanged(_contentType))
|
||||
// {
|
||||
// _contentType.RebuildXmlStructuresForContent();
|
||||
// }
|
||||
//}
|
||||
_contentType.Save();
|
||||
|
||||
Trace.Write("ContentTypeControlNew", "task completing");
|
||||
};
|
||||
@@ -648,7 +607,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
|
||||
PropertyTypes.Controls.Add(new LiteralControl("<div id='tabs-container'>")); // opens draggable container for properties on tabs
|
||||
|
||||
foreach (ContentType.TabI tab in tabs)
|
||||
foreach (var tab in tabs)
|
||||
{
|
||||
string tabName = tab.GetRawCaption();
|
||||
string tabCaption = tabName;
|
||||
@@ -660,9 +619,9 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 data-tabname='" + tabName + "' class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));
|
||||
|
||||
var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id);
|
||||
var propertyTypes = propertyGroup == null
|
||||
? tab.GetPropertyTypes(_contentType.Id, false)
|
||||
: propertyGroup.GetPropertyTypes();
|
||||
var propertyTypes = (propertyGroup == null
|
||||
? tab.GetPropertyTypes(_contentType.Id, false)
|
||||
: propertyGroup.GetPropertyTypes()).ToArray();
|
||||
|
||||
var propertyGroupId = tab.Id;
|
||||
|
||||
@@ -675,26 +634,26 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
{
|
||||
PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + propertyGroupId.ToString() + "_Contents\">"));
|
||||
|
||||
foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
|
||||
foreach (var 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;
|
||||
|
||||
var gpw = new GenericPropertyWrapper();
|
||||
var gpw = GetPropertyWrapperForPropertyType(pt);
|
||||
gpw.ID = "gpw_" + pt.Id;
|
||||
gpw.PropertyType = pt;
|
||||
gpw.Tabs = tabs;
|
||||
gpw.TabId = propertyGroupId;
|
||||
gpw.DataTypeDefinitions = dtds;
|
||||
gpw.Delete += new EventHandler(gpw_Delete);
|
||||
gpw.FullId = "t_" + propertyGroupId.ToString() + "_Contents_" + +pt.Id;
|
||||
gpw.Delete += gpw_Delete;
|
||||
gpw.FullId = "t_" + propertyGroupId + "_Contents_" + +pt.Id;
|
||||
|
||||
PropertyTypes.Controls.Add(gpw);
|
||||
_genericProperties.Add(gpw);
|
||||
if (refresh)
|
||||
gpw.GenricPropertyControl.UpdateInterface();
|
||||
|
||||
inTab.Add(pt.Id.ToString(), "");
|
||||
inTab.Add(pt.Id.ToString(CultureInfo.InvariantCulture), "");
|
||||
counter++;
|
||||
}
|
||||
|
||||
@@ -714,25 +673,25 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
// Generic properties tab
|
||||
counter = 0;
|
||||
bool propertyTabHasProperties = false;
|
||||
var propertiesPH = new PlaceHolder();
|
||||
propertiesPH.ID = "propertiesPH";
|
||||
var propertiesPh = new PlaceHolder();
|
||||
propertiesPh.ID = "propertiesPH";
|
||||
PropertyTypes.Controls.Add(new LiteralControl("<h2 data-tabname=\"Generic Properties\" class=\"propertypaneTitel\">Tab: Generic Properties</h2>"));
|
||||
PropertyTypes.Controls.Add(propertiesPH);
|
||||
PropertyTypes.Controls.Add(propertiesPh);
|
||||
|
||||
var propSort_gp = new HtmlInputHidden();
|
||||
propSort_gp.ID = "propSort_general_Content";
|
||||
PropertyTypes.Controls.Add(propSort_gp);
|
||||
_sortLists.Add(propSort_gp);
|
||||
var propSortGp = new HtmlInputHidden();
|
||||
propSortGp.ID = "propSort_general_Content";
|
||||
PropertyTypes.Controls.Add(propSortGp);
|
||||
_sortLists.Add(propSortGp);
|
||||
|
||||
propertiesPH.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
|
||||
foreach (cms.businesslogic.propertytype.PropertyType pt in _contentType.PropertyTypes)
|
||||
propertiesPh.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
|
||||
foreach (var pt in _contentType.PropertyTypes)
|
||||
{
|
||||
//This use to be:
|
||||
if (pt.ContentTypeId == _contentType.Id && inTab.ContainsKey(pt.Id.ToString()) == false)
|
||||
if (pt.ContentTypeId == _contentType.Id && inTab.ContainsKey(pt.Id.ToString(CultureInfo.InvariantCulture)) == false)
|
||||
//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 = new GenericPropertyWrapper();
|
||||
var gpw = GetPropertyWrapperForPropertyType(pt);
|
||||
|
||||
// Changed by duckie, was:
|
||||
// gpw.ID = "gpw_" + editPropertyType.Alias;
|
||||
@@ -745,7 +704,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
gpw.Delete += new EventHandler(gpw_Delete);
|
||||
gpw.FullId = "t_general_Contents_" + pt.Id;
|
||||
|
||||
propertiesPH.Controls.Add(gpw);
|
||||
propertiesPh.Controls.Add(gpw);
|
||||
_genericProperties.Add(gpw);
|
||||
if (refresh)
|
||||
gpw.GenricPropertyControl.UpdateInterface();
|
||||
@@ -755,9 +714,9 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
}
|
||||
}
|
||||
|
||||
propertiesPH.Controls.Add(new LiteralControl("</ul>"));
|
||||
propertiesPh.Controls.Add(new LiteralControl("</ul>"));
|
||||
|
||||
var jsSortable_gp = GetJavaScriptForPropertySorting(propSort_gp.ClientID);
|
||||
var jsSortable_gp = GetJavaScriptForPropertySorting(propSortGp.ClientID);
|
||||
|
||||
Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true);
|
||||
|
||||
@@ -769,13 +728,30 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyTypes.Controls.Add(propertiesPH);
|
||||
PropertyTypes.Controls.Add(propertiesPh);
|
||||
}
|
||||
|
||||
PropertyTypes.Controls.Add(new LiteralControl("</div>")); // closes draggable container for properties on tabs
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a generic property wrapper for a given property - this determines if the property type should be
|
||||
/// allowed to be editable.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private GenericPropertyWrapper GetPropertyWrapperForPropertyType(cms.businesslogic.propertytype.PropertyType pt)
|
||||
{
|
||||
if (_contentType.ContentTypeItem is IMemberType)
|
||||
{
|
||||
var builtInAliases = global::Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray();
|
||||
var gpw = new GenericPropertyWrapper(builtInAliases.Contains(pt.Alias) == false);
|
||||
return gpw;
|
||||
}
|
||||
|
||||
return new GenericPropertyWrapper();
|
||||
}
|
||||
|
||||
private string GetJavaScriptForPropertySorting(string propSortClientId)
|
||||
{
|
||||
return @"(function($) {
|
||||
@@ -948,77 +924,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
}
|
||||
}
|
||||
|
||||
private void SavePropertyTypesLegacy(SaveClickEventArgs e)
|
||||
{
|
||||
this.CreateChildControls();
|
||||
|
||||
GenericProperty gpData = gp.GenricPropertyControl;
|
||||
if (gpData.Name.Trim() != "" && gpData.Alias.Trim() != "")
|
||||
{
|
||||
if (DoesPropertyTypeAliasExist(gpData))
|
||||
{
|
||||
cms.businesslogic.propertytype.PropertyType pt =
|
||||
_contentType.AddPropertyType(
|
||||
cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpData.Type),
|
||||
Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim()), gpData.Name);
|
||||
pt.Description = gpData.Description;
|
||||
pt.ValidationRegExp = gpData.Validation.Trim();
|
||||
pt.Mandatory = gpData.Mandatory;
|
||||
|
||||
if (gpData.Tab != 0)
|
||||
{
|
||||
_contentType.SetTabOnPropertyType(pt, gpData.Tab);
|
||||
}
|
||||
|
||||
gpData.Clear();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Message = ui.Text("contentTypeDublicatePropertyType", Security.CurrentUser);
|
||||
e.IconType = BasePage.speechBubbleIcon.warning;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GenericPropertyWrapper gpw in _genericProperties)
|
||||
{
|
||||
cms.businesslogic.propertytype.PropertyType pt = gpw.PropertyType;
|
||||
pt.Alias = gpw.GenricPropertyControl.Alias; // FIXME so we blindly trust the UI for safe aliases?!
|
||||
pt.Name = gpw.GenricPropertyControl.Name;
|
||||
pt.Description = gpw.GenricPropertyControl.Description;
|
||||
pt.ValidationRegExp = gpw.GenricPropertyControl.Validation.Trim();
|
||||
pt.Mandatory = gpw.GenricPropertyControl.Mandatory;
|
||||
pt.DataTypeDefinition = cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpw.GenricPropertyControl.Type);
|
||||
if (gpw.GenricPropertyControl.Tab == 0)
|
||||
_contentType.removePropertyTypeFromTab(pt);
|
||||
else
|
||||
_contentType.SetTabOnPropertyType(pt, gpw.GenricPropertyControl.Tab);
|
||||
|
||||
pt.Save();
|
||||
}
|
||||
|
||||
// Sort order
|
||||
foreach (HtmlInputHidden propSorter in _sortLists)
|
||||
{
|
||||
if (propSorter.Value.Trim() != "")
|
||||
{
|
||||
string tabId = propSorter.ID;
|
||||
// remove leading "propSort_" and trailing "_Content"
|
||||
tabId = tabId.Substring(9, tabId.Length - 9 - 8);
|
||||
// calc the position of the prop SO i.e. after "t_<tabId>Contents[]="
|
||||
int propSOPosition = "t_".Length + tabId.Length + "Contents[]=".Length + 1;
|
||||
|
||||
string[] tempSO = propSorter.Value.Split("&".ToCharArray());
|
||||
for (int i = 0; i < tempSO.Length; i++)
|
||||
{
|
||||
string propSO = tempSO[i].Substring(propSOPosition);
|
||||
int currentSortOrder = int.Parse(propSO);
|
||||
cms.businesslogic.propertytype.PropertyType.GetPropertyType(currentSortOrder).SortOrder = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool DoesPropertyTypeAliasExist(GenericProperty gpData)
|
||||
{
|
||||
bool hasAlias = _contentType.getPropertyType(Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim())) != null;
|
||||
@@ -1044,24 +949,13 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
int propertyId = int.Parse(e.Item.Cells[0].Text);
|
||||
string rawName = string.Empty;
|
||||
|
||||
//if (_contentType.ContentTypeItem is IContentType
|
||||
// || _contentType.ContentTypeItem is IMediaType
|
||||
// || _contentType.ContentTypeItem is IMemberType)
|
||||
//{
|
||||
var propertyType = _contentType.ContentTypeItem.PropertyTypes.FirstOrDefault(x => x.Id == propertyId);
|
||||
if (propertyType != null && string.IsNullOrEmpty(propertyType.Alias) == false)
|
||||
{
|
||||
rawName = propertyType.Name;
|
||||
_contentType.ContentTypeItem.RemovePropertyType(propertyType.Alias);
|
||||
_contentType.Save();
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// cms.businesslogic.propertytype.PropertyType pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(propertyId);
|
||||
// rawName = pt.GetRawName();
|
||||
// pt.delete();
|
||||
//}
|
||||
var propertyType = _contentType.ContentTypeItem.PropertyTypes.FirstOrDefault(x => x.Id == propertyId);
|
||||
if (propertyType != null && string.IsNullOrEmpty(propertyType.Alias) == false)
|
||||
{
|
||||
rawName = propertyType.Name;
|
||||
_contentType.ContentTypeItem.RemovePropertyType(propertyType.Alias);
|
||||
_contentType.Save();
|
||||
}
|
||||
|
||||
RaiseBubbleEvent(new object(), new SaveClickEventArgs("Property ´" + rawName + "´ deleted"));
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
using ClientDependency.Core;
|
||||
using umbraco.cms.businesslogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.BasePages;
|
||||
@@ -25,61 +26,49 @@ namespace umbraco.controls.GenericProperties
|
||||
public partial class GenericProperty : System.Web.UI.UserControl
|
||||
{
|
||||
|
||||
private cms.businesslogic.propertytype.PropertyType _pt;
|
||||
private cms.businesslogic.web.DocumentType.TabI[] _tabs;
|
||||
private cms.businesslogic.datatype.DataTypeDefinition[] _dataTypeDefinitions;
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public GenericProperty()
|
||||
{
|
||||
FullId = "";
|
||||
AllowPropertyEdit = true;
|
||||
}
|
||||
|
||||
private cms.businesslogic.datatype.DataTypeDefinition[] _dataTypeDefinitions;
|
||||
private int _tabId = 0;
|
||||
|
||||
public event System.EventHandler Delete;
|
||||
|
||||
private string _fullId = "";
|
||||
public event EventHandler Delete;
|
||||
|
||||
public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions
|
||||
{
|
||||
set
|
||||
{
|
||||
_dataTypeDefinitions = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Defines whether the property can be edited in the UI
|
||||
/// </summary>
|
||||
public bool AllowPropertyEdit { get; set; }
|
||||
|
||||
public int TabId
|
||||
{
|
||||
set {
|
||||
_tabId = value;
|
||||
}
|
||||
}
|
||||
public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions
|
||||
{
|
||||
set { _dataTypeDefinitions = value; }
|
||||
}
|
||||
|
||||
public cms.businesslogic.propertytype.PropertyType PropertyType
|
||||
{
|
||||
set
|
||||
{
|
||||
_pt = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return _pt;
|
||||
}
|
||||
}
|
||||
public int TabId
|
||||
{
|
||||
set { _tabId = value; }
|
||||
}
|
||||
|
||||
public cms.businesslogic.web.DocumentType.TabI[] Tabs
|
||||
{
|
||||
get { return _tabs; }
|
||||
set
|
||||
{
|
||||
_tabs = value;
|
||||
}
|
||||
}
|
||||
public PropertyType PropertyType { get; set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get {
|
||||
return tbName.Text;
|
||||
}
|
||||
}
|
||||
public string Alias
|
||||
public ContentType.TabI[] Tabs { get; set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return tbName.Text; }
|
||||
}
|
||||
|
||||
public string Alias
|
||||
{
|
||||
get {return tbAlias.Text;} // FIXME so we blindly trust the UI for safe aliases?!
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get {return tbDescription.Text;}
|
||||
@@ -96,29 +85,12 @@ namespace umbraco.controls.GenericProperties
|
||||
{
|
||||
get {return int.Parse(ddlTab.SelectedValue);}
|
||||
}
|
||||
public string FullId
|
||||
{
|
||||
set
|
||||
{
|
||||
_fullId = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return _fullId;
|
||||
}
|
||||
}
|
||||
|
||||
private int _id;
|
||||
public string FullId { get; set; }
|
||||
|
||||
public int Id {
|
||||
set {
|
||||
_id = value;
|
||||
}get{
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Type
|
||||
public int Type
|
||||
{
|
||||
get {return int.Parse(ddlTypes.SelectedValue);}
|
||||
}
|
||||
@@ -127,6 +99,7 @@ namespace umbraco.controls.GenericProperties
|
||||
{
|
||||
tbName.Text = "";
|
||||
tbAlias.Text = "";
|
||||
lblAlias.Text = "";
|
||||
tbValidation.Text = "";
|
||||
tbDescription.Text = "";
|
||||
ddlTab.SelectedIndex = 0;
|
||||
@@ -141,8 +114,8 @@ namespace umbraco.controls.GenericProperties
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
|
||||
//SD: this is temporary in v4, in v6 we have a proper user control hierarchy
|
||||
|
||||
//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
|
||||
@@ -161,22 +134,31 @@ namespace umbraco.controls.GenericProperties
|
||||
public void UpdateInterface()
|
||||
{
|
||||
// Name and alias
|
||||
if (_pt != null)
|
||||
if (PropertyType != null)
|
||||
{
|
||||
_id = _pt.Id;
|
||||
Id = PropertyType.Id;
|
||||
//form.Attributes.Add("style", "display: none;");
|
||||
tbName.Text = _pt.GetRawName();
|
||||
tbAlias.Text = _pt.Alias;
|
||||
FullHeader.Text = _pt.GetRawName() + " (" + _pt.Alias + "), Type: " + _pt.DataTypeDefinition.Text;;
|
||||
Header.Text = _pt.GetRawName();
|
||||
tbName.Text = PropertyType.GetRawName();
|
||||
tbAlias.Text = PropertyType.Alias;
|
||||
lblAlias.Text = PropertyType.Alias;
|
||||
FullHeader.Text = PropertyType.GetRawName() + " (" + PropertyType.Alias + "), Type: " + PropertyType.DataTypeDefinition.Text;;
|
||||
Header.Text = PropertyType.GetRawName();
|
||||
DeleteButton.Visible = true;
|
||||
DeleteButton.ImageUrl = SystemDirectories.Umbraco + "/images/delete_button.png";
|
||||
DeleteButton.Attributes.Add("style", "float: right; cursor: hand;");
|
||||
DeleteButton.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');");
|
||||
DeleteButton2.Visible = true;
|
||||
|
||||
|
||||
DeleteButton2.ImageUrl = SystemDirectories.Umbraco + "/images/delete_button.png";
|
||||
DeleteButton2.Attributes.Add("style", "float: right; cursor: hand;");
|
||||
DeleteButton2.Attributes.Add("onclick", "return confirm('" + ui.Text("areyousure", CurrentUser) + "');");
|
||||
DeleteButton2.Visible = true;
|
||||
|
||||
//DeleteButton2.Visible = AllowPropertyEdit;
|
||||
//tbAlias.Visible = AllowPropertyEdit;
|
||||
//lblAlias.Visible = AllowPropertyEdit == false;
|
||||
//PropertyPanel5.Visible = AllowPropertyEdit;
|
||||
//PropertyPanel6.Visible = AllowPropertyEdit;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,7 +181,7 @@ namespace umbraco.controls.GenericProperties
|
||||
foreach(cms.businesslogic.datatype.DataTypeDefinition dt in _dataTypeDefinitions)
|
||||
{
|
||||
var li = new ListItem(dt.Text, dt.Id.ToString());
|
||||
if ((_pt != null && _pt.DataTypeDefinition.Id == dt.Id))
|
||||
if ((PropertyType != null && PropertyType.DataTypeDefinition.Id == dt.Id))
|
||||
{
|
||||
li.Selected = true;
|
||||
itemSelected = true;
|
||||
@@ -216,13 +198,13 @@ namespace umbraco.controls.GenericProperties
|
||||
}
|
||||
|
||||
// tabs
|
||||
if (_tabs != null)
|
||||
if (Tabs != null)
|
||||
{
|
||||
ddlTab.Items.Clear();
|
||||
for (int i=0;i<_tabs.Length;i++)
|
||||
for (int i=0;i<Tabs.Length;i++)
|
||||
{
|
||||
ListItem li = new ListItem(_tabs[i].Caption, _tabs[i].Id.ToString());
|
||||
if (_tabs[i].Id == _tabId)
|
||||
ListItem li = new ListItem(Tabs[i].Caption, Tabs[i].Id.ToString());
|
||||
if (Tabs[i].Id == _tabId)
|
||||
li.Selected = true;
|
||||
ddlTab.Items.Add(li);
|
||||
}
|
||||
@@ -233,16 +215,16 @@ namespace umbraco.controls.GenericProperties
|
||||
ddlTab.Items.Add(liGeneral);
|
||||
|
||||
// mandatory
|
||||
if (_pt != null && _pt.Mandatory)
|
||||
if (PropertyType != null && PropertyType.Mandatory)
|
||||
checkMandatory.Checked = true;
|
||||
|
||||
// validation
|
||||
if (_pt != null && string.IsNullOrEmpty(_pt.ValidationRegExp) == false)
|
||||
tbValidation.Text = _pt.ValidationRegExp;
|
||||
if (PropertyType != null && string.IsNullOrEmpty(PropertyType.ValidationRegExp) == false)
|
||||
tbValidation.Text = PropertyType.ValidationRegExp;
|
||||
|
||||
// description
|
||||
if (_pt != null && _pt.Description != "")
|
||||
tbDescription.Text = _pt.GetRawDescription();
|
||||
if (PropertyType != null && PropertyType.Description != "")
|
||||
tbDescription.Text = PropertyType.GetRawDescription();
|
||||
}
|
||||
|
||||
private void SetDefaultDocumentTypeProperty()
|
||||
@@ -259,21 +241,18 @@ namespace umbraco.controls.GenericProperties
|
||||
}
|
||||
}
|
||||
|
||||
protected void defaultDeleteHandler(object sender, System.EventArgs e)
|
||||
protected void defaultDeleteHandler(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
base.OnInit(e);
|
||||
|
||||
this.Delete += new System.EventHandler(defaultDeleteHandler);
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
DeleteButton2.Click += DeleteButton2_Click;
|
||||
Delete += defaultDeleteHandler;
|
||||
|
||||
// [ClientDependency(ClientDependencyType.Javascript, "js/UmbracoCasingRules.aspx", "UmbracoRoot")]
|
||||
var loader = ClientDependency.Core.Controls.ClientDependencyLoader.GetInstance(new HttpContextWrapper(Context));
|
||||
@@ -281,26 +260,14 @@ namespace umbraco.controls.GenericProperties
|
||||
loader.RegisterDependency(helper.GetCoreStringsControllerPath() + "ServicesJavaScript", ClientDependencyType.Javascript);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.DeleteButton.Click += new System.Web.UI.ImageClickEventHandler(this.DeleteButton_Click);
|
||||
this.DeleteButton2.Click += new System.Web.UI.ImageClickEventHandler(this.DeleteButton2_Click);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void DeleteButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
|
||||
{
|
||||
Delete(this,new System.EventArgs());
|
||||
Delete(this,new EventArgs());
|
||||
}
|
||||
|
||||
private void DeleteButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
|
||||
{
|
||||
Delete(this,new System.EventArgs());
|
||||
Delete(this,new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,15 @@ namespace umbraco.controls.GenericProperties {
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox tbAlias;
|
||||
|
||||
/// <summary>
|
||||
/// tbAlias control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblAlias;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyPanel2 control.
|
||||
|
||||
@@ -5,100 +5,97 @@ using umbraco.cms.businesslogic.propertytype;
|
||||
|
||||
namespace umbraco.controls.GenericProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for GenericPropertyWrapper.
|
||||
/// </summary>
|
||||
public class GenericPropertyWrapper : System.Web.UI.WebControls.PlaceHolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for GenericPropertyWrapper.
|
||||
/// </summary>
|
||||
public class GenericPropertyWrapper : System.Web.UI.WebControls.PlaceHolder
|
||||
{
|
||||
private readonly bool _allowModification;
|
||||
|
||||
private GenericProperty _gp;
|
||||
private cms.businesslogic.propertytype.PropertyType _pt;
|
||||
private cms.businesslogic.ContentType.TabI[] _tabs;
|
||||
private cms.businesslogic.datatype.DataTypeDefinition[] _dtds;
|
||||
private int _tabId;
|
||||
private string _fullId = "";
|
||||
private GenericProperty _gp;
|
||||
private cms.businesslogic.ContentType.TabI[] _tabs;
|
||||
private cms.businesslogic.datatype.DataTypeDefinition[] _dtds;
|
||||
private int _tabId;
|
||||
private string _fullId = "";
|
||||
|
||||
public event System.EventHandler Delete;
|
||||
public event EventHandler Delete;
|
||||
|
||||
public cms.businesslogic.propertytype.PropertyType PropertyType
|
||||
{
|
||||
set {_pt = value;}
|
||||
get {return _pt;}
|
||||
}
|
||||
public int TabId
|
||||
{
|
||||
set {_tabId = value;}
|
||||
}
|
||||
public PropertyType PropertyType { get; set; }
|
||||
|
||||
public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions
|
||||
{
|
||||
set
|
||||
{
|
||||
_dtds = value;
|
||||
}
|
||||
}
|
||||
public cms.businesslogic.web.DocumentType.TabI[] Tabs
|
||||
{
|
||||
set
|
||||
{
|
||||
_tabs = value;
|
||||
}
|
||||
}
|
||||
public int TabId
|
||||
{
|
||||
set { _tabId = value; }
|
||||
}
|
||||
|
||||
public string FullId
|
||||
{
|
||||
set
|
||||
{
|
||||
_fullId = value;
|
||||
}
|
||||
}
|
||||
public cms.businesslogic.datatype.DataTypeDefinition[] DataTypeDefinitions
|
||||
{
|
||||
set { _dtds = value; }
|
||||
}
|
||||
|
||||
public GenericProperty GenricPropertyControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _gp;
|
||||
}
|
||||
}
|
||||
public cms.businesslogic.web.DocumentType.TabI[] Tabs
|
||||
{
|
||||
set { _tabs = value; }
|
||||
}
|
||||
|
||||
public GenericPropertyWrapper()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
public string FullId
|
||||
{
|
||||
set { _fullId = value; }
|
||||
}
|
||||
|
||||
public void UpdateEditControl()
|
||||
{
|
||||
if (this.Controls.Count == 1)
|
||||
{
|
||||
System.Web.UI.Control u = this.Controls[0];
|
||||
u.ID = this.ID + "_control";
|
||||
_gp = (GenericProperty) u;
|
||||
_gp.PropertyType = _pt;
|
||||
_gp.DataTypeDefinitions = _dtds;
|
||||
_gp.Tabs = _tabs;
|
||||
_gp.TabId = _tabId;
|
||||
_gp.FullId = _fullId;
|
||||
}
|
||||
}
|
||||
public GenericProperty GenricPropertyControl
|
||||
{
|
||||
get { return _gp; }
|
||||
}
|
||||
|
||||
protected void GenericPropertyWrapper_Delete(object sender, System.EventArgs e)
|
||||
{
|
||||
Delete(this,new System.EventArgs());
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit (e);
|
||||
System.Web.UI.Control u = new System.Web.UI.UserControl().LoadControl(SystemDirectories.Umbraco + "/controls/genericProperties/GenericProperty.ascx");
|
||||
u.ID = this.ID + "_control";
|
||||
((GenericProperty) u).Delete += new EventHandler(GenericPropertyWrapper_Delete);
|
||||
((GenericProperty) u).FullId = _fullId;
|
||||
this.Controls.Add(u);
|
||||
UpdateEditControl();
|
||||
}
|
||||
public GenericPropertyWrapper()
|
||||
: this(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GenericPropertyWrapper(bool allowModification)
|
||||
{
|
||||
_allowModification = allowModification;
|
||||
}
|
||||
|
||||
public void UpdateEditControl()
|
||||
{
|
||||
if (Controls.Count == 1)
|
||||
{
|
||||
var u = Controls[0];
|
||||
u.ID = ID + "_control";
|
||||
_gp = (GenericProperty)u;
|
||||
_gp.PropertyType = PropertyType;
|
||||
_gp.DataTypeDefinitions = _dtds;
|
||||
_gp.Tabs = _tabs;
|
||||
_gp.TabId = _tabId;
|
||||
_gp.FullId = _fullId;
|
||||
}
|
||||
}
|
||||
|
||||
protected void GenericPropertyWrapper_Delete(object sender, EventArgs e)
|
||||
{
|
||||
Delete(this, new EventArgs());
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
var u = (GenericProperty)Page.LoadControl(SystemDirectories.Umbraco + "/controls/genericProperties/GenericProperty.ascx");
|
||||
u.AllowPropertyEdit = _allowModification;
|
||||
|
||||
u.ID = ID + "_control";
|
||||
|
||||
if (_allowModification)
|
||||
{
|
||||
u.Delete += GenericPropertyWrapper_Delete;
|
||||
}
|
||||
|
||||
u.FullId = _fullId;
|
||||
Controls.Add(u);
|
||||
UpdateEditControl();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace umbraco.cms.presentation.members
|
||||
if (Membership.Provider.IsUmbracoMembershipProvider())
|
||||
{
|
||||
_document = new Member(int.Parse(Request.QueryString["id"]));
|
||||
|
||||
_member = Membership.GetUser(_document.LoginName, false);
|
||||
_contentControl = new ContentControl(_document, ContentControl.publishModes.NoPublish, "TabView1");
|
||||
_contentControl.Width = Unit.Pixel(666);
|
||||
|
||||
@@ -3,12 +3,16 @@ using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using ClientDependency.Core;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using umbraco.controls;
|
||||
|
||||
namespace umbraco.cms.presentation.members
|
||||
{
|
||||
@@ -20,46 +24,47 @@ namespace umbraco.cms.presentation.members
|
||||
CurrentApp = BusinessLogic.DefaultApps.member.ToString();
|
||||
|
||||
}
|
||||
protected System.Web.UI.WebControls.PlaceHolder plc;
|
||||
private cms.businesslogic.member.MemberType dt;
|
||||
protected PlaceHolder plc;
|
||||
private businesslogic.member.MemberType _dt;
|
||||
|
||||
private System.Collections.ArrayList ExtraPropertyTypeInfos = new System.Collections.ArrayList();
|
||||
protected global::umbraco.controls.ContentTypeControlNew ContentTypeControlNew1;
|
||||
private ArrayList _extraPropertyTypeInfos = new ArrayList();
|
||||
protected controls.ContentTypeControlNew ContentTypeControlNew1;
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
dt = new cms.businesslogic.member.MemberType(int.Parse(Request.QueryString["id"]));
|
||||
setupExtraEditorControls();
|
||||
_dt = new cms.businesslogic.member.MemberType(int.Parse(Request.QueryString["id"]));
|
||||
SetupExtraEditorControls();
|
||||
ContentTypeControlNew1.InfoTabPage.Controls.Add(Pane1andmore);
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
ClientTools
|
||||
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadMemberTypes>().Tree.Alias)
|
||||
.SyncTree(dt.Id.ToString(), false);
|
||||
.SyncTree(_dt.Id.ToString(), false);
|
||||
}
|
||||
|
||||
}
|
||||
protected override bool OnBubbleEvent(object source, EventArgs args)
|
||||
{
|
||||
bool handled = false;
|
||||
if (args is controls.SaveClickEventArgs)
|
||||
var handled = false;
|
||||
var eventArgs = args as SaveClickEventArgs;
|
||||
if (eventArgs != null)
|
||||
{
|
||||
controls.SaveClickEventArgs e = (controls.SaveClickEventArgs) args;
|
||||
var e = eventArgs;
|
||||
if (e.Message == "Saved")
|
||||
{
|
||||
saveExtras();
|
||||
|
||||
ClientTools
|
||||
.ShowSpeechBubble(speechBubbleIcon.save, "Membertype saved", "")
|
||||
.SyncTree(dt.Id.ToString(), true);
|
||||
.SyncTree(_dt.Id.ToString(CultureInfo.InvariantCulture), true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientTools
|
||||
.ShowSpeechBubble(e.IconType, e.Message, "")
|
||||
.SyncTree(dt.Id.ToString(), true);
|
||||
.SyncTree(_dt.Id.ToString(CultureInfo.InvariantCulture), true);
|
||||
|
||||
}
|
||||
handled = true;
|
||||
@@ -67,69 +72,54 @@ namespace umbraco.cms.presentation.members
|
||||
|
||||
return handled;
|
||||
}
|
||||
private void setupExtraEditorControls(){
|
||||
DataTable dt1 = new DataTable();
|
||||
dt1.Columns.Add("id");
|
||||
dt1.Columns.Add("name");
|
||||
dt1.Columns.Add("canedit");
|
||||
dt1.Columns.Add("canview");
|
||||
|
||||
foreach (cms.businesslogic.propertytype.PropertyType pt in dt.PropertyTypes)
|
||||
{
|
||||
DataRow dr = dt1.NewRow();
|
||||
dr["name"] = pt.Name;
|
||||
dr["id"] = pt.Id;
|
||||
dt1.Rows.Add(dr);
|
||||
}
|
||||
dgEditExtras.DataSource = dt1;
|
||||
dgEditExtras.DataBind();
|
||||
}
|
||||
private void SetupExtraEditorControls()
|
||||
{
|
||||
var dt1 = new DataTable();
|
||||
dt1.Columns.Add("id");
|
||||
dt1.Columns.Add("name");
|
||||
dt1.Columns.Add("canedit");
|
||||
dt1.Columns.Add("canview");
|
||||
|
||||
protected void saveExtras() {
|
||||
foreach (DataGridItem dgi in dgEditExtras.Items) {
|
||||
if(dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
cms.businesslogic.propertytype.PropertyType pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(dgi.Cells[0].Text));
|
||||
dt.setMemberCanEdit(pt,((CheckBox)dgi.FindControl("ckbMemberCanEdit")).Checked);
|
||||
dt.setMemberViewOnProfile(pt,((CheckBox)dgi.FindControl("ckbMemberCanView")).Checked);
|
||||
dt.Save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
protected void dgEditExtras_itemdatabound(object sender,DataGridItemEventArgs e)
|
||||
//filter out the 'built-in' property types as we don't want to display these options for them
|
||||
var builtIns = Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray();
|
||||
var propTypes = _dt.PropertyTypes.Where(x => builtIns.Contains(x.Alias) == false);
|
||||
|
||||
foreach (var pt in propTypes)
|
||||
{
|
||||
var dr = dt1.NewRow();
|
||||
dr["name"] = pt.Name;
|
||||
dr["id"] = pt.Id;
|
||||
dt1.Rows.Add(dr);
|
||||
}
|
||||
dgEditExtras.DataSource = dt1;
|
||||
dgEditExtras.DataBind();
|
||||
}
|
||||
|
||||
protected void saveExtras()
|
||||
{
|
||||
foreach (DataGridItem dgi in dgEditExtras.Items)
|
||||
{
|
||||
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
var pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(dgi.Cells[0].Text));
|
||||
_dt.setMemberCanEdit(pt, ((CheckBox) dgi.FindControl("ckbMemberCanEdit")).Checked);
|
||||
_dt.setMemberViewOnProfile(pt, ((CheckBox) dgi.FindControl("ckbMemberCanView")).Checked);
|
||||
_dt.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void dgEditExtras_itemdatabound(object sender,DataGridItemEventArgs e)
|
||||
{
|
||||
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
cms.businesslogic.propertytype.PropertyType pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(((DataRowView)e.Item.DataItem).Row["id"].ToString()));
|
||||
((CheckBox)e.Item.FindControl("ckbMemberCanEdit")).Checked = dt.MemberCanEdit(pt);
|
||||
((CheckBox)e.Item.FindControl("ckbMemberCanView")).Checked = dt.ViewOnProfile(pt);
|
||||
var pt = cms.businesslogic.propertytype.PropertyType.GetPropertyType(int.Parse(((DataRowView)e.Item.DataItem).Row["id"].ToString()));
|
||||
((CheckBox)e.Item.FindControl("ckbMemberCanEdit")).Checked = _dt.MemberCanEdit(pt);
|
||||
((CheckBox)e.Item.FindControl("ckbMemberCanView")).Checked = _dt.ViewOnProfile(pt);
|
||||
}
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user