diff --git a/build/Build.bat b/build/Build.bat
index 0d08fab10d..966fcdb84f 100644
--- a/build/Build.bat
+++ b/build/Build.bat
@@ -1,5 +1,5 @@
@ECHO OFF
-SET release=6.0.1
+SET release=6.0.2
SET comment=
SET version=%release%
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixZeroOne/UpdatePropertyTypesAndGroups.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixZeroOne/UpdatePropertyTypesAndGroups.cs
index e599ebe1be..6cc1013fb6 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixZeroOne/UpdatePropertyTypesAndGroups.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixZeroOne/UpdatePropertyTypesAndGroups.cs
@@ -5,7 +5,7 @@ using Umbraco.Core.Models.Rdbms;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixZeroOne
{
- [Migration("6.0.1", 0, GlobalSettings.UmbracoMigrationName)]
+ [Migration("6.0.2", 0, GlobalSettings.UmbracoMigrationName)]
public class UpdatePropertyTypesAndGroups : MigrationBase
{
public override void Up()
@@ -41,6 +41,9 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixZeroOne
};
int id = Convert.ToInt16(database.Insert(propertyGroup));
+ propertyGroup.Id = id;
+ propertyGroups.Add(propertyGroup);
+
propertyType.PropertyTypeGroupId = id;
database.Update(propertyType);
}
diff --git a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs
index 0cdade3486..30d8aabccf 100644
--- a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs
+++ b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs
@@ -20,22 +20,22 @@ namespace umbraco.editorControls.XPathDropDownList
///
/// Field for the data.
///
- private IData m_Data;
+ private IData data;
///
/// Field for the options.
///
- private XPathDropDownListOptions m_Options;
+ private XPathDropDownListOptions options;
///
/// Field for the CustomValidator.
///
- private CustomValidator m_CustomValidator = new CustomValidator();
+ private CustomValidator customValidator = new CustomValidator();
///
/// Field for the DropDownList.
///
- private DropDownList m_DropDownList = new DropDownList();
+ private DropDownList dropDownList = new DropDownList();
///
/// Gets a value indicating whether [treat as rich text editor].
@@ -82,8 +82,8 @@ namespace umbraco.editorControls.XPathDropDownList
///
internal XPathDropDownListDataEditor(IData data, XPathDropDownListOptions options)
{
- this.m_Data = data;
- this.m_Options = options;
+ this.data = data;
+ this.options = options;
}
///
@@ -91,16 +91,34 @@ namespace umbraco.editorControls.XPathDropDownList
///
protected override void CreateChildControls()
{
- this.m_DropDownList.DataSource = uQuery.GetNodesByXPath(this.m_Options.XPath).ToNameIds();
- this.m_DropDownList.DataTextField = "Value";
- this.m_DropDownList.DataValueField = this.m_Options.UseId ? "Key" : "Value";
- this.m_DropDownList.DataBind();
+ switch (this.options.UmbracoObjectType)
+ {
+ case uQuery.UmbracoObjectType.Unknown:
+ case uQuery.UmbracoObjectType.Document:
+
+ this.dropDownList.DataSource = uQuery.GetNodesByXPath(this.options.XPath).Where(x => x.Id != -1).ToNameIds();
+ break;
+
+ case uQuery.UmbracoObjectType.Media:
+
+ this.dropDownList.DataSource = uQuery.GetMediaByXPath(this.options.XPath).Where(x => x.Id != -1).ToNameIds();
+ break;
+
+ case uQuery.UmbracoObjectType.Member:
+
+ this.dropDownList.DataSource = uQuery.GetMembersByXPath(this.options.XPath).ToNameIds();
+ break;
+ }
+
+ this.dropDownList.DataTextField = "Value";
+ this.dropDownList.DataValueField = this.options.UseId ? "Key" : "Value";
+ this.dropDownList.DataBind();
// Add a default please select value
- this.m_DropDownList.Items.Insert(0, new ListItem(string.Concat(ui.Text("choose"), "..."), "-1"));
+ this.dropDownList.Items.Insert(0, new ListItem(string.Concat(ui.Text("choose"), "..."), "-1"));
- this.Controls.Add(this.m_CustomValidator);
- this.Controls.Add(this.m_DropDownList);
+ this.Controls.Add(this.customValidator);
+ this.Controls.Add(this.dropDownList);
}
///
@@ -112,10 +130,10 @@ namespace umbraco.editorControls.XPathDropDownList
base.OnLoad(e);
this.EnsureChildControls();
- if (!this.Page.IsPostBack)
+ if (!this.Page.IsPostBack && this.data.Value != null)
{
// Get selected items from Node Name or Node Id
- var dropDownListItem = this.m_DropDownList.Items.FindByValue(this.m_Data.Value.ToString());
+ var dropDownListItem = this.dropDownList.Items.FindByValue(this.data.Value.ToString());
if (dropDownListItem != null)
{
dropDownListItem.Selected = true;
@@ -128,22 +146,22 @@ namespace umbraco.editorControls.XPathDropDownList
///
public void Save()
{
- Property property = new Property(((umbraco.cms.businesslogic.datatype.DefaultData)this.m_Data).PropertyId);
- if (property.PropertyType.Mandatory && this.m_DropDownList.SelectedValue == "-1")
+ Property property = new Property(((umbraco.cms.businesslogic.datatype.DefaultData)this.data).PropertyId);
+ if (property.PropertyType.Mandatory && this.dropDownList.SelectedValue == "-1")
{
// Property is mandatory, but no value selected in the DropDownList
- this.m_CustomValidator.IsValid = false;
+ this.customValidator.IsValid = false;
DocumentType documentType = new DocumentType(property.PropertyType.ContentTypeId);
ContentType.TabI tab = documentType.getVirtualTabs.Where(x => x.Id == property.PropertyType.TabId).FirstOrDefault();
if (tab != null)
{
- this.m_CustomValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatory", new string[] { property.PropertyType.Alias, tab.Caption }, User.GetCurrent());
+ this.customValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatory", new string[] { property.PropertyType.Alias, tab.Caption }, User.GetCurrent());
}
}
- this.m_Data.Value = this.m_DropDownList.SelectedValue;
+ this.data.Value = this.dropDownList.SelectedValue;
}
}
}
diff --git a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListOptions.cs b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListOptions.cs
index 514fbfca90..a47a37f583 100644
--- a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListOptions.cs
+++ b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListOptions.cs
@@ -1,25 +1,63 @@
-
+using System;
+using System.ComponentModel;
+
namespace umbraco.editorControls.XPathDropDownList
{
- internal class XPathDropDownListOptions
- {
- ///
- /// XPath string used to get Nodes to be used as CheckBox options in a CheckBoxList
+ internal class XPathDropDownListOptions : AbstractOptions
+ {
+ private string type = null;
+
+ ///
+ ///
///
+ public string Type
+ {
+ get
+ {
+ // null check for the type, as older versions of this data type won't have this value stored
+ if (this.type == null)
+ {
+ return uQuery.UmbracoObjectType.Document.GetGuid().ToString();
+ }
+
+ return this.type;
+ }
+
+ set
+ {
+ this.type = value;
+ }
+ }
+
+ ///
+ /// XPath string used to get Nodes to be used as CheckBox options in a CheckBoxList
+ ///
+ [DefaultValue("//*")]
public string XPath { get; set; }
///
/// Defaults to true, where property value is a csv of NodeIds, else if false, then csv of Node names is stored
///
+ [DefaultValue(true)]
public bool UseId { get; set; }
+
+ ///
+ /// Gets the UmbracoObjectType from the stored string guid
+ ///
+ /// a Document, Media or Member
+ public uQuery.UmbracoObjectType UmbracoObjectType
+ {
+ get
+ {
+ return uQuery.GetUmbracoObjectType(new Guid(this.Type));
+ }
+ }
///
/// Initializes an instance of XPathDropDownListOptions
///
- public XPathDropDownListOptions()
+ public XPathDropDownListOptions() : base(true)
{
- this.XPath = string.Empty;
- this.UseId = true; // Default to storing Node Id
- }
- }
+ }
+ }
}
diff --git a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs
index 82ee7c15a4..618fca66a7 100644
--- a/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs
+++ b/src/umbraco.editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs
@@ -9,6 +9,11 @@ namespace umbraco.editorControls.XPathDropDownList
{
class XPathDropDownListPreValueEditor : AbstractJsonPrevalueEditor
{
+ ///
+ /// Radio buttons to select type of node to pick from: Content / Media / Members
+ ///
+ private RadioButtonList typeRadioButtonList = new RadioButtonList();
+
///
/// TextBox control to get the XPath expression
///
@@ -20,7 +25,7 @@ namespace umbraco.editorControls.XPathDropDownList
private RequiredFieldValidator xPathRequiredFieldValidator = new RequiredFieldValidator();
///
- /// Server side validation of XPath expression, to ensure some nodes are returned
+ /// Server side validation of XPath expression
///
private CustomValidator xPathCustomValidator = new CustomValidator();
@@ -71,6 +76,11 @@ namespace umbraco.editorControls.XPathDropDownList
///
protected override void CreateChildControls()
{
+ //radio buttons to select type of nodes that can be picked (Document, Media or Member)
+ this.typeRadioButtonList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Document.GetFriendlyName(), uQuery.UmbracoObjectType.Document.GetGuid().ToString()));
+ this.typeRadioButtonList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Media.GetFriendlyName(), uQuery.UmbracoObjectType.Media.GetGuid().ToString()));
+ this.typeRadioButtonList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Member.GetFriendlyName(), uQuery.UmbracoObjectType.Member.GetGuid().ToString()));
+
this.xPathTextBox.ID = "xPathTextBox";
this.xPathTextBox.CssClass = "umbEditorTextField";
@@ -80,16 +90,18 @@ namespace umbraco.editorControls.XPathDropDownList
this.xPathCustomValidator.ControlToValidate = this.xPathTextBox.ID;
this.xPathCustomValidator.Display = ValidatorDisplay.Dynamic;
- this.xPathCustomValidator.ServerValidate += new ServerValidateEventHandler(XPathCustomValidator_ServerValidate);
+ this.xPathCustomValidator.ServerValidate += new ServerValidateEventHandler(this.XPathCustomValidator_ServerValidate);
this.valueTypeDropDownList.ID = "valueTypeDropDownList";
this.valueTypeDropDownList.Items.Add(new ListItem("Node Id", bool.TrueString));
this.valueTypeDropDownList.Items.Add(new ListItem("Node Name", bool.FalseString));
- this.Controls.Add(this.xPathTextBox);
- this.Controls.Add(this.xPathRequiredFieldValidator);
- this.Controls.Add(this.xPathCustomValidator);
- this.Controls.Add(this.valueTypeDropDownList);
+ this.Controls.AddPrevalueControls(
+ this.typeRadioButtonList,
+ this.xPathTextBox,
+ this.xPathRequiredFieldValidator,
+ this.xPathCustomValidator,
+ this.valueTypeDropDownList);
}
///
@@ -100,16 +112,14 @@ namespace umbraco.editorControls.XPathDropDownList
{
base.OnLoad(e);
- //if (!this.Page.IsPostBack)
- //{
// Read in stored configuration values
+ this.typeRadioButtonList.SelectedValue = this.Options.Type;
this.xPathTextBox.Text = this.Options.XPath;
this.valueTypeDropDownList.SelectedValue = this.Options.UseId.ToString();
- //}
}
///
- /// Will run the entered XPath expression to ensure it returns at least 1 node
+ /// Will run the entered XPath expression to ensure it returns a collection
///
/// xPathCustomValidator
///
@@ -120,10 +130,32 @@ namespace umbraco.editorControls.XPathDropDownList
try
{
- if (uQuery.GetNodesByXPath(xPath).Count() >= 0)
+ switch (this.options.UmbracoObjectType)
{
- isValid = true;
- }
+ case uQuery.UmbracoObjectType.Document:
+ if (uQuery.GetNodesByXPath(xPath).Count() >= 0)
+ {
+ isValid = true;
+ }
+
+ break;
+
+ case uQuery.UmbracoObjectType.Media:
+ if (uQuery.GetMediaByXPath(xPath).Count() >= 0)
+ {
+ isValid = true;
+ }
+
+ break;
+
+ case uQuery.UmbracoObjectType.Member:
+ if (uQuery.GetMembersByXPath(xPath).Count() >= 0)
+ {
+ isValid = true;
+ }
+
+ break;
+ }
}
catch (XPathException)
{
@@ -140,6 +172,7 @@ namespace umbraco.editorControls.XPathDropDownList
{
if (this.Page.IsValid)
{
+ this.Options.Type = this.typeRadioButtonList.SelectedValue;
this.Options.XPath = this.xPathTextBox.Text;
this.Options.UseId = bool.Parse(this.valueTypeDropDownList.SelectedValue);
@@ -153,11 +186,22 @@ namespace umbraco.editorControls.XPathDropDownList
///
protected override void RenderContents(HtmlTextWriter writer)
{
- writer.AddPrevalueRow("XPath Expression", @"can use the tokens $ancestorOrSelf, $parentPage and $currentPage, eg.
-
- all siblings: $parentPage//*[@id != $currentPage/@id]
- ", this.xPathTextBox, this.xPathRequiredFieldValidator, this.xPathCustomValidator);
- writer.AddPrevalueRow("Value", this.valueTypeDropDownList);
+ writer.AddPrevalueRow(
+ "Type",
+ "the xml schema to query",
+ this.typeRadioButtonList);
+
+ writer.AddPrevalueRow(
+ "XPath Expression",
+ "can use the tokens $ancestorOrSelf, $parentPage and $currentPage",
+ this.xPathTextBox,
+ this.xPathRequiredFieldValidator,
+ this.xPathCustomValidator);
+
+ writer.AddPrevalueRow(
+ "Value",
+ "store the node id or the name",
+ this.valueTypeDropDownList);
}
}