Merge branch 'dev-v7.6' of https://github.com/umbraco/Umbraco-CMS into dev-v7.6
This commit is contained in:
@@ -245,7 +245,8 @@
|
||||
|
||||
//sync state
|
||||
editorState.set(vm.partialView);
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.virtualPath, forceReload: true }).then(function (syncArgs) {
|
||||
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Web.Trees;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -62,7 +64,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
virtualPath = System.Web.HttpUtility.UrlDecode(virtualPath);
|
||||
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -72,6 +74,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var display = Mapper.Map<IPartialView, CodeFileDisplay>(view);
|
||||
display.FileType = Core.Constants.Trees.PartialViews;
|
||||
display.Path = Url.GetTreePathFromFilePath(view.Path);
|
||||
return display;
|
||||
}
|
||||
return null;
|
||||
@@ -82,6 +85,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var display = Mapper.Map<IPartialView, CodeFileDisplay>(viewMacro);
|
||||
display.FileType = Core.Constants.Trees.PartialViewMacros;
|
||||
display.Path = Url.GetTreePathFromFilePath(viewMacro.Path);
|
||||
return display;
|
||||
}
|
||||
return null;
|
||||
@@ -92,6 +96,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var display = Mapper.Map<Script, CodeFileDisplay>(script);
|
||||
display.FileType = Core.Constants.Trees.Scripts;
|
||||
display.Path = Url.GetTreePathFromFilePath(script.Path);
|
||||
return display;
|
||||
}
|
||||
return null;
|
||||
@@ -171,12 +176,15 @@ namespace Umbraco.Web.Editors
|
||||
// might need to find the path
|
||||
var orgPath = view.OriginalPath.Substring(0, view.OriginalPath.IndexOf(view.Name));
|
||||
view.Path = orgPath + display.Name;
|
||||
|
||||
view.Content = display.Content;
|
||||
|
||||
//Save the file and update the response to reflect any name and path changes
|
||||
var result = Services.FileService.SavePartialView(view, Security.CurrentUser.Id);
|
||||
if (result.Success == true)
|
||||
{
|
||||
return Mapper.Map(view, display);
|
||||
display = Mapper.Map(result.Result, display);
|
||||
display.Path = Url.GetTreePathFromFilePath(view.Path);
|
||||
return display;
|
||||
}
|
||||
|
||||
display.AddErrorNotification(
|
||||
@@ -195,13 +203,19 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
viewMacro.Content = display.Content;
|
||||
viewMacro.Path = display.Name;
|
||||
|
||||
//save the file and update the display to reflect any path and name changes
|
||||
var result = Services.FileService.SavePartialViewMacro(viewMacro, Security.CurrentUser.Id);
|
||||
if (result.Success == false)
|
||||
if (result.Success == true)
|
||||
{
|
||||
display.AddErrorNotification(
|
||||
Services.TextService.Localize("speechBubbles/macroPartialViewErrorHeader"),
|
||||
Services.TextService.Localize("speechBubbles/macroPartialViewErrorText"));
|
||||
display = Mapper.Map(result.Result, display);
|
||||
display.Path = Url.GetTreePathFromFilePath(result.Result.Path);
|
||||
return display;
|
||||
}
|
||||
|
||||
display.AddErrorNotification(
|
||||
Services.TextService.Localize("speechBubbles/partialViewErrorHeader"),
|
||||
Services.TextService.Localize("speechBubbles/partialViewErrorText"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,7 +229,12 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
script.Content = display.Content;
|
||||
script.Path = display.Name;
|
||||
|
||||
Services.FileService.SaveScript(script, Security.CurrentUser.Id);
|
||||
display = Mapper.Map(script, display);
|
||||
display.Path = Url.GetTreePathFromFilePath(script.Path);
|
||||
return display;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,9 +11,24 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataContract(Name = "scriptFile", Namespace = "")]
|
||||
public class CodeFileDisplay : INotificationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// VirtualPath is the path to the file on disk
|
||||
/// /views/partials/file.cshtml
|
||||
/// </summary>
|
||||
[DataMember(Name = "virtualPath", IsRequired = true)]
|
||||
public string VirtualPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path represents the path used by the backoffice tree
|
||||
/// For files stored on disk, this is a urlencoded, comma seperated
|
||||
/// path to the file, always starting with -1.
|
||||
///
|
||||
/// -1,Partials,Parials%2FFolder,Partials%2FFolder%2FFile.cshtml
|
||||
/// </summary>
|
||||
[DataMember(Name = "path")]
|
||||
[ReadOnly(true)]
|
||||
public string Path { get; set; }
|
||||
|
||||
[DataMember(Name = "name", IsRequired = true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
config.CreateMap<IPartialView, CodeFileDisplay>()
|
||||
.ForMember(x => x.FileType, exp => exp.Ignore())
|
||||
.ForMember(x => x.Notifications, exp => exp.Ignore())
|
||||
.ForMember(x => x.Path, exp => exp.Ignore())
|
||||
.ForMember(x => x.Snippet, exp => exp.Ignore());
|
||||
|
||||
config.CreateMap<Script, CodeFileDisplay>()
|
||||
.ForMember(x => x.FileType, exp => exp.Ignore())
|
||||
.ForMember(x => x.Notifications, exp => exp.Ignore())
|
||||
.ForMember(x => x.Path, exp => exp.Ignore())
|
||||
.ForMember(x => x.Snippet, exp => exp.Ignore());
|
||||
|
||||
config.CreateMap<CodeFileDisplay, IPartialView>()
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Trees
|
||||
string path = "";
|
||||
if (!string.IsNullOrEmpty(id) && id != "-1")
|
||||
{
|
||||
orgPath = id;
|
||||
orgPath = System.Web.HttpUtility.UrlDecode(id);
|
||||
path = IOHelper.MapPath(FilePath + "/" + orgPath);
|
||||
orgPath += "/";
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Web.Trees
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == 0)
|
||||
{
|
||||
var HasChildren = dir.GetFiles().Length > 0 || dir.GetDirectories().Length > 0;
|
||||
var node = CreateTreeNode(orgPath + dir.Name, orgPath, queryStrings, dir.Name, "icon-folder", HasChildren);
|
||||
var node = CreateTreeNode(System.Web.HttpUtility.UrlEncode(orgPath + dir.Name), orgPath, queryStrings, dir.Name, "icon-folder", HasChildren);
|
||||
|
||||
OnRenderFolderNode(ref node);
|
||||
if(node != null)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http.Routing;
|
||||
using Umbraco.Core;
|
||||
|
||||
@@ -30,5 +33,35 @@ namespace Umbraco.Web.Trees
|
||||
return actionUrl;
|
||||
}
|
||||
|
||||
|
||||
internal static string GetTreePathFromFilePath(this UrlHelper urlHelper, string virtualPath, string basePath = "")
|
||||
{
|
||||
//This reuses the Logic from umbraco.cms.helpers.DeepLink class
|
||||
//to convert a filepath to a tree syncing path string.
|
||||
|
||||
//removes the basepath from the path
|
||||
//and normalises paths - / is used consistently between trees and editors
|
||||
basePath = basePath.TrimStart("~");
|
||||
virtualPath = virtualPath.TrimStart("~");
|
||||
virtualPath = virtualPath.Substring(basePath.Length);
|
||||
virtualPath = virtualPath.Replace('\\', '/');
|
||||
|
||||
//-1 is the default root id for trees
|
||||
var sb = new StringBuilder("-1");
|
||||
|
||||
//split the virtual path and iterate through it
|
||||
var pathPaths = virtualPath.Split('/');
|
||||
|
||||
for (var p = 0; p < pathPaths.Length; p++)
|
||||
{
|
||||
var path = HttpUtility.UrlEncode(string.Join("/", pathPaths.Take(p + 1)));
|
||||
if (string.IsNullOrEmpty(path) == false)
|
||||
{
|
||||
sb.Append(",");
|
||||
sb.Append(path);
|
||||
}
|
||||
}
|
||||
return sb.ToString().TrimEnd(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user