Merge branch 'wip-changedoctypeui' of https://github.com/AndyButland/Umbraco-CMS into AndyButland-wip-changedoctypeui
Conflicts: .gitignore src/Umbraco.Web.UI/Umbraco.Web.UI.csproj src/Umbraco.Web.UI/config/ClientDependency.config src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
@@ -454,6 +454,13 @@
|
||||
<Compile Include="Umbraco\Developer\Python\EditPython.aspx.designer.cs">
|
||||
<DependentUpon>editPython.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Dialogs\ChangeDocType.aspx.cs">
|
||||
<DependentUpon>ChangeDocType.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Dialogs\ChangeDocType.aspx.designer.cs">
|
||||
<DependentUpon>ChangeDocType.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Dialogs\EditMacro.aspx.cs">
|
||||
<DependentUpon>EditMacro.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -663,6 +670,9 @@
|
||||
<Content Include="Umbraco\Developer\RelationTypes\TreeMenu\ActionDeleteRelationType.js" />
|
||||
<Content Include="Umbraco\Developer\RelationTypes\TreeMenu\ActionNewRelationType.js" />
|
||||
<Content Include="Umbraco\Dialogs\AssignDomain2.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\ChangeDocType.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="Umbraco\Dialogs\EditMacro.aspx" />
|
||||
<Content Include="Umbraco\Images\delete.gif" />
|
||||
<Content Include="Umbraco\Images\delete.png" />
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<key alias="assignDomain">Culture and Hostnames</key>
|
||||
<key alias="auditTrail">Audit Trail</key>
|
||||
<key alias="browse">Browse Node</key>
|
||||
<key alias="changeDocType">Change Document Type</key>
|
||||
<key alias="copy">Copy</key>
|
||||
<key alias="create">Create</key>
|
||||
<key alias="createPackage">Create Package</key>
|
||||
@@ -92,6 +93,26 @@
|
||||
<key alias="styleShow">Show styles</key>
|
||||
<key alias="tableInsert">Insert table</key>
|
||||
</area>
|
||||
<area alias="changeDocType">
|
||||
<key alias="changeDocTypeInstruction">To change the document type for the selected content, first select from the list of valid types for this location.</key>
|
||||
<key alias="changeDocTypeInstruction2">Then confirm and/or amend the mapping of properties from the current type to the new, and click Save.</key>
|
||||
<key alias="contentRepublished">The content has been re-published.</key>
|
||||
<key alias="currentProperty">Current Property</key>
|
||||
<key alias="currentType">Current type</key>
|
||||
<key alias="docTypeCannotBeChanged">The document type cannot be changed, as there are no alternatives valid for this location.</key>
|
||||
<key alias="docTypeChanged">Document Type Changed</key>
|
||||
<key alias="mapProperties">Map Properties</key>
|
||||
<key alias="mapToProperty">Map to Property</key>
|
||||
<key alias="newTemplate">New Template</key>
|
||||
<key alias="newType">New Type</key>
|
||||
<key alias="none">none</key>
|
||||
<key alias="selectedContent">Content</key>
|
||||
<key alias="selectNewDocType">Select New Document Type</key>
|
||||
<key alias="successMessage">The document type of the selected content has been successfully changed to [new type] and the following properties mapped:</key>
|
||||
<key alias="to">to</key>
|
||||
<key alias="validationErrorPropertyWithMoreThanOneMapping">Could not complete property mapping as one or more properties have more than one mapping defined.</key>
|
||||
<key alias="validDocTypesNote">Only alternate types valid for the current location are displayed.</key>
|
||||
</area>
|
||||
<area alias="content">
|
||||
<key alias="about">About this page</key>
|
||||
<key alias="alias">Alias</key>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<key alias="assignDomain">Manage hostnames</key>
|
||||
<key alias="auditTrail">Audit Trail</key>
|
||||
<key alias="browse">Browse Node</key>
|
||||
<key alias="changeDocType">Change Document Type</key>
|
||||
<key alias="copy">Copy</key>
|
||||
<key alias="create">Create</key>
|
||||
<key alias="createPackage">Create Package</key>
|
||||
@@ -79,6 +80,23 @@
|
||||
<key alias="styleShow">Show styles</key>
|
||||
<key alias="tableInsert">Insert table</key>
|
||||
</area>
|
||||
<area alias="changeDocType">
|
||||
<key alias="changeDocTypeInstruction">To change the document type for the selected content, first select from the list of valid types for this location.</key>
|
||||
<key alias="changeDocTypeInstruction2">Then confirm and/or amend the mapping of properties from the current type to the new, and click Save.</key>
|
||||
<key alias="currentProperty">Current Property</key>
|
||||
<key alias="currentType">Current type</key>
|
||||
<key alias="docTypeCannotBeChanged">The document type cannot be changed, as there are no alternatives valid for this location.</key>
|
||||
<key alias="mapProperties">Map Properties</key>
|
||||
<key alias="mapToProperty">Map to Property</key>
|
||||
<key alias="newTemplate">New Template</key>
|
||||
<key alias="newType">New Type</key>
|
||||
<key alias="none">none</key>
|
||||
<key alias="selectedContent">Content</key>
|
||||
<key alias="selectNewDocType">Select New Document Type</key>
|
||||
<key alias="successMessage">The document type of the selected content has been successfully changed and the properties mapped.</key>
|
||||
<key alias="validationErrorPropertyWithMoreThanOneMapping">Could not complete property mapping as one or more properties have more than one mapping defined.</key>
|
||||
<key alias="validDocTypesNote">Only alternate types valid for the current location are displayed.</key>
|
||||
</area>
|
||||
<area alias="content">
|
||||
<key alias="about">About this page</key>
|
||||
<key alias="alias">Alias</key>
|
||||
|
||||
118
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx
Normal file
118
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx
Normal file
@@ -0,0 +1,118 @@
|
||||
<%@ Page Language="c#" MasterPageFile="../masterpages/umbracoDialog.Master"Codebehind="ChangeDocType.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.Dialogs.ChangeDocType" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
|
||||
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
|
||||
<style type="text/css">
|
||||
#propertyMapping thead tr th{border-bottom:1px solid #ccc; padding: 4px; padding-right: 25px;
|
||||
background-image: url(<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco_client) %>/tableSorting/img/bg.gif);
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center right;
|
||||
}
|
||||
|
||||
#propertyMapping tbody tr td{border-bottom:1px solid #efefef}
|
||||
#propertyMapping td{padding: 4px; ;}
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
|
||||
<cc1:Pane runat="server" ID="ChangeDocTypePane">
|
||||
<p class="help">
|
||||
<%= umbraco.ui.Text("changeDocType", "changeDocTypeInstruction") %>
|
||||
</p>
|
||||
|
||||
<cc1:PropertyPanel ID="ContentNamePropertyPanel" runat="server">
|
||||
<asp:Label ID="ContentNameLabel" runat="server" />
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="CurrentTypePropertyPanel" runat="server">
|
||||
<asp:Label ID="CurrentTypeLabel" runat="server" />
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="NewTypePropertyPanel" runat="server">
|
||||
<asp:DropDownList ID="NewDocumentTypeList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="NewDocumentTypeList_SelectedIndexChanged" />
|
||||
<asp:RequiredFieldValidator ControlToValidate="NewDocumentTypeList" ErrorMessage="*" ID="NewDocumentTypeValidator" runat="server" Display="Dynamic" />
|
||||
<br /><small><%=umbraco.ui.Text("changeDocType", "validDocTypesNote") %></small>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel ID="NewTemplatePropertyPanel" runat="server">
|
||||
<asp:DropDownList ID="NewTemplateList" runat="server" />
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<asp:PlaceHolder ID="NotAvailablePlaceholder" runat="server" Visible="false">
|
||||
<div class="propertyItem notice" style="padding: 10px">
|
||||
<p><%=umbraco.ui.Text("changeDocType", "docTypeCannotBeChanged") %></p>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
</cc1:Pane>
|
||||
|
||||
<cc1:Pane runat="server" ID="ChangeDocTypePropertyMappingPane">
|
||||
|
||||
<p class="help">
|
||||
<%= umbraco.ui.Text("changeDocType", "changeDocTypeInstruction2") %>
|
||||
</p>
|
||||
|
||||
<asp:Repeater ID="PropertyMappingRepeater" runat="server">
|
||||
<HeaderTemplate>
|
||||
<table id="propertyMapping">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= umbraco.ui.Text("changeDocType", "currentProperty") %></th>
|
||||
<th><%= umbraco.ui.Text("changeDocType", "mapToProperty") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
<tr>
|
||||
<td>
|
||||
<%# DataBinder.Eval(Container, "DataItem.Name") %>
|
||||
<asp:HiddenField ID="Alias" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.Alias")%>' />
|
||||
<asp:HiddenField ID="Name" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.Name")%>' />
|
||||
<asp:HiddenField ID="DataTypeId" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.DataTypeId")%>' />
|
||||
</td>
|
||||
<td><asp:DropDownList id="DestinationProperty" runat="server" /></td>
|
||||
</tr>
|
||||
</ItemTemplate>
|
||||
<FooterTemplate>
|
||||
</table>
|
||||
</FooterTemplate>
|
||||
</asp:Repeater>
|
||||
</cc1:Pane>
|
||||
|
||||
<asp:PlaceHolder ID="SuccessPlaceholder" runat="server" Visible="false">
|
||||
<h2 class="propertypaneTitel"><%=umbraco.ui.Text("changeDocType", "docTypeChanged") %></h2>
|
||||
<br />
|
||||
<div class="success" style="padding: 10px">
|
||||
<asp:Literal ID="SuccessMessage" runat="server" />
|
||||
<asp:Literal ID="PropertiesMappedMessage" runat="server" />
|
||||
<asp:Literal ID="ContentPublishedMessage" runat="server" />
|
||||
<br /><br />
|
||||
<a href="#" style="color: blue" onclick="UmbClientMgr.closeModalWindow()"><%=umbraco.ui.Text("defaultdialogs", "closeThisWindow") %></a>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
|
||||
<asp:PlaceHolder ID="ValidationPlaceholder" runat="server" Visible="false">
|
||||
<br />
|
||||
<div class="notice" style="padding: 10px">
|
||||
<asp:Literal id="ValidationError" runat="server" />
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
|
||||
<asp:PlaceHolder ID="SaveAndCancelPlaceholder" runat="server">
|
||||
<br />
|
||||
<p>
|
||||
<asp:PlaceHolder ID="SavePlaceholder" runat="server">
|
||||
<asp:Button ID="ValidateAndSave" runat="server" OnClick="ValidateAndSave_Click" />
|
||||
<em> <%= umbraco.ui.Text("or") %> </em>
|
||||
</asp:PlaceHolder>
|
||||
<a href="#" style="color: blue" onclick="UmbClientMgr.closeModalWindow()"><%=umbraco.ui.Text("general", "cancel", this.getUser())%></a>
|
||||
</p>
|
||||
</asp:PlaceHolder>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
333
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx.cs
Normal file
333
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx.cs
Normal file
@@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using umbraco.BasePages;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Dialogs
|
||||
{
|
||||
public partial class ChangeDocType : UmbracoEnsuredPage
|
||||
{
|
||||
class PropertyMapping
|
||||
{
|
||||
public string FromName { get; set; }
|
||||
public string ToName { get; set; }
|
||||
public string ToAlias { get; set; }
|
||||
public object Value { get; set; }
|
||||
}
|
||||
|
||||
private IContent _content;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
var contentNodeId = int.Parse(Request.QueryString["id"]);
|
||||
_content = ApplicationContext.Current.Services.ContentService.GetById(contentNodeId);
|
||||
|
||||
LocalizeTexts();
|
||||
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
DisplayContentDetails();
|
||||
if (PopulateListOfValidAlternateDocumentTypes())
|
||||
{
|
||||
PopulateListOfTemplates();
|
||||
PopulatePropertyMappingWithSources();
|
||||
PopulatePropertyMappingWithDestinations();
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayNotAvailable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LocalizeTexts()
|
||||
{
|
||||
ChangeDocTypePane.Text = global::umbraco.ui.Text("changeDocType", "selectNewDocType");
|
||||
ContentNamePropertyPanel.Text = global::umbraco.ui.Text("changeDocType", "selectedContent");
|
||||
CurrentTypePropertyPanel.Text = global::umbraco.ui.Text("changeDocType", "currentType");
|
||||
NewTypePropertyPanel.Text = global::umbraco.ui.Text("changeDocType", "newType");
|
||||
NewTemplatePropertyPanel.Text = global::umbraco.ui.Text("changeDocType", "newTemplate");
|
||||
ChangeDocTypePropertyMappingPane.Text = global::umbraco.ui.Text("changeDocType", "mapProperties");
|
||||
ValidateAndSave.Text = global::umbraco.ui.Text("buttons", "save");
|
||||
}
|
||||
|
||||
private void DisplayContentDetails()
|
||||
{
|
||||
ContentNameLabel.Text = _content.Name;
|
||||
CurrentTypeLabel.Text = _content.ContentType.Name;
|
||||
}
|
||||
|
||||
private bool PopulateListOfValidAlternateDocumentTypes()
|
||||
{
|
||||
// Get all content types
|
||||
var documentTypes = ApplicationContext.Current.Services.ContentTypeService.GetAllContentTypes();
|
||||
|
||||
// Save a flag if the allowed at root option has been set for any document types (if not, then all are allowed there)
|
||||
var haveTypesAllowedAtRootBeenDefined = documentTypes.Any(x => x.AllowedAsRoot);
|
||||
|
||||
// Remove current one
|
||||
documentTypes = documentTypes.Where(x => x.Id != _content.ContentType.Id);
|
||||
|
||||
// Remove any not valid for current location
|
||||
if (_content.ParentId == -1 && haveTypesAllowedAtRootBeenDefined)
|
||||
{
|
||||
// Root content, and at least one type has been defined as allowed at root, so only include those that have
|
||||
// been selected as allowed
|
||||
documentTypes = documentTypes.Where(x => x.AllowedAsRoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Below root, so only include those allowed as sub-nodes for the parent
|
||||
var parentNode = ApplicationContext.Current.Services.ContentService.GetById(_content.ParentId);
|
||||
documentTypes = documentTypes.Where(x => parentNode.ContentType.AllowedContentTypes
|
||||
.Select(y => y.Id.Value)
|
||||
.Contains(x.Id));
|
||||
}
|
||||
|
||||
// If we have at least one, bind to list and return true
|
||||
if (documentTypes.Any())
|
||||
{
|
||||
NewDocumentTypeList.DataSource = documentTypes.OrderBy(x => x.Name);
|
||||
NewDocumentTypeList.DataValueField = "Id";
|
||||
NewDocumentTypeList.DataTextField = "Name";
|
||||
NewDocumentTypeList.DataBind();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PopulateListOfTemplates()
|
||||
{
|
||||
// Get selected new document type
|
||||
var contentType = GetSelectedDocumentType();
|
||||
|
||||
// Populate template list
|
||||
NewTemplateList.DataSource = contentType.AllowedTemplates;
|
||||
NewTemplateList.DataValueField = "Id";
|
||||
NewTemplateList.DataTextField = "Name";
|
||||
NewTemplateList.DataBind();
|
||||
NewTemplateList.Items.Add(new ListItem("<" + global::umbraco.ui.Text("changeDocType", "none") + ">", "0"));
|
||||
|
||||
// Set default template
|
||||
if (contentType.DefaultTemplate != null)
|
||||
{
|
||||
var itemToSelect = NewTemplateList.Items.FindByValue(contentType.DefaultTemplate.Id.ToString());
|
||||
if (itemToSelect != null)
|
||||
{
|
||||
itemToSelect.Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulatePropertyMappingWithSources()
|
||||
{
|
||||
PropertyMappingRepeater.DataSource = GetPropertiesOfContentType(_content.ContentType);
|
||||
PropertyMappingRepeater.DataBind();
|
||||
}
|
||||
|
||||
private void PopulatePropertyMappingWithDestinations()
|
||||
{
|
||||
// Get selected new document type
|
||||
var contentType = GetSelectedDocumentType();
|
||||
|
||||
// Get properties of new document type (including any from parent types)
|
||||
var properties = GetPropertiesOfContentType(contentType);
|
||||
|
||||
// Loop through list of source properties and populate destination options with all those of same property type
|
||||
foreach (RepeaterItem ri in PropertyMappingRepeater.Items)
|
||||
{
|
||||
if (ri.ItemType == ListItemType.Item || ri.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
// Get data type from hidden field
|
||||
var dataTypeId = Guid.Parse(((HiddenField)ri.FindControl("DataTypeId")).Value);
|
||||
|
||||
// Bind destination list with properties that match data type
|
||||
var ddl = (DropDownList)ri.FindControl("DestinationProperty");
|
||||
ddl.DataSource = properties.Where(x => x.DataTypeId == dataTypeId);
|
||||
ddl.DataValueField = "Alias";
|
||||
ddl.DataTextField = "Name";
|
||||
ddl.DataBind();
|
||||
ddl.Items.Add(new ListItem("<" + global::umbraco.ui.Text("changeDocType", "none") + ">", string.Empty));
|
||||
|
||||
// Set default selection to be one with matching alias
|
||||
var alias = ((HiddenField)ri.FindControl("Alias")).Value;
|
||||
var item = ddl.Items.FindByValue(alias);
|
||||
if (item != null)
|
||||
{
|
||||
item.Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IContentType GetSelectedDocumentType()
|
||||
{
|
||||
return ApplicationContext.Current.Services.ContentTypeService.GetContentType(int.Parse(NewDocumentTypeList.SelectedItem.Value));
|
||||
}
|
||||
|
||||
private IEnumerable<PropertyType> GetPropertiesOfContentType(IContentType contentType)
|
||||
{
|
||||
var properties = contentType.PropertyTypes.ToList();
|
||||
while (contentType.ParentId > -1)
|
||||
{
|
||||
contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(contentType.ParentId);
|
||||
properties.AddRange(contentType.PropertyTypes);
|
||||
}
|
||||
|
||||
return properties.OrderBy(x => x.Name);
|
||||
}
|
||||
|
||||
private void DisplayNotAvailable()
|
||||
{
|
||||
NewTypePropertyPanel.Visible = false;
|
||||
NewTemplatePropertyPanel.Visible = false;
|
||||
SavePlaceholder.Visible = false;
|
||||
NotAvailablePlaceholder.Visible = true;
|
||||
ChangeDocTypePropertyMappingPane.Visible = false;
|
||||
}
|
||||
|
||||
protected void NewDocumentTypeList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
PopulateListOfTemplates();
|
||||
PopulatePropertyMappingWithDestinations();
|
||||
}
|
||||
|
||||
protected void ValidateAndSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (IsPropertyMappingValid())
|
||||
{
|
||||
// For all properties to be mapped, save the values to a temporary list
|
||||
var propertyMappings = SavePropertyMappings();
|
||||
|
||||
// Get flag for if content already published
|
||||
var wasPublished = _content.Published;
|
||||
|
||||
// Change the document type passing flag to clear the properties
|
||||
var newContentType = GetSelectedDocumentType();
|
||||
_content.ChangeContentType(newContentType, true);
|
||||
|
||||
// Set the template if one has been selected
|
||||
if (NewTemplateList.SelectedItem != null)
|
||||
{
|
||||
var templateId = int.Parse(NewTemplateList.SelectedItem.Value);
|
||||
if (templateId > 0)
|
||||
{
|
||||
_content.Template = ApplicationContext.Current.Services.FileService.GetTemplate(templateId);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the property values
|
||||
var propertiesMappedMessageBuilder = new StringBuilder("<ul>");
|
||||
foreach (var propertyMapping in propertyMappings)
|
||||
{
|
||||
propertiesMappedMessageBuilder.AppendFormat("<li>{0} {1} {2}</li>",
|
||||
propertyMapping.FromName, global::umbraco.ui.Text("changeDocType", "to"), propertyMapping.ToName);
|
||||
_content.SetValue(propertyMapping.ToAlias, propertyMapping.Value);
|
||||
}
|
||||
propertiesMappedMessageBuilder.Append("</ul>");
|
||||
|
||||
// Save
|
||||
var user = global::umbraco.BusinessLogic.User.GetCurrent();
|
||||
ApplicationContext.Current.Services.ContentService.Save(_content, user.Id);
|
||||
|
||||
// Publish if the content was already published
|
||||
if (wasPublished)
|
||||
{
|
||||
ApplicationContext.Current.Services.ContentService.Publish(_content, user.Id);
|
||||
}
|
||||
|
||||
// Sync the tree
|
||||
ClientTools.SyncTree(_content.Path, true);
|
||||
|
||||
// Reload the page if the content was already being viewed
|
||||
ClientTools.ReloadContentFrameUrlIfPathLoaded("/editContent.aspx?id=" + _content.Id);
|
||||
|
||||
// Display success message
|
||||
SuccessMessage.Text = global::umbraco.ui.Text("changeDocType", "successMessage").Replace("[new type]", "<strong>" + newContentType.Name + "</strong>");
|
||||
PropertiesMappedMessage.Text = propertiesMappedMessageBuilder.ToString();
|
||||
if (wasPublished)
|
||||
{
|
||||
ContentPublishedMessage.Text = global::umbraco.ui.Text("changeDocType", "contentRepublished");
|
||||
ContentPublishedMessage.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentPublishedMessage.Visible = false;
|
||||
}
|
||||
SuccessPlaceholder.Visible = true;
|
||||
SaveAndCancelPlaceholder.Visible = false;
|
||||
ValidationPlaceholder.Visible = false;
|
||||
ChangeDocTypePane.Visible = false;
|
||||
ChangeDocTypePropertyMappingPane.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ValidationPlaceholder.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPropertyMappingValid()
|
||||
{
|
||||
// Check whether any properties have been mapped to more than once
|
||||
var mappedPropertyAliases = new List<string>();
|
||||
foreach (RepeaterItem ri in PropertyMappingRepeater.Items)
|
||||
{
|
||||
if (ri.ItemType == ListItemType.Item || ri.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
var ddl = (DropDownList)ri.FindControl("DestinationProperty");
|
||||
var mappedPropertyAlias = ddl.SelectedItem.Value;
|
||||
if (!string.IsNullOrEmpty(mappedPropertyAlias))
|
||||
{
|
||||
if (mappedPropertyAliases.Contains(mappedPropertyAlias))
|
||||
{
|
||||
ValidationError.Text = global::umbraco.ui.Text("changeDocType", "validationErrorPropertyWithMoreThanOneMapping");
|
||||
return false;
|
||||
}
|
||||
|
||||
mappedPropertyAliases.Add(mappedPropertyAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private IList<PropertyMapping> SavePropertyMappings()
|
||||
{
|
||||
// Create list of mapped property values for assignment after the document type is changed
|
||||
var mappedPropertyValues = new List<PropertyMapping>();
|
||||
foreach (RepeaterItem ri in PropertyMappingRepeater.Items)
|
||||
{
|
||||
if (ri.ItemType == ListItemType.Item || ri.ItemType == ListItemType.AlternatingItem)
|
||||
{
|
||||
// Get property alias to map to
|
||||
var ddl = (DropDownList)ri.FindControl("DestinationProperty");
|
||||
var mappedAlias = ddl.SelectedItem.Value;
|
||||
if (!string.IsNullOrEmpty(mappedAlias))
|
||||
{
|
||||
// If mapping property, get current property value from alias
|
||||
var sourceAlias = ((HiddenField)ri.FindControl("Alias")).Value;
|
||||
var sourcePropertyValue = _content.GetValue(sourceAlias);
|
||||
|
||||
// Add to list
|
||||
mappedPropertyValues.Add(new PropertyMapping
|
||||
{
|
||||
FromName = ((HiddenField)ri.FindControl("Name")).Value,
|
||||
ToName = ddl.SelectedItem.Text,
|
||||
ToAlias = mappedAlias,
|
||||
Value = sourcePropertyValue
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mappedPropertyValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
213
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx.designer.cs
generated
Normal file
213
src/Umbraco.Web.UI/umbraco/dialogs/ChangeDocType.aspx.designer.cs
generated
Normal file
@@ -0,0 +1,213 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Dialogs {
|
||||
|
||||
|
||||
public partial class ChangeDocType {
|
||||
|
||||
/// <summary>
|
||||
/// ChangeDocTypePane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane ChangeDocTypePane;
|
||||
|
||||
/// <summary>
|
||||
/// ContentNamePropertyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel ContentNamePropertyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// ContentNameLabel 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 ContentNameLabel;
|
||||
|
||||
/// <summary>
|
||||
/// CurrentTypePropertyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel CurrentTypePropertyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// CurrentTypeLabel 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 CurrentTypeLabel;
|
||||
|
||||
/// <summary>
|
||||
/// NewTypePropertyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel NewTypePropertyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// NewDocumentTypeList 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.DropDownList NewDocumentTypeList;
|
||||
|
||||
/// <summary>
|
||||
/// NewDocumentTypeValidator 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.RequiredFieldValidator NewDocumentTypeValidator;
|
||||
|
||||
/// <summary>
|
||||
/// NewTemplatePropertyPanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.PropertyPanel NewTemplatePropertyPanel;
|
||||
|
||||
/// <summary>
|
||||
/// NewTemplateList 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.DropDownList NewTemplateList;
|
||||
|
||||
/// <summary>
|
||||
/// NotAvailablePlaceholder 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.PlaceHolder NotAvailablePlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// ChangeDocTypePropertyMappingPane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane ChangeDocTypePropertyMappingPane;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyMappingRepeater 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.Repeater PropertyMappingRepeater;
|
||||
|
||||
/// <summary>
|
||||
/// SuccessPlaceholder 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.PlaceHolder SuccessPlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// SuccessMessage 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.Literal SuccessMessage;
|
||||
|
||||
/// <summary>
|
||||
/// PropertiesMappedMessage 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.Literal PropertiesMappedMessage;
|
||||
|
||||
/// <summary>
|
||||
/// ContentPublishedMessage 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.Literal ContentPublishedMessage;
|
||||
|
||||
/// <summary>
|
||||
/// ValidationPlaceholder 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.PlaceHolder ValidationPlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// ValidationError 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.Literal ValidationError;
|
||||
|
||||
/// <summary>
|
||||
/// SaveAndCancelPlaceholder 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.PlaceHolder SaveAndCancelPlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// SavePlaceholder 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.PlaceHolder SavePlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// ValidateAndSave 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.Button ValidateAndSave;
|
||||
}
|
||||
}
|
||||
@@ -181,6 +181,15 @@ Umbraco.Application.Actions = function () {
|
||||
|
||||
},
|
||||
|
||||
actionChangeDocType: function () {
|
||||
/// <summary></summary>
|
||||
|
||||
if (UmbClientMgr.mainTree().getActionNode().nodeId != '0' && UmbClientMgr.mainTree().getActionNode().nodeType != '') {
|
||||
UmbClientMgr.openModalWindow("dialogs/changeDocType.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&app=' + this._currApp + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_changeDocType'], true, 600, 600);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
actionRights: function () {
|
||||
/// <summary></summary>
|
||||
|
||||
|
||||
@@ -141,6 +141,20 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
|
||||
},200);
|
||||
}
|
||||
},
|
||||
reloadContentFrameUrlIfPathLoaded: function (url) {
|
||||
var contentFrame;
|
||||
if (typeof this.mainWindow().right != "undefined") {
|
||||
contentFrame = this.mainWindow().right;
|
||||
}
|
||||
else {
|
||||
contentFrame = this.mainWindow();
|
||||
}
|
||||
|
||||
var currentPath = contentFrame.location.pathname + (contentFrame.location.search ? contentFrame.location.search : "");
|
||||
if (currentPath == url) {
|
||||
contentFrame.location.reload();
|
||||
}
|
||||
},
|
||||
openModalWindow: function(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) {
|
||||
//need to create the modal on the top window if the top window has a client manager, if not, create it on the current window
|
||||
|
||||
|
||||
@@ -105,8 +105,11 @@
|
||||
{
|
||||
background-position: -7px -207px;
|
||||
}
|
||||
|
||||
.sprLiveEdit
|
||||
{
|
||||
background-position: -7px -706px;
|
||||
}
|
||||
}
|
||||
.sprChangeDocType
|
||||
{
|
||||
background-position: -12px -741px;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
@@ -1957,7 +1957,9 @@
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\users\EditUser.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\users\EditUserType.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\users\EditUserType.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<!--<Content Include="umbraco.presentation\umbraco\users\PermissionEditor.aspx" />-->
|
||||
<Content Include="umbraco.presentation\umbraco\webService.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\CacheRefresher.asmx">
|
||||
|
||||
@@ -124,6 +124,8 @@ namespace umbraco
|
||||
actions.Add(ActionSort.Instance);
|
||||
actions.Add(ActionRollback.Instance);
|
||||
actions.Add(ContextMenuSeperator.Instance);
|
||||
actions.Add(ActionChangeDocType.Instance);
|
||||
actions.Add(ContextMenuSeperator.Instance);
|
||||
actions.Add(ActionPublish.Instance);
|
||||
actions.Add(ActionToPublish.Instance);
|
||||
actions.Add(ActionAssignDomain.Instance);
|
||||
|
||||
@@ -48,6 +48,9 @@ namespace umbraco.BasePages
|
||||
public static string ChangeContentFrameUrl(string url) {
|
||||
return string.Format(ClientMgrScript + ".contentFrame('{0}');", url);
|
||||
}
|
||||
public static string ReloadContentFrameUrlIfPathLoaded(string url) {
|
||||
return string.Format(ClientMgrScript + ".reloadContentFrameUrlIfPathLoaded('{0}');", url);
|
||||
}
|
||||
public static string ChildNodeCreated = GetMainTree + ".childNodeCreated();";
|
||||
public static string SyncTree { get { return GetMainTree + ".syncTree('{0}', {1});"; } }
|
||||
public static string ClearTreeCache { get { return GetMainTree + ".clearTreeCache();"; } }
|
||||
@@ -147,8 +150,7 @@ namespace umbraco.BasePages
|
||||
//don't load if there is no url
|
||||
if (string.IsNullOrEmpty(url)) return this;
|
||||
|
||||
if (url.StartsWith("/") && !url.StartsWith(IOHelper.ResolveUrl(SystemDirectories.Umbraco)))
|
||||
url = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/" + url;
|
||||
url = EnsureUmbracoUrl(url);
|
||||
|
||||
if (url.Trim().StartsWith("~"))
|
||||
url = IOHelper.ResolveUrl(url);
|
||||
@@ -158,6 +160,30 @@ namespace umbraco.BasePages
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the content in the content frame if the specified URL is currently loaded
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public ClientTools ReloadContentFrameUrlIfPathLoaded(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return this;
|
||||
|
||||
url = EnsureUmbracoUrl(url);
|
||||
|
||||
RegisterClientScript(Scripts.ReloadContentFrameUrlIfPathLoaded(url));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private string EnsureUmbracoUrl(string url)
|
||||
{
|
||||
if (url.StartsWith("/") && !url.StartsWith(IOHelper.ResolveUrl(SystemDirectories.Umbraco)))
|
||||
{
|
||||
url = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dashboard for the given application
|
||||
/// </summary>
|
||||
|
||||
94
src/umbraco.cms/Actions/ActionChangeDocType.cs
Normal file
94
src/umbraco.cms/Actions/ActionChangeDocType.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.BasePages;
|
||||
|
||||
namespace umbraco.BusinessLogic.Actions
|
||||
{
|
||||
/// <summary>
|
||||
/// This action is invoked when the document type of a piece of content is changed
|
||||
/// </summary>
|
||||
public class ActionChangeDocType : IAction
|
||||
{
|
||||
//create singleton
|
||||
#pragma warning disable 612,618
|
||||
private static readonly ActionChangeDocType m_instance = new ActionChangeDocType();
|
||||
#pragma warning restore 612,618
|
||||
|
||||
/// <summary>
|
||||
/// A public constructor exists ONLY for backwards compatibility in regards to 3rd party add-ons.
|
||||
/// All Umbraco assemblies should use the singleton instantiation (this.Instance)
|
||||
/// When this applicatio is refactored, this constuctor should be made private.
|
||||
/// </summary>
|
||||
[Obsolete("Use the singleton instantiation instead of a constructor")]
|
||||
public ActionChangeDocType() { }
|
||||
|
||||
public static ActionChangeDocType Instance
|
||||
{
|
||||
get { return m_instance; }
|
||||
}
|
||||
|
||||
#region IAction Members
|
||||
|
||||
public char Letter
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return '7';
|
||||
}
|
||||
}
|
||||
|
||||
public string JsFunctionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0}.actionChangeDocType()", ClientTools.Scripts.GetAppActions);
|
||||
}
|
||||
}
|
||||
|
||||
public string JsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string Alias
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return "changeDocType";
|
||||
}
|
||||
}
|
||||
|
||||
public string Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return ".sprChangeDocType";
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowInNotifier
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool CanBePermissionAssigned
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -175,6 +175,7 @@
|
||||
<Compile Include="Actions\ActionAssignDomain.cs" />
|
||||
<Compile Include="Actions\ActionAudit.cs" />
|
||||
<Compile Include="Actions\ActionBrowse.cs" />
|
||||
<Compile Include="Actions\ActionChangeDocType.cs" />
|
||||
<Compile Include="Actions\ActionCopy.cs" />
|
||||
<Compile Include="Actions\ActionDelete.cs" />
|
||||
<Compile Include="Actions\ActionDisable.cs" />
|
||||
|
||||
Reference in New Issue
Block a user