Fixes issue related to moving PropertyTypes between tabs.

Ensures that the right tabs with the right ids are loaded in the dropdown.
This commit is contained in:
Morten Christensen
2013-02-26 13:31:29 -01:00
parent e9b2261aab
commit fef96e8b43
5 changed files with 52 additions and 14 deletions

View File

@@ -258,7 +258,7 @@ namespace Umbraco.Core.Persistence.Repositories
//unless the PropertyGroupId has already been changed.
foreach (var propertyType in propertyGroup.PropertyTypes)
{
if(propertyType.IsPropertyDirty("PropertyGroupId") == false)
if ((propertyType.IsPropertyDirty("PropertyGroupId") && propertyType.PropertyGroupId == 0) == false)
propertyType.PropertyGroupId = propertyGroup.Id;
}
}

View File

@@ -405,6 +405,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gp = new GenericPropertyWrapper();
gp.ID = "GenericPropertyNew";
gp.Tabs = tabs;
gp.PropertyGroups = propertyTypeGroups;
gp.DataTypeDefinitions = dtds;
PropertyTypeNew.Controls.Add(gp);
PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
@@ -414,6 +415,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1];
gp.ID = "GenericPropertyNew";
gp.Tabs = tabs;
gp.PropertyGroups = propertyTypeGroups;
gp.DataTypeDefinitions = dtds;
gp.UpdateEditControl();
gp.GenricPropertyControl.UpdateInterface();
@@ -435,14 +437,18 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
? tab.GetPropertyTypes(_contentType.Id, false)
: propertyGroup.GetPropertyTypes();
var propertyGroupId = tab.Id;
if (propertyGroup != null && propertyGroup.ParentId > 0)
propertyGroupId = propertyGroup.Id;
if (propertyTypes.Any())
{
var propSort = new HtmlInputHidden();
propSort.ID = "propSort_" + tab.Id.ToString() + "_Content";
propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content";
PropertyTypes.Controls.Add(propSort);
_sortLists.Add(propSort);
PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + tab.Id.ToString() + "_Contents\">"));
PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + propertyGroupId.ToString() + "_Contents\">"));
foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
{
@@ -453,10 +459,11 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gpw.ID = "gpw_" + pt.Id;
gpw.PropertyType = pt;
gpw.Tabs = tabs;
gpw.TabId = tab.Id;
gp.PropertyGroups = propertyTypeGroups;
gpw.TabId = propertyGroupId;
gpw.DataTypeDefinitions = dtds;
gpw.Delete += new EventHandler(gpw_Delete);
gpw.FullId = "t_" + tab.Id.ToString() + "_Contents_" + +pt.Id;
gpw.FullId = "t_" + propertyGroupId.ToString() + "_Contents_" + +pt.Id;
PropertyTypes.Controls.Add(gpw);
_genericProperties.Add(gpw);
@@ -528,6 +535,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
gpw.PropertyType = pt;
gpw.Tabs = tabs;
gpw.PropertyGroups = propertyTypeGroups;
gpw.DataTypeDefinitions = dtds;
gpw.Delete += new EventHandler(gpw_Delete);
gpw.FullId = "t_general_Contents_" + pt.Id;

View File

@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web.UI.WebControls;
using ClientDependency.Core;
using umbraco.BasePages;
using umbraco.IO;
using umbraco.cms.businesslogic.propertytype;
namespace umbraco.controls.GenericProperties
{
@@ -101,7 +105,9 @@ namespace umbraco.controls.GenericProperties
}
private int _id;
public int Id {
private List<PropertyTypeGroup> _propertyGroups;
public int Id {
set {
_id = value;
}get{
@@ -114,7 +120,13 @@ namespace umbraco.controls.GenericProperties
get {return int.Parse(ddlTypes.SelectedValue);}
}
public void Clear()
public List<PropertyTypeGroup> PropertyGroups
{
get { return _propertyGroups; }
set { _propertyGroups = value; }
}
public void Clear()
{
tbName.Text = "";
tbAlias.Text = "";
@@ -129,10 +141,8 @@ namespace umbraco.controls.GenericProperties
{
if (!IsPostBack)
{
UpdateInterface();
}
}
public void UpdateInterface()
@@ -182,7 +192,18 @@ namespace umbraco.controls.GenericProperties
}
// tabs
if (_tabs != null)
if (_propertyGroups != null)
{
ddlTab.Items.Clear();
foreach (var propertyGroup in _propertyGroups.OrderBy(x => x.SortOrder))
{
var li = new ListItem(propertyGroup.Name, propertyGroup.Id.ToString(CultureInfo.InvariantCulture));
if (propertyGroup.Id == _tabId)
li.Selected = true;
ddlTab.Items.Add(li);
}
}
else if (_tabs != null)
{
ddlTab.Items.Clear();
for (int i=0;i<_tabs.Length;i++)

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using umbraco.IO;
using umbraco.cms.businesslogic.propertytype;
namespace umbraco.controls.GenericProperties
{
@@ -15,8 +17,9 @@ namespace umbraco.controls.GenericProperties
private cms.businesslogic.datatype.DataTypeDefinition[] _dtds;
private int _tabId;
private string _fullId = "";
private List<PropertyTypeGroup> _propertyGroups;
public event System.EventHandler Delete;
public event System.EventHandler Delete;
public cms.businesslogic.propertytype.PropertyType PropertyType
{
@@ -59,7 +62,12 @@ namespace umbraco.controls.GenericProperties
}
}
public GenericPropertyWrapper()
public List<PropertyTypeGroup> PropertyGroups
{
set { _propertyGroups = value; }
}
public GenericPropertyWrapper()
{
//
// TODO: Add constructor logic here
@@ -76,6 +84,7 @@ namespace umbraco.controls.GenericProperties
_gp.PropertyType = _pt;
_gp.DataTypeDefinitions = _dtds;
_gp.Tabs = _tabs;
_gp.PropertyGroups = _propertyGroups;
_gp.TabId = _tabId;
_gp.FullId = _fullId;
}

View File

@@ -62,8 +62,8 @@ namespace umbraco.editorControls
base.DataSource = dropdownData;
base.DataBind();
base.Items.Insert(0, new ListItem(ui.Text("choose") + "...",""));
base.SelectedValue = _data.Value.ToString();
base.SelectedValue = _data.Value != null ? _data.Value.ToString() : "";
// Iterate on the control items and mark fields by match them with the Text property!
//foreach(ListItem li in base.Items)