I didn't add a Type drop down like the scripts screen has. This is unnecessary and cumbersome. Instead it works like other screens and the user can generate a hierarchy in their files by adding /'s in the names. This is how it works in Stylesheets works and its a lot cleaner. I added a note of this to the creation dialogs as well. For example create a view file with the name myFolder/myView and the system will take care of folder creation automatically. There is also a delete option. Other errors fixed: Selecting a folder in the scripts lists was generating an error. Stylesheets would not create a new folder(but they wold make nested children in existing folders. Partial and Macro Views would not use the proper elpers for generating syncTree code.
84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using Umbraco.Core;
|
|
using Umbraco.Core.Configuration;
|
|
using Umbraco.Core.IO;
|
|
using umbraco.BusinessLogic.Actions;
|
|
using umbraco.businesslogic;
|
|
using umbraco.cms.businesslogic.template;
|
|
using umbraco.cms.presentation.Trees;
|
|
using umbraco.interfaces;
|
|
|
|
namespace Umbraco.Web.Trees
|
|
{
|
|
/// <summary>
|
|
/// Tree for displaying partial views in the settings app
|
|
/// </summary>
|
|
[Tree(Constants.Applications.Settings, "partialViews", "Partial Views", sortOrder: 2)]
|
|
public class PartialViewsTree : FileSystemTree
|
|
{
|
|
public PartialViewsTree(string application) : base(application) { }
|
|
|
|
public override void RenderJS(ref StringBuilder javascript)
|
|
{
|
|
//NOTE: Notice the Partials%2f string below, this is a URLEncoded string of "Partials/" so that the editor knows
|
|
// to load the file from the correct location
|
|
javascript.Append(
|
|
@"
|
|
function openPartialView(id) {
|
|
UmbClientMgr.contentFrame('Settings/Views/EditView.aspx?treeType=partialViews&file=Partials%2f' + id);
|
|
}
|
|
");
|
|
}
|
|
|
|
protected override void CreateRootNode(ref XmlTreeNode rootNode)
|
|
{
|
|
rootNode.NodeType = TreeAlias;
|
|
rootNode.NodeID = "init";
|
|
}
|
|
|
|
protected override string FilePath
|
|
{
|
|
get { return SystemDirectories.MvcViews + "/Partials/"; }
|
|
}
|
|
|
|
protected override string FileSearchPattern
|
|
{
|
|
get { return "*.cshtml"; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures that no folders can be added
|
|
/// </summary>
|
|
/// <param name="xNode"></param>
|
|
protected override void OnRenderFolderNode(ref XmlTreeNode xNode)
|
|
{
|
|
// We should allow folder hierarchy for organization in large sites.
|
|
xNode.Action = "javascript:void(0);";
|
|
xNode.NodeType = "partialViewsFolder";
|
|
xNode.Menu = new List<IAction>(new IAction[] { ActionDelete.Instance, ContextMenuSeperator.Instance, ActionNew.Instance, ContextMenuSeperator.Instance, ActionRefresh.Instance });
|
|
|
|
}
|
|
|
|
protected virtual void ChangeNodeAction(XmlTreeNode xNode)
|
|
{
|
|
xNode.Action = xNode.Action.Replace("openFile", "openPartialView");
|
|
}
|
|
|
|
protected override void OnRenderFileNode(ref XmlTreeNode xNode)
|
|
{
|
|
ChangeNodeAction(xNode);
|
|
xNode.Icon = "settingView.gif";
|
|
xNode.OpenIcon = "settingView.gif";
|
|
|
|
xNode.Text = xNode.Text.StripFileExtension();
|
|
}
|
|
|
|
|
|
}
|
|
}
|