Merge with 6.0.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@ECHO OFF
|
||||
SET release=6.0.1
|
||||
SET release=6.0.2
|
||||
SET comment=
|
||||
SET version=%release%
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
/// <summary>
|
||||
/// Field for the data.
|
||||
/// </summary>
|
||||
private IData m_Data;
|
||||
private IData data;
|
||||
|
||||
/// <summary>
|
||||
/// Field for the options.
|
||||
/// </summary>
|
||||
private XPathDropDownListOptions m_Options;
|
||||
private XPathDropDownListOptions options;
|
||||
|
||||
/// <summary>
|
||||
/// Field for the CustomValidator.
|
||||
/// </summary>
|
||||
private CustomValidator m_CustomValidator = new CustomValidator();
|
||||
private CustomValidator customValidator = new CustomValidator();
|
||||
|
||||
/// <summary>
|
||||
/// Field for the DropDownList.
|
||||
/// </summary>
|
||||
private DropDownList m_DropDownList = new DropDownList();
|
||||
private DropDownList dropDownList = new DropDownList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [treat as rich text editor].
|
||||
@@ -82,8 +82,8 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
/// <param name="options"></param>
|
||||
internal XPathDropDownListDataEditor(IData data, XPathDropDownListOptions options)
|
||||
{
|
||||
this.m_Data = data;
|
||||
this.m_Options = options;
|
||||
this.data = data;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,16 +91,34 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,63 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace umbraco.editorControls.XPathDropDownList
|
||||
{
|
||||
internal class XPathDropDownListOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// XPath string used to get Nodes to be used as CheckBox options in a CheckBoxList
|
||||
internal class XPathDropDownListOptions : AbstractOptions
|
||||
{
|
||||
private string type = null;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// XPath string used to get Nodes to be used as CheckBox options in a CheckBoxList
|
||||
/// </summary>
|
||||
[DefaultValue("//*")]
|
||||
public string XPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to true, where property value is a csv of NodeIds, else if false, then csv of Node names is stored
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool UseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UmbracoObjectType from the stored string guid
|
||||
/// </summary>
|
||||
/// <value>a Document, Media or Member</value>
|
||||
public uQuery.UmbracoObjectType UmbracoObjectType
|
||||
{
|
||||
get
|
||||
{
|
||||
return uQuery.GetUmbracoObjectType(new Guid(this.Type));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of XPathDropDownListOptions
|
||||
/// </summary>
|
||||
public XPathDropDownListOptions()
|
||||
public XPathDropDownListOptions() : base(true)
|
||||
{
|
||||
this.XPath = string.Empty;
|
||||
this.UseId = true; // Default to storing Node Id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
{
|
||||
class XPathDropDownListPreValueEditor : AbstractJsonPrevalueEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Radio buttons to select type of node to pick from: Content / Media / Members
|
||||
/// </summary>
|
||||
private RadioButtonList typeRadioButtonList = new RadioButtonList();
|
||||
|
||||
/// <summary>
|
||||
/// TextBox control to get the XPath expression
|
||||
/// </summary>
|
||||
@@ -20,7 +25,7 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
private RequiredFieldValidator xPathRequiredFieldValidator = new RequiredFieldValidator();
|
||||
|
||||
/// <summary>
|
||||
/// Server side validation of XPath expression, to ensure some nodes are returned
|
||||
/// Server side validation of XPath expression
|
||||
/// </summary>
|
||||
private CustomValidator xPathCustomValidator = new CustomValidator();
|
||||
|
||||
@@ -71,6 +76,11 @@ namespace umbraco.editorControls.XPathDropDownList
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="source">xPathCustomValidator</param>
|
||||
/// <param name="args"></param>
|
||||
@@ -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
|
||||
/// <param name="writer"></param>
|
||||
protected override void RenderContents(HtmlTextWriter writer)
|
||||
{
|
||||
writer.AddPrevalueRow("XPath Expression", @"can use the tokens <strong>$ancestorOrSelf</strong>, <strong>$parentPage</strong> and <strong>$currentPage</strong>, eg.<br />
|
||||
<br />
|
||||
all siblings: $parentPage//*[@id != $currentPage/@id] <br />
|
||||
", 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 <strong>$ancestorOrSelf</strong>, <strong>$parentPage</strong> and <strong>$currentPage</strong>",
|
||||
this.xPathTextBox,
|
||||
this.xPathRequiredFieldValidator,
|
||||
this.xPathCustomValidator);
|
||||
|
||||
writer.AddPrevalueRow(
|
||||
"Value",
|
||||
"store the node id or the name",
|
||||
this.valueTypeDropDownList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user