Merge pull request #10629 from umbraco/v9/task/package-partial-views
V9/task/package partial views
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
|
||||
@@ -7,6 +9,25 @@ namespace Umbraco.Extensions
|
||||
{
|
||||
public static class FileSystemExtensions
|
||||
{
|
||||
public static string GetStreamHash(this Stream fileStream)
|
||||
{
|
||||
if (fileStream.CanSeek)
|
||||
{
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
using HashAlgorithm alg = SHA1.Create();
|
||||
|
||||
// create a string output for the hash
|
||||
var stringBuilder = new StringBuilder();
|
||||
var hashedByteArray = alg.ComputeHash(fileStream);
|
||||
foreach (var b in hashedByteArray)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("x2"));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to open the file at <code>filePath</code> up to <code>maxRetries</code> times,
|
||||
/// with a thread sleep time of <code>sleepPerRetryInMilliseconds</code> between retries.
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the type's of Umbraco entities that can be resolved from the EntityController
|
||||
/// </summary>
|
||||
public enum UmbracoEntityTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Domain
|
||||
/// </summary>
|
||||
Domain,
|
||||
|
||||
/// <summary>
|
||||
/// Language
|
||||
/// </summary>
|
||||
@@ -65,6 +60,16 @@
|
||||
/// </summary>
|
||||
Stylesheet,
|
||||
|
||||
/// <summary>
|
||||
/// Script
|
||||
/// </summary>
|
||||
Script,
|
||||
|
||||
/// <summary>
|
||||
/// Partial View
|
||||
/// </summary>
|
||||
PartialView,
|
||||
|
||||
/// <summary>
|
||||
/// Member
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.Mapping
|
||||
@@ -8,9 +8,14 @@ namespace Umbraco.Cms.Core.Models.Mapping
|
||||
public void DefineMaps(IUmbracoMapper mapper)
|
||||
{
|
||||
mapper.Define<IStylesheet, EntityBasic>((source, context) => new EntityBasic(), Map);
|
||||
mapper.Define<IPartialView, CodeFileDisplay>((source, context) => new CodeFileDisplay(), Map);
|
||||
mapper.Define<IScript, CodeFileDisplay>((source, context) => new CodeFileDisplay(), Map);
|
||||
mapper.Define<IStylesheet, CodeFileDisplay>((source, context) => new CodeFileDisplay(), Map);
|
||||
|
||||
mapper.Define<IPartialView, EntityBasic>((source, context) => new EntityBasic(), Map);
|
||||
mapper.Define<IPartialView, CodeFileDisplay>((source, context) => new CodeFileDisplay(), Map);
|
||||
|
||||
mapper.Define<IScript, EntityBasic>((source, context) => new EntityBasic(), Map);
|
||||
mapper.Define<IScript, CodeFileDisplay>((source, context) => new CodeFileDisplay(), Map);
|
||||
|
||||
mapper.Define<CodeFileDisplay, IPartialView>(Map);
|
||||
mapper.Define<CodeFileDisplay, IScript>(Map);
|
||||
|
||||
@@ -27,6 +32,28 @@ namespace Umbraco.Cms.Core.Models.Mapping
|
||||
target.Path = source.Path;
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Trashed -Udi -Icon
|
||||
private static void Map(IScript source, EntityBasic target, MapperContext context)
|
||||
{
|
||||
target.Alias = source.Alias;
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.ParentId = -1;
|
||||
target.Path = source.Path;
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Trashed -Udi -Icon
|
||||
private static void Map(IPartialView source, EntityBasic target, MapperContext context)
|
||||
{
|
||||
target.Alias = source.Alias;
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.ParentId = -1;
|
||||
target.Path = source.Path;
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -FileType -Notifications -Path -Snippet
|
||||
private static void Map(IPartialView source, CodeFileDisplay target, MapperContext context)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,11 @@ namespace Umbraco.Cms.Core.Models.Packaging
|
||||
public string Name { get; set; }
|
||||
public InstallWarnings Warnings { get; set; } = new InstallWarnings();
|
||||
public IEnumerable<XElement> Macros { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> MacroPartialViews { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> Templates { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> Stylesheets { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> Scripts { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> PartialViews { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> DataTypes { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> Languages { get; set; } // TODO: make strongly typed
|
||||
public IEnumerable<XElement> DictionaryItems { get; set; } // TODO: make strongly typed
|
||||
|
||||
@@ -38,8 +38,11 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
PackageFile = null,
|
||||
Name = package.Element("name")?.Value,
|
||||
Macros = xml.Root.Element("Macros")?.Elements("macro") ?? Enumerable.Empty<XElement>(),
|
||||
MacroPartialViews = xml.Root.Element("MacroPartialViews")?.Elements("View") ?? Enumerable.Empty<XElement>(),
|
||||
PartialViews = xml.Root.Element("PartialViews")?.Elements("View") ?? Enumerable.Empty<XElement>(),
|
||||
Templates = xml.Root.Element("Templates")?.Elements("Template") ?? Enumerable.Empty<XElement>(),
|
||||
Stylesheets = xml.Root.Element("Stylesheets")?.Elements("styleSheet") ?? Enumerable.Empty<XElement>(),
|
||||
Stylesheets = xml.Root.Element("Stylesheets")?.Elements("Stylesheet") ?? Enumerable.Empty<XElement>(),
|
||||
Scripts = xml.Root.Element("Scripts")?.Elements("Script") ?? Enumerable.Empty<XElement>(),
|
||||
DataTypes = xml.Root.Element("DataTypes")?.Elements("DataType") ?? Enumerable.Empty<XElement>(),
|
||||
Languages = xml.Root.Element("Languages")?.Elements("Language") ?? Enumerable.Empty<XElement>(),
|
||||
DictionaryItems = xml.Root.Element("DictionaryItems")?.Elements("DictionaryItem") ?? Enumerable.Empty<XElement>(),
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
if (xElement == null)
|
||||
throw new FormatException("Missing \"Name\" element");
|
||||
|
||||
return _fileService.GetStylesheetByName(xElement.Value) as IFile;
|
||||
return _fileService.GetStylesheet(xElement.Value) as IFile;
|
||||
})
|
||||
.Where(v => v != null);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
public IEnumerable<IContentType> DocumentTypesInstalled { get; set; } = Enumerable.Empty<IContentType>();
|
||||
public IEnumerable<IMediaType> MediaTypesInstalled { get; set; } = Enumerable.Empty<IMediaType>();
|
||||
public IEnumerable<IFile> StylesheetsInstalled { get; set; } = Enumerable.Empty<IFile>();
|
||||
public IEnumerable<IScript> ScriptsInstalled { get; set; } = Enumerable.Empty<IScript>();
|
||||
public IEnumerable<IPartialView> PartialViewsInstalled { get; set; } = Enumerable.Empty<IPartialView>();
|
||||
public IEnumerable<IContent> ContentInstalled { get; set; } = Enumerable.Empty<IContent>();
|
||||
public IEnumerable<IMedia> MediaInstalled { get; set; } = Enumerable.Empty<IMedia>();
|
||||
public string PackageName { get; }
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
[DataMember(Name = "templates")]
|
||||
public IList<string> Templates { get; set; } = new List<string>();
|
||||
|
||||
[DataMember(Name = "partialViews")]
|
||||
public IList<string> PartialViews { get; set; } = new List<string>();
|
||||
|
||||
[DataMember(Name = "documentTypes")]
|
||||
public IList<string> DocumentTypes { get; set; } = new List<string>();
|
||||
|
||||
@@ -61,6 +64,9 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
[DataMember(Name = "stylesheets")]
|
||||
public IList<string> Stylesheets { get; set; } = new List<string>();
|
||||
|
||||
[DataMember(Name = "scripts")]
|
||||
public IList<string> Scripts { get; set; } = new List<string>();
|
||||
|
||||
[DataMember(Name = "dataTypes")]
|
||||
public IList<string> DataTypes { get; set; } = new List<string>();
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
/// </summary>
|
||||
public class PackageDefinitionXmlParser
|
||||
{
|
||||
private static readonly IList<string> s_emptyStringList = new List<string>();
|
||||
private static readonly IList<GuidUdi> s_emptyGuidUdiList = new List<GuidUdi>();
|
||||
|
||||
|
||||
public PackageDefinition ToPackageDefinition(XElement xml)
|
||||
{
|
||||
if (xml == null)
|
||||
@@ -27,16 +31,18 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
PackageId = xml.AttributeValue<Guid>("packageGuid"),
|
||||
ContentNodeId = xml.Element("content")?.AttributeValue<string>("nodeId") ?? string.Empty,
|
||||
ContentLoadChildNodes = xml.Element("content")?.AttributeValue<bool>("loadChildNodes") ?? false,
|
||||
MediaUdis = xml.Element("media")?.Elements("nodeUdi").Select(x => (GuidUdi)UdiParser.Parse(x.Value)).ToList() ?? new List<GuidUdi>(),
|
||||
MediaUdis = xml.Element("media")?.Elements("nodeUdi").Select(x => (GuidUdi)UdiParser.Parse(x.Value)).ToList() ?? s_emptyGuidUdiList,
|
||||
MediaLoadChildNodes = xml.Element("media")?.AttributeValue<bool>("loadChildNodes") ?? false,
|
||||
Macros = xml.Element("macros")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
Templates = xml.Element("templates")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
Stylesheets = xml.Element("stylesheets")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
DocumentTypes = xml.Element("documentTypes")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
MediaTypes = xml.Element("mediaTypes")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
Languages = xml.Element("languages")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
DictionaryItems = xml.Element("dictionaryitems")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
DataTypes = xml.Element("datatypes")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
|
||||
Macros = xml.Element("macros")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
Templates = xml.Element("templates")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
Stylesheets = xml.Element("stylesheets")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
Scripts = xml.Element("scripts")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
PartialViews = xml.Element("partialViews")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
DocumentTypes = xml.Element("documentTypes")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
MediaTypes = xml.Element("mediaTypes")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
Languages = xml.Element("languages")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
DictionaryItems = xml.Element("dictionaryitems")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
DataTypes = xml.Element("datatypes")?.Value.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).ToList() ?? s_emptyStringList,
|
||||
};
|
||||
|
||||
return retVal;
|
||||
@@ -57,6 +63,8 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
|
||||
new XElement("templates", string.Join(",", def.Templates ?? Array.Empty<string>())),
|
||||
new XElement("stylesheets", string.Join(",", def.Stylesheets ?? Array.Empty<string>())),
|
||||
new XElement("scripts", string.Join(",", def.Scripts ?? Array.Empty<string>())),
|
||||
new XElement("partialViews", string.Join(",", def.PartialViews ?? Array.Empty<string>())),
|
||||
new XElement("documentTypes", string.Join(",", def.DocumentTypes ?? Array.Empty<string>())),
|
||||
new XElement("mediaTypes", string.Join(",", def.MediaTypes ?? Array.Empty<string>())),
|
||||
new XElement("macros", string.Join(",", def.Macros ?? Array.Empty<string>())),
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Packaging
|
||||
{
|
||||
@@ -32,16 +33,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
// several very large package.zips.
|
||||
|
||||
using Stream stream = GetEmbeddedPackageStream(planType);
|
||||
using HashAlgorithm alg = SHA1.Create();
|
||||
|
||||
// create a string output for the hash
|
||||
var stringBuilder = new StringBuilder();
|
||||
var hashedByteArray = alg.ComputeHash(stream);
|
||||
foreach (var b in hashedByteArray)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("x2"));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
return stream.GetStreamHash();
|
||||
}
|
||||
|
||||
public static ZipArchive GetEmbeddedPackageDataManifest(Type planType, out XDocument packageXml)
|
||||
|
||||
@@ -4,10 +4,9 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Hosting;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
@@ -39,6 +38,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
private readonly MediaFileManager _mediaFileManager;
|
||||
private readonly FileSystems _fileSystems;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
@@ -71,6 +71,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
IMediaService mediaService,
|
||||
IMediaTypeService mediaTypeService,
|
||||
MediaFileManager mediaFileManager,
|
||||
FileSystems fileSystems,
|
||||
string packageRepositoryFileName,
|
||||
string tempFolderPath = null,
|
||||
string packagesFolderPath = null,
|
||||
@@ -96,6 +97,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
_mediaService = mediaService;
|
||||
_mediaTypeService = mediaTypeService;
|
||||
_mediaFileManager = mediaFileManager;
|
||||
_fileSystems = fileSystems;
|
||||
}
|
||||
|
||||
private string CreatedPackagesFile => _packagesFolderPath.EnsureEndsWith('/') + _packageRepositoryFileName;
|
||||
@@ -189,7 +191,7 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
try
|
||||
{
|
||||
//Init package file
|
||||
var compiledPackageXml = CreateCompiledPackageXml(out var root);
|
||||
XDocument compiledPackageXml = CreateCompiledPackageXml(out XElement root);
|
||||
|
||||
//Info section
|
||||
root.Add(GetPackageInfoXml(definition));
|
||||
@@ -199,6 +201,8 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
PackageMediaTypes(definition, root);
|
||||
PackageTemplates(definition, root);
|
||||
PackageStylesheets(definition, root);
|
||||
PackageStaticFiles(definition.Scripts, root, "Scripts", "Script", _fileSystems.ScriptsFileSystem);
|
||||
PackageStaticFiles(definition.PartialViews, root, "PartialViews", "View", _fileSystems.PartialViewsFileSystem);
|
||||
PackageMacros(definition, root);
|
||||
PackageDictionaryItems(definition, root);
|
||||
PackageLanguages(definition, root);
|
||||
@@ -372,34 +376,85 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
|
||||
private void PackageMacros(PackageDefinition definition, XContainer root)
|
||||
{
|
||||
var packagedMacros = new List<IMacro>();
|
||||
var macros = new XElement("Macros");
|
||||
foreach (var macroId in definition.Macros)
|
||||
{
|
||||
if (!int.TryParse(macroId, out var outInt))
|
||||
if (!int.TryParse(macroId, out int outInt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var macroXml = GetMacroXml(outInt, out var macro);
|
||||
XElement macroXml = GetMacroXml(outInt, out IMacro macro);
|
||||
if (macroXml == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
macros.Add(macroXml);
|
||||
packagedMacros.Add(macro);
|
||||
}
|
||||
|
||||
root.Add(macros);
|
||||
|
||||
// get the partial views for macros and package those
|
||||
IEnumerable<string> views = packagedMacros.Select(x => x.MacroSource).Where(x => x.EndsWith(".cshtml"));
|
||||
PackageMacroPartialViews(views, root);
|
||||
}
|
||||
|
||||
private void PackageStylesheets(PackageDefinition definition, XContainer root)
|
||||
{
|
||||
var stylesheetsXml = new XElement("Stylesheets");
|
||||
foreach (var stylesheetName in definition.Stylesheets)
|
||||
foreach (var stylesheet in definition.Stylesheets)
|
||||
{
|
||||
if (stylesheetName.IsNullOrWhiteSpace())
|
||||
if (stylesheet.IsNullOrWhiteSpace())
|
||||
{
|
||||
continue;
|
||||
var xml = GetStylesheetXml(stylesheetName, true);
|
||||
}
|
||||
|
||||
XElement xml = GetStylesheetXml(stylesheet, true);
|
||||
if (xml != null)
|
||||
{
|
||||
stylesheetsXml.Add(xml);
|
||||
}
|
||||
}
|
||||
root.Add(stylesheetsXml);
|
||||
}
|
||||
|
||||
private void PackageStaticFiles(
|
||||
IEnumerable<string> filePaths,
|
||||
XContainer root,
|
||||
string containerName,
|
||||
string elementName,
|
||||
IFileSystem fileSystem)
|
||||
{
|
||||
var scriptsXml = new XElement(containerName);
|
||||
foreach (var file in filePaths)
|
||||
{
|
||||
if (file.IsNullOrWhiteSpace())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fileSystem.FileExists(file))
|
||||
{
|
||||
throw new InvalidOperationException("No file found with path " + file);
|
||||
}
|
||||
|
||||
using (Stream stream = fileSystem.OpenFile(file))
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
var fileContents = reader.ReadToEnd();
|
||||
scriptsXml.Add(
|
||||
new XElement(
|
||||
elementName,
|
||||
new XAttribute("path", file),
|
||||
new XCData(fileContents)));
|
||||
}
|
||||
}
|
||||
root.Add(scriptsXml);
|
||||
}
|
||||
|
||||
private void PackageTemplates(PackageDefinition definition, XContainer root)
|
||||
{
|
||||
var templatesXml = new XElement("Templates");
|
||||
@@ -415,6 +470,33 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
root.Add(templatesXml);
|
||||
}
|
||||
|
||||
private void PackageMacroPartialViews(IEnumerable<string> viewPaths, XContainer root)
|
||||
{
|
||||
var viewsXml = new XElement("MacroPartialViews");
|
||||
foreach (var viewPath in viewPaths)
|
||||
{
|
||||
// TODO: See TODO note in MacrosController about the inconsistencies of usages of partial views
|
||||
// and how paths are saved. We have no choice currently but to assume that all views are 100% always
|
||||
// on the content path.
|
||||
|
||||
var physicalPath = _hostingEnvironment.MapPathContentRoot(viewPath);
|
||||
if (!File.Exists(physicalPath))
|
||||
{
|
||||
throw new InvalidOperationException("Could not find partial view at path " + viewPath);
|
||||
}
|
||||
|
||||
var fileContents = File.ReadAllText(physicalPath, Encoding.UTF8);
|
||||
|
||||
viewsXml.Add(
|
||||
new XElement(
|
||||
"View",
|
||||
new XAttribute("path", viewPath),
|
||||
new XCData(fileContents)));
|
||||
}
|
||||
|
||||
root.Add(viewsXml);
|
||||
}
|
||||
|
||||
private void PackageDocumentTypes(PackageDefinition definition, XContainer root)
|
||||
{
|
||||
var contentTypes = new HashSet<IContentType>();
|
||||
@@ -591,34 +673,23 @@ namespace Umbraco.Cms.Core.Packaging
|
||||
/// <summary>
|
||||
/// Converts a umbraco stylesheet to a package xml node
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the stylesheet.</param>
|
||||
/// <param name="path">The path of the stylesheet.</param>
|
||||
/// <param name="includeProperties">if set to <c>true</c> [include properties].</param>
|
||||
/// <returns></returns>
|
||||
private XElement GetStylesheetXml(string name, bool includeProperties)
|
||||
private XElement GetStylesheetXml(string path, bool includeProperties)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
|
||||
var sts = _fileService.GetStylesheetByName(name);
|
||||
if (sts == null)
|
||||
return null;
|
||||
var stylesheetXml = new XElement("Stylesheet");
|
||||
stylesheetXml.Add(new XElement("Name", sts.Alias));
|
||||
stylesheetXml.Add(new XElement("FileName", sts.Name));
|
||||
stylesheetXml.Add(new XElement("Content", new XCData(sts.Content)));
|
||||
|
||||
if (!includeProperties)
|
||||
return stylesheetXml;
|
||||
|
||||
var properties = new XElement("Properties");
|
||||
foreach (var ssP in sts.Properties)
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
var property = new XElement("Property");
|
||||
property.Add(new XElement("Name", ssP.Name));
|
||||
property.Add(new XElement("Alias", ssP.Alias));
|
||||
property.Add(new XElement("Value", ssP.Value));
|
||||
throw new ArgumentException("Value cannot be null or whitespace.", nameof(path));
|
||||
}
|
||||
stylesheetXml.Add(properties);
|
||||
return stylesheetXml;
|
||||
|
||||
IStylesheet stylesheet = _fileService.GetStylesheet(path);
|
||||
if (stylesheet == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _serializer.Serialize(stylesheet, includeProperties);
|
||||
}
|
||||
|
||||
private void AddDocumentType(IContentType dt, HashSet<IContentType> dtl)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Cms.Core.Services
|
||||
/// <returns><see cref="XElement"/> containing the xml representation of the IDictionaryItem object</returns>
|
||||
XElement Serialize(IDictionaryItem dictionaryItem, bool includeChildren);
|
||||
|
||||
XElement Serialize(Stylesheet stylesheet);
|
||||
XElement Serialize(IStylesheet stylesheet, bool includeProperties);
|
||||
|
||||
/// <summary>
|
||||
/// Exports a list of <see cref="ILanguage"/> items to xml as an <see cref="XElement"/>
|
||||
|
||||
@@ -15,6 +15,13 @@ namespace Umbraco.Cms.Core.Services
|
||||
void CreatePartialViewMacroFolder(string folderPath);
|
||||
void DeletePartialViewFolder(string folderPath);
|
||||
void DeletePartialViewMacroFolder(string folderPath);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all <see cref="IPartialView"/> objects
|
||||
/// </summary>
|
||||
/// <returns>An enumerable list of <see cref="IPartialView"/> objects</returns>
|
||||
IEnumerable<IPartialView> GetPartialViews(params string[] names);
|
||||
|
||||
IPartialView GetPartialView(string path);
|
||||
IPartialView GetPartialViewMacro(string path);
|
||||
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId);
|
||||
@@ -70,14 +77,14 @@ namespace Umbraco.Cms.Core.Services
|
||||
/// Gets a list of all <see cref="IStylesheet"/> objects
|
||||
/// </summary>
|
||||
/// <returns>An enumerable list of <see cref="IStylesheet"/> objects</returns>
|
||||
IEnumerable<IStylesheet> GetStylesheets(params string[] names);
|
||||
IEnumerable<IStylesheet> GetStylesheets(params string[] paths);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IStylesheet"/> object by its name
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the stylesheet incl. extension</param>
|
||||
/// <param name="path">Path of the stylesheet incl. extension</param>
|
||||
/// <returns>A <see cref="IStylesheet"/> object</returns>
|
||||
IStylesheet GetStylesheetByName(string name);
|
||||
IStylesheet GetStylesheet(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a <see cref="IStylesheet"/>
|
||||
@@ -127,12 +134,18 @@ namespace Umbraco.Cms.Core.Services
|
||||
/// <returns>The size of the stylesheet.</returns>
|
||||
long GetStylesheetFileSize(string filepath);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all <see cref="IScript"/> objects
|
||||
/// </summary>
|
||||
/// <returns>An enumerable list of <see cref="IScript"/> objects</returns>
|
||||
IEnumerable<IScript> GetScripts(params string[] names);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IScript"/> object by its name
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the script incl. extension</param>
|
||||
/// <returns>A <see cref="IScript"/> object</returns>
|
||||
IScript GetScriptByName(string name);
|
||||
IScript GetScript(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a <see cref="Script"/>
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection
|
||||
factory.GetRequiredService<IMediaService>(),
|
||||
factory.GetRequiredService<IMediaTypeService>(),
|
||||
factory.GetRequiredService<MediaFileManager>(),
|
||||
factory.GetRequiredService<FileSystems>(),
|
||||
packageRepoFileName);
|
||||
|
||||
private static LocalizedTextServiceFileSources SourcesFactory(IServiceProvider container)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -39,6 +41,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
private readonly IConfigurationEditorJsonSerializer _serializer;
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
private readonly IContentService _contentService;
|
||||
@@ -59,7 +62,8 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IConfigurationEditorJsonSerializer serializer,
|
||||
IMediaService mediaService,
|
||||
IMediaTypeService mediaTypeService)
|
||||
IMediaTypeService mediaTypeService,
|
||||
IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
_dataValueEditorFactory = dataValueEditorFactory;
|
||||
_logger = logger;
|
||||
@@ -74,6 +78,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
_serializer = serializer;
|
||||
_mediaService = mediaService;
|
||||
_mediaTypeService = mediaTypeService;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_entityService = entityService;
|
||||
_contentTypeService = contentTypeService;
|
||||
_contentService = contentService;
|
||||
@@ -91,7 +96,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
DataTypesInstalled = ImportDataTypes(compiledPackage.DataTypes.ToList(), userId),
|
||||
LanguagesInstalled = ImportLanguages(compiledPackage.Languages, userId),
|
||||
DictionaryItemsInstalled = ImportDictionaryItems(compiledPackage.DictionaryItems, userId),
|
||||
MacrosInstalled = ImportMacros(compiledPackage.Macros, userId),
|
||||
MacrosInstalled = ImportMacros(compiledPackage.Macros, compiledPackage.MacroPartialViews, userId),
|
||||
TemplatesInstalled = ImportTemplates(compiledPackage.Templates.ToList(), userId),
|
||||
DocumentTypesInstalled = ImportDocumentTypes(compiledPackage.DocumentTypes, userId),
|
||||
MediaTypesInstalled = ImportMediaTypes(compiledPackage.MediaTypes, userId),
|
||||
@@ -102,6 +107,8 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
var importedMediaTypes = installationSummary.MediaTypesInstalled.ToDictionary(x => x.Alias, x => x);
|
||||
|
||||
installationSummary.StylesheetsInstalled = ImportStylesheets(compiledPackage.Stylesheets, userId);
|
||||
installationSummary.PartialViewsInstalled = ImportPartialViews(compiledPackage.PartialViews, userId);
|
||||
installationSummary.ScriptsInstalled = ImportScripts(compiledPackage.Scripts, userId);
|
||||
installationSummary.ContentInstalled = ImportContentBase(compiledPackage.Documents, importedDocTypes, userId, _contentTypeService, _contentService);
|
||||
installationSummary.MediaInstalled = ImportContentBase(compiledPackage.Media, importedMediaTypes, userId, _mediaTypeService, _mediaService);
|
||||
|
||||
@@ -1243,18 +1250,43 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
/// <param name="macroElements">Xml to import</param>
|
||||
/// <param name="userId">Optional id of the User performing the operation</param>
|
||||
/// <returns></returns>
|
||||
public IReadOnlyList<IMacro> ImportMacros(IEnumerable<XElement> macroElements, int userId)
|
||||
public IReadOnlyList<IMacro> ImportMacros(
|
||||
IEnumerable<XElement> macroElements,
|
||||
IEnumerable<XElement> macroPartialViewsElements,
|
||||
int userId)
|
||||
{
|
||||
var macros = macroElements.Select(ParseMacroElement).ToList();
|
||||
|
||||
foreach (var macro in macros)
|
||||
foreach (IMacro macro in macros)
|
||||
{
|
||||
_macroService.Save(macro, userId);
|
||||
}
|
||||
|
||||
ImportMacroPartialViews(macroPartialViewsElements);
|
||||
|
||||
return macros;
|
||||
}
|
||||
|
||||
private void ImportMacroPartialViews(IEnumerable<XElement> viewElements)
|
||||
{
|
||||
foreach (XElement element in viewElements)
|
||||
{
|
||||
var path = element.AttributeValue<string>("path");
|
||||
if (path == null)
|
||||
{
|
||||
throw new InvalidOperationException("No path attribute found");
|
||||
}
|
||||
var contents = element.Value ?? string.Empty;
|
||||
|
||||
var physicalPath = _hostingEnvironment.MapPathContentRoot(path);
|
||||
// TODO: Do we overwrite? IMO I don't think so since these will be views a user will change.
|
||||
if (!System.IO.File.Exists(physicalPath))
|
||||
{
|
||||
System.IO.File.WriteAllText(physicalPath, contents, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMacro ParseMacroElement(XElement macroElement)
|
||||
{
|
||||
var macroKey = Guid.Parse(macroElement.Element("key").Value);
|
||||
@@ -1335,30 +1367,94 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
|
||||
#endregion
|
||||
|
||||
public IReadOnlyList<IScript> ImportScripts(IEnumerable<XElement> scriptElements, int userId)
|
||||
{
|
||||
var result = new List<IScript>();
|
||||
|
||||
foreach (XElement scriptXml in scriptElements)
|
||||
{
|
||||
var path = scriptXml.AttributeValue<string>("path");
|
||||
|
||||
if (path.IsNullOrWhiteSpace())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IScript script = _fileService.GetScript(path);
|
||||
|
||||
// only update if it doesn't exist
|
||||
if (script == null)
|
||||
{
|
||||
var content = scriptXml.Value;
|
||||
if (content == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
script = new Script(path) { Content = content };
|
||||
_fileService.SaveScript(script, userId);
|
||||
result.Add(script);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IReadOnlyList<IPartialView> ImportPartialViews(IEnumerable<XElement> partialViewElements, int userId)
|
||||
{
|
||||
var result = new List<IPartialView>();
|
||||
|
||||
foreach (XElement partialViewXml in partialViewElements)
|
||||
{
|
||||
var path = partialViewXml.AttributeValue<string>("path");
|
||||
|
||||
if (path == null)
|
||||
{
|
||||
throw new InvalidOperationException("No path attribute found");
|
||||
}
|
||||
|
||||
IPartialView partialView = _fileService.GetPartialView(path);
|
||||
|
||||
// only update if it doesn't exist
|
||||
if (partialView == null)
|
||||
{
|
||||
var content = partialViewXml.Value ?? string.Empty;
|
||||
|
||||
partialView = new PartialView(PartialViewType.PartialView, path) { Content = content };
|
||||
_fileService.SavePartialView(partialView, userId);
|
||||
result.Add(partialView);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#region Stylesheets
|
||||
|
||||
public IReadOnlyList<IFile> ImportStylesheets(IEnumerable<XElement> stylesheetElements, int userId)
|
||||
{
|
||||
var result = new List<IFile>();
|
||||
|
||||
foreach (var n in stylesheetElements)
|
||||
foreach (XElement n in stylesheetElements)
|
||||
{
|
||||
var stylesheetName = n.Element("Name")?.Value;
|
||||
if (stylesheetName.IsNullOrWhiteSpace())
|
||||
continue;
|
||||
var stylesheetPath = n.Element("FileName")?.Value;
|
||||
|
||||
var s = _fileService.GetStylesheetByName(stylesheetName);
|
||||
if (stylesheetPath.IsNullOrWhiteSpace())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IStylesheet s = _fileService.GetStylesheet(stylesheetPath);
|
||||
if (s == null)
|
||||
{
|
||||
var fileName = n.Element("FileName")?.Value;
|
||||
if (fileName == null)
|
||||
continue;
|
||||
var content = n.Element("Content")?.Value;
|
||||
if (content == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
s = new Stylesheet(fileName) { Content = content };
|
||||
_fileService.SaveStylesheet(s);
|
||||
s = new Stylesheet(stylesheetPath) { Content = content };
|
||||
_fileService.SaveStylesheet(s, userId);
|
||||
}
|
||||
|
||||
foreach (var prop in n.XPathSelectElements("Properties/Property"))
|
||||
@@ -1386,7 +1482,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
|
||||
sp.Alias = alias;
|
||||
sp.Value = prop.Element("Value")?.Value;
|
||||
}
|
||||
_fileService.SaveStylesheet(s);
|
||||
_fileService.SaveStylesheet(s, userId);
|
||||
result.Add(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,13 +264,18 @@ namespace Umbraco.Cms.Core.Services.Implement
|
||||
return xml;
|
||||
}
|
||||
|
||||
public XElement Serialize(Stylesheet stylesheet)
|
||||
public XElement Serialize(IStylesheet stylesheet, bool includeProperties)
|
||||
{
|
||||
var xml = new XElement("Stylesheet",
|
||||
new XElement("Name", stylesheet.Alias),
|
||||
new XElement("FileName", stylesheet.Path),
|
||||
new XElement("Content", new XCData(stylesheet.Content)));
|
||||
|
||||
if (!includeProperties)
|
||||
{
|
||||
return xml;
|
||||
}
|
||||
|
||||
var props = new XElement("Properties");
|
||||
xml.Add(props);
|
||||
|
||||
|
||||
@@ -56,20 +56,20 @@ namespace Umbraco.Cms.Core.Services.Implement
|
||||
#region Stylesheets
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IStylesheet> GetStylesheets(params string[] names)
|
||||
public IEnumerable<IStylesheet> GetStylesheets(params string[] paths)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _stylesheetRepository.GetMany(names);
|
||||
return _stylesheetRepository.GetMany(paths);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IStylesheet GetStylesheetByName(string name)
|
||||
public IStylesheet GetStylesheet(string path)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _stylesheetRepository.Get(name);
|
||||
return _stylesheetRepository.Get(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,16 @@ namespace Umbraco.Cms.Core.Services.Implement
|
||||
#region Scripts
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScript GetScriptByName(string name)
|
||||
public IEnumerable<IScript> GetScripts(params string[] names)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _scriptRepository.GetMany(names);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScript GetScript(string name)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -647,6 +656,14 @@ namespace Umbraco.Cms.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IPartialView> GetPartialViews(params string[] names)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _partialViewRepository.GetMany(names);
|
||||
}
|
||||
}
|
||||
|
||||
public IPartialView GetPartialView(string path)
|
||||
{
|
||||
using (IScope scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Packaging
|
||||
|
||||
private MediaFileManager MediaFileManager => GetRequiredService<MediaFileManager>();
|
||||
|
||||
private FileSystems FileSystems => GetRequiredService<FileSystems>();
|
||||
|
||||
public ICreatedPackagesRepository PackageBuilder => new PackagesRepository(
|
||||
ContentService,
|
||||
ContentTypeService,
|
||||
@@ -72,6 +74,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Packaging
|
||||
MediaService,
|
||||
MediaTypeService,
|
||||
MediaFileManager,
|
||||
FileSystems,
|
||||
"createdPackages.config",
|
||||
|
||||
// temp paths
|
||||
|
||||
@@ -648,7 +648,10 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
|
||||
XElement macrosElement = xml.Descendants("Macros").First();
|
||||
|
||||
// Act
|
||||
var macros = PackageDataInstallation.ImportMacros(macrosElement.Elements("macro"), 0).ToList();
|
||||
var macros = PackageDataInstallation.ImportMacros(
|
||||
macrosElement.Elements("macro"),
|
||||
Enumerable.Empty<XElement>(),
|
||||
0).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(macros.Any(), Is.True);
|
||||
@@ -669,7 +672,10 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
|
||||
XElement macrosElement = xml.Descendants("Macros").First();
|
||||
|
||||
// Act
|
||||
var macros = PackageDataInstallation.ImportMacros(macrosElement.Elements("macro"), 0).ToList();
|
||||
var macros = PackageDataInstallation.ImportMacros(
|
||||
macrosElement.Elements("macro"),
|
||||
Enumerable.Empty<XElement>(),
|
||||
0).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(macros.Any(), Is.True);
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
break;
|
||||
case Constants.Trees.Scripts:
|
||||
var script = _fileService.GetScriptByName(virtualPath);
|
||||
var script = _fileService.GetScript(virtualPath);
|
||||
if (script != null)
|
||||
{
|
||||
var display = _umbracoMapper.Map<IScript, CodeFileDisplay>(script);
|
||||
@@ -224,7 +224,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
break;
|
||||
case Constants.Trees.Stylesheets:
|
||||
var stylesheet = _fileService.GetStylesheetByName(virtualPath);
|
||||
var stylesheet = _fileService.GetStylesheet(virtualPath);
|
||||
if (stylesheet != null)
|
||||
{
|
||||
var display = _umbracoMapper.Map<IStylesheet, CodeFileDisplay>(stylesheet);
|
||||
@@ -371,7 +371,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
_fileService.DeleteScriptFolder(virtualPath);
|
||||
return Ok();
|
||||
}
|
||||
if (_fileService.GetScriptByName(virtualPath) != null)
|
||||
if (_fileService.GetScript(virtualPath) != null)
|
||||
{
|
||||
_fileService.DeleteScript(virtualPath, currentUser.Id);
|
||||
return Ok();
|
||||
@@ -383,7 +383,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
_fileService.DeleteStyleSheetFolder(virtualPath);
|
||||
return Ok();
|
||||
}
|
||||
if (_fileService.GetStylesheetByName(virtualPath) != null)
|
||||
if (_fileService.GetStylesheet(virtualPath) != null)
|
||||
{
|
||||
_fileService.DeleteStylesheet(virtualPath, currentUser.Id);
|
||||
return Ok();
|
||||
@@ -540,7 +540,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
private IScript CreateOrUpdateScript(CodeFileDisplay display)
|
||||
{
|
||||
return CreateOrUpdateFile(display, ".js", _fileSystems.ScriptsFileSystem,
|
||||
name => _fileService.GetScriptByName(name),
|
||||
name => _fileService.GetScript(name),
|
||||
(script, userId) => _fileService.SaveScript(script, userId),
|
||||
name => new Script(name));
|
||||
}
|
||||
@@ -548,7 +548,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
private IStylesheet CreateOrUpdateStylesheet(CodeFileDisplay display)
|
||||
{
|
||||
return CreateOrUpdateFile(display, ".css", _fileSystems.StylesheetsFileSystem,
|
||||
name => _fileService.GetStylesheetByName(name),
|
||||
name => _fileService.GetStylesheet(name),
|
||||
(stylesheet, userId) => _fileService.SaveStylesheet(stylesheet, userId),
|
||||
name => new Stylesheet(name)
|
||||
);
|
||||
|
||||
@@ -545,7 +545,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
//now we need to convert the unknown ones
|
||||
switch (type)
|
||||
{
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -705,7 +704,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
case UmbracoEntityTypes.PropertyType:
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -791,7 +789,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
case UmbracoEntityTypes.PropertyType:
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -835,7 +832,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
//now we need to convert the unknown ones
|
||||
switch (entityType)
|
||||
{
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -902,7 +898,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
case UmbracoEntityTypes.PropertyType:
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -934,7 +929,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
case UmbracoEntityTypes.PropertyType:
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -966,7 +960,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
case UmbracoEntityTypes.PropertyType:
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Language:
|
||||
case UmbracoEntityTypes.User:
|
||||
case UmbracoEntityTypes.Macro:
|
||||
@@ -994,8 +987,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
|
||||
case UmbracoEntityTypes.Domain:
|
||||
|
||||
case UmbracoEntityTypes.Language:
|
||||
|
||||
case UmbracoEntityTypes.User:
|
||||
@@ -1026,8 +1017,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
case UmbracoEntityTypes.PropertyGroup:
|
||||
|
||||
case UmbracoEntityTypes.Domain:
|
||||
|
||||
case UmbracoEntityTypes.Language:
|
||||
|
||||
case UmbracoEntityTypes.User:
|
||||
@@ -1140,6 +1129,20 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
return _fileService.GetStylesheets().Select(MapEntities());
|
||||
|
||||
case UmbracoEntityTypes.Script:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace())
|
||||
throw new NotSupportedException("Filtering on scripts is not currently supported");
|
||||
|
||||
return _fileService.GetScripts().Select(MapEntities());
|
||||
|
||||
case UmbracoEntityTypes.PartialView:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace())
|
||||
throw new NotSupportedException("Filtering on partial views is not currently supported");
|
||||
|
||||
return _fileService.GetPartialViews().Select(MapEntities());
|
||||
|
||||
case UmbracoEntityTypes.Language:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace())
|
||||
@@ -1153,7 +1156,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
return GetAllDictionaryItems();
|
||||
|
||||
case UmbracoEntityTypes.Domain:
|
||||
default:
|
||||
throw new NotSupportedException("The " + typeof(EntityController) + " does not currently support data for the type " + entityType);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
ILogger<MacrosController> logger,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IUmbracoMapper umbracoMapper
|
||||
)
|
||||
IUmbracoMapper umbracoMapper)
|
||||
{
|
||||
_parameterEditorCollection = parameterEditorCollection ?? throw new ArgumentNullException(nameof(parameterEditorCollection));
|
||||
_macroService = macroService ?? throw new ArgumentNullException(nameof(macroService));
|
||||
@@ -315,6 +314,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
/// </returns>
|
||||
private IEnumerable<string> FindPartialViewFilesInViewsFolder()
|
||||
{
|
||||
// TODO: This is inconsistent. We have FileSystems.MacroPartialsFileSystem but we basically don't use
|
||||
// that at all except to render the tree. In the future we may want to use it. This also means that
|
||||
// we are storing the virtual path of the macro like ~/Views/MacroPartials/Login.cshtml instead of the
|
||||
// relative path which would work with the FileSystems.MacroPartialsFileSystem, but these are incompatible.
|
||||
// At some point this should all be made consistent and probably just use FileSystems.MacroPartialsFileSystem.
|
||||
|
||||
var partialsDir = _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MacroPartials);
|
||||
|
||||
return this.FindPartialViewFilesInFolder(
|
||||
|
||||
@@ -75,10 +75,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
return package;
|
||||
}
|
||||
|
||||
public PackageDefinition GetEmpty()
|
||||
{
|
||||
return new PackageDefinition();
|
||||
}
|
||||
public PackageDefinition GetEmpty() => new PackageDefinition();
|
||||
|
||||
/// <summary>
|
||||
/// Creates or updates a package
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
|
||||
public IEnumerable<StylesheetRule> GetRulesByName(string name)
|
||||
{
|
||||
var css = _fileService.GetStylesheetByName(name.EnsureEndsWith(".css"));
|
||||
var css = _fileService.GetStylesheet(name.EnsureEndsWith(".css"));
|
||||
if (css == null)
|
||||
return Enumerable.Empty<StylesheetRule>();
|
||||
|
||||
|
||||
@@ -1,401 +1,443 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, packageResource, editorService, formHelper, localizationService) {
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, packageResource, editorService, formHelper, localizationService) {
|
||||
|
||||
const vm = this;
|
||||
const vm = this;
|
||||
|
||||
const packageId = $routeParams.id;
|
||||
const create = $routeParams.create;
|
||||
const packageId = $routeParams.id;
|
||||
const create = $routeParams.create;
|
||||
|
||||
vm.showBackButton = true;
|
||||
vm.showBackButton = true;
|
||||
|
||||
// open all expansion panels
|
||||
vm.loading = true;
|
||||
vm.mediaNodeDisplayModels = [];
|
||||
vm.back = back;
|
||||
vm.createOrUpdatePackage = createOrUpdatePackage;
|
||||
vm.removeContentItem = removeContentItem;
|
||||
vm.openContentPicker = openContentPicker;
|
||||
vm.openViewPicker = openViewPicker;
|
||||
vm.removePackageView = removePackageView;
|
||||
vm.downloadFile = downloadFile;
|
||||
// open all expansion panels
|
||||
vm.loading = true;
|
||||
vm.mediaNodeDisplayModels = [];
|
||||
vm.back = back;
|
||||
vm.createOrUpdatePackage = createOrUpdatePackage;
|
||||
vm.removeContentItem = removeContentItem;
|
||||
vm.openContentPicker = openContentPicker;
|
||||
vm.openViewPicker = openViewPicker;
|
||||
vm.removePackageView = removePackageView;
|
||||
vm.downloadFile = downloadFile;
|
||||
|
||||
vm.selectDocumentType = selectDocumentType;
|
||||
vm.selectMediaType = selectMediaType;
|
||||
vm.selectTemplate = selectTemplate;
|
||||
vm.selectStyleSheet = selectStyleSheet;
|
||||
vm.selectMacro = selectMacro;
|
||||
vm.selectLanguage = selectLanguage;
|
||||
vm.selectDictionaryItem = selectDictionaryItem;
|
||||
vm.selectDataType = selectDataType;
|
||||
vm.selectDocumentType = selectDocumentType;
|
||||
vm.selectMediaType = selectMediaType;
|
||||
vm.selectTemplate = selectTemplate;
|
||||
vm.selectStyleSheet = selectStyleSheet;
|
||||
vm.selectScript = selectScript;
|
||||
vm.selectPartialView = selectPartialView;
|
||||
vm.selectMacro = selectMacro;
|
||||
vm.selectLanguage = selectLanguage;
|
||||
vm.selectDictionaryItem = selectDictionaryItem;
|
||||
vm.selectDataType = selectDataType;
|
||||
|
||||
vm.mediaPickerModel = {
|
||||
hideLabel: true,
|
||||
view: "mediapicker",
|
||||
value: "",
|
||||
config: {
|
||||
multiPicker: true,
|
||||
allowEdit:false
|
||||
}
|
||||
}
|
||||
vm.labels = {};
|
||||
|
||||
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
|
||||
|
||||
vm.aceOption = {
|
||||
mode: "xml",
|
||||
theme: "chrome",
|
||||
showPrintMargin: false,
|
||||
advanced: {
|
||||
fontSize: '14px',
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: false
|
||||
},
|
||||
onLoad: function (_editor) {
|
||||
vm.editor = _editor;
|
||||
|
||||
vm.editor.setValue(vm.package.actions);
|
||||
}
|
||||
};
|
||||
|
||||
function onInit() {
|
||||
|
||||
if (create) {
|
||||
// Pre populate package with some values
|
||||
packageResource.getEmpty().then(scaffold => {
|
||||
vm.package = scaffold;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
});
|
||||
|
||||
localizationService.localizeMany(["general_create", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
} else {
|
||||
// Load package
|
||||
packageResource.getCreatedById(packageId).then(createdPackage => {
|
||||
vm.package = createdPackage;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
|
||||
// Get render model for content node
|
||||
if (vm.package.contentNodeId) {
|
||||
entityResource.getById(vm.package.contentNodeId, "Document")
|
||||
.then((entity) => {
|
||||
vm.contentNodeDisplayModel = entity;
|
||||
});
|
||||
}
|
||||
|
||||
vm.mediaPickerModel.value = vm.package.mediaUdis.join(',');
|
||||
});
|
||||
|
||||
|
||||
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadResources() {
|
||||
|
||||
// Get all document types
|
||||
entityResource.getAll("DocumentType").then(documentTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
documentTypes.forEach(documentType => {
|
||||
documentType.id = documentType.id.toString();
|
||||
documentType.selected = vm.package.documentTypes.indexOf(documentType.id) !== -1;
|
||||
});
|
||||
vm.documentTypes = documentTypes;
|
||||
});
|
||||
|
||||
// Get all media types
|
||||
entityResource.getAll("MediaType").then(mediaTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
mediaTypes.forEach(mediaType => {
|
||||
mediaType.id = mediaType.id.toString();
|
||||
mediaType.selected = vm.package.mediaTypes.indexOf(mediaType.id) !== -1;
|
||||
});
|
||||
vm.mediaTypes = mediaTypes;
|
||||
});
|
||||
|
||||
// Get all templates
|
||||
entityResource.getAll("Template").then(templates => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
templates.forEach(template => {
|
||||
template.id = template.id.toString();
|
||||
template.selected = vm.package.templates.indexOf(template.id) >= 0;
|
||||
});
|
||||
vm.templates = templates;
|
||||
});
|
||||
|
||||
// Get all stylesheets
|
||||
entityResource.getAll("Stylesheet").then(stylesheets => {
|
||||
stylesheets.forEach(stylesheet => {
|
||||
stylesheet.selected = vm.package.stylesheets.indexOf(stylesheet.name) >= 0;
|
||||
});
|
||||
vm.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
// Get all macros
|
||||
entityResource.getAll("Macro").then(macros => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
macros.forEach(macro => {
|
||||
macro.id = macro.id.toString();
|
||||
macro.selected = vm.package.macros.indexOf(macro.id) !== -1;
|
||||
});
|
||||
vm.macros = macros;
|
||||
});
|
||||
|
||||
// Get all languages
|
||||
entityResource.getAll("Language").then(languages => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
languages.forEach(language => {
|
||||
language.id = language.id.toString();
|
||||
language.selected = vm.package.languages.indexOf(language.id) !== -1;
|
||||
});
|
||||
vm.languages = languages;
|
||||
});
|
||||
|
||||
// Get all dictionary items
|
||||
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dictionaryItems.forEach(dictionaryItem => {
|
||||
dictionaryItem.id = dictionaryItem.id.toString();
|
||||
dictionaryItem.selected = vm.package.dictionaryItems.indexOf(dictionaryItem.id) !== -1;
|
||||
});
|
||||
vm.dictionaryItems = dictionaryItems;
|
||||
});
|
||||
|
||||
// Get all data types
|
||||
entityResource.getAll("DataType").then(dataTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dataTypes.forEach(dataType => {
|
||||
dataType.id = dataType.id.toString();
|
||||
dataType.selected = vm.package.dataTypes.indexOf(dataType.id) !== -1;
|
||||
});
|
||||
vm.dataTypes = dataTypes;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function downloadFile(id) {
|
||||
var url = umbRequestHelper.getApiUrl(
|
||||
"packageApiBaseUrl",
|
||||
"DownloadCreatedPackage",
|
||||
{ id: id });
|
||||
|
||||
umbRequestHelper.downloadFile(url).then(function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function back() {
|
||||
$location.path("packages/packages/created").search("create", null).search("packageId", null);
|
||||
}
|
||||
|
||||
function createOrUpdatePackage(editPackageForm) {
|
||||
|
||||
// Split by comma and remove empty entries
|
||||
vm.package.mediaUdis = vm.mediaPickerModel.value.split(",").filter(i => i);
|
||||
if (formHelper.submitForm({ formCtrl: editPackageForm, scope: $scope })) {
|
||||
|
||||
vm.buttonState = "busy";
|
||||
|
||||
packageResource.savePackage(vm.package).then((updatedPackage) => {
|
||||
|
||||
vm.package = updatedPackage;
|
||||
vm.buttonState = "success";
|
||||
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm });
|
||||
|
||||
if (create) {
|
||||
//if we are creating, then redirect to the correct url and reload
|
||||
$location.path("packages/packages/edit/" + vm.package.id).search("create", null);
|
||||
//don't add a browser history for this
|
||||
$location.replace();
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm, hasErrors: true });
|
||||
formHelper.handleError(err);
|
||||
vm.buttonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeContentItem() {
|
||||
vm.package.contentNodeId = null;
|
||||
}
|
||||
|
||||
function openContentPicker() {
|
||||
const contentPicker = {
|
||||
submit: function (model) {
|
||||
if (model.selection && model.selection.length > 0) {
|
||||
vm.package.contentNodeId = model.selection[0].id.toString();
|
||||
vm.contentNodeDisplayModel = model.selection[0];
|
||||
}
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.contentPicker(contentPicker);
|
||||
vm.mediaPickerModel = {
|
||||
hideLabel: true,
|
||||
view: "mediapicker",
|
||||
value: "",
|
||||
config: {
|
||||
multiPicker: true,
|
||||
allowEdit: false
|
||||
}
|
||||
}
|
||||
vm.labels = {};
|
||||
|
||||
function openViewPicker() {
|
||||
const controlPicker = {
|
||||
title: "Select view",
|
||||
section: "settings",
|
||||
treeAlias: "files",
|
||||
entityType: "file",
|
||||
onlyInitialized: false,
|
||||
filter: function (i) {
|
||||
if (i.name.indexOf(".html") === -1 &&
|
||||
i.name.indexOf(".htm") === -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
filterCssClass: "not-allowed",
|
||||
select: function (node) {
|
||||
const id = decodeURIComponent(node.id.replace(/\+/g, " "));
|
||||
vm.package.packageView = id;
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.treePicker(controlPicker);
|
||||
}
|
||||
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
|
||||
|
||||
function removePackageView() {
|
||||
vm.package.packageView = null;
|
||||
}
|
||||
vm.aceOption = {
|
||||
mode: "xml",
|
||||
theme: "chrome",
|
||||
showPrintMargin: false,
|
||||
advanced: {
|
||||
fontSize: '14px',
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: false
|
||||
},
|
||||
onLoad: function (_editor) {
|
||||
vm.editor = _editor;
|
||||
|
||||
function selectDocumentType(doctype) {
|
||||
vm.editor.setValue(vm.package.actions);
|
||||
}
|
||||
};
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.documentTypes.indexOf(doctype.id);
|
||||
function onInit() {
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.documentTypes.push(doctype.id);
|
||||
} else {
|
||||
vm.package.documentTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
if (create) {
|
||||
// Pre populate package with some values
|
||||
packageResource.getEmpty().then(scaffold => {
|
||||
vm.package = scaffold;
|
||||
|
||||
function selectMediaType(mediatype) {
|
||||
loadResources();
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.mediaTypes.indexOf(mediatype.id);
|
||||
vm.loading = false;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.mediaTypes.push(mediatype.id);
|
||||
} else {
|
||||
vm.package.mediaTypes.splice(index, 1);
|
||||
localizationService.localizeMany(["general_create", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
} else {
|
||||
// Load package
|
||||
packageResource.getCreatedById(packageId).then(createdPackage => {
|
||||
vm.package = createdPackage;
|
||||
|
||||
loadResources();
|
||||
|
||||
vm.loading = false;
|
||||
|
||||
// Get render model for content node
|
||||
if (vm.package.contentNodeId) {
|
||||
entityResource.getById(vm.package.contentNodeId, "Document")
|
||||
.then((entity) => {
|
||||
vm.contentNodeDisplayModel = entity;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selectTemplate(template) {
|
||||
vm.mediaPickerModel.value = vm.package.mediaUdis.join(',');
|
||||
});
|
||||
|
||||
// Check if the template is already selected.
|
||||
var index = vm.package.templates.indexOf(template.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.templates.push(template.id);
|
||||
} else {
|
||||
vm.package.templates.splice(index, 1);
|
||||
}
|
||||
}
|
||||
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
|
||||
vm.labels.button = values[0];
|
||||
vm.labels.includeAllChildNodes = values[1];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selectStyleSheet(stylesheet) {
|
||||
function loadResources() {
|
||||
|
||||
// Check if the style sheet is already selected.
|
||||
var index = vm.package.stylesheets.indexOf(stylesheet.name);
|
||||
// Get all document types
|
||||
entityResource.getAll("DocumentType").then(documentTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
documentTypes.forEach(documentType => {
|
||||
documentType.id = documentType.id.toString();
|
||||
documentType.selected = vm.package.documentTypes.indexOf(documentType.id) !== -1;
|
||||
});
|
||||
vm.documentTypes = documentTypes;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.stylesheets.push(stylesheet.name);
|
||||
} else {
|
||||
vm.package.stylesheets.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all media types
|
||||
entityResource.getAll("MediaType").then(mediaTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
mediaTypes.forEach(mediaType => {
|
||||
mediaType.id = mediaType.id.toString();
|
||||
mediaType.selected = vm.package.mediaTypes.indexOf(mediaType.id) !== -1;
|
||||
});
|
||||
vm.mediaTypes = mediaTypes;
|
||||
});
|
||||
|
||||
function selectMacro(macro) {
|
||||
// Get all templates
|
||||
entityResource.getAll("Template").then(templates => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
templates.forEach(template => {
|
||||
template.id = template.id.toString();
|
||||
template.selected = vm.package.templates.indexOf(template.id) >= 0;
|
||||
});
|
||||
vm.templates = templates;
|
||||
});
|
||||
|
||||
// Check if the macro is already selected.
|
||||
var index = vm.package.macros.indexOf(macro.id);
|
||||
// Get all stylesheets
|
||||
entityResource.getAll("Stylesheet").then(stylesheets => {
|
||||
stylesheets.forEach(stylesheet => {
|
||||
stylesheet.selected = vm.package.stylesheets.indexOf(stylesheet.path) >= 0;
|
||||
});
|
||||
vm.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.macros.push(macro.id);
|
||||
} else {
|
||||
vm.package.macros.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all scripts
|
||||
entityResource.getAll("Script").then(scripts => {
|
||||
scripts.forEach(script => {
|
||||
script.selected = vm.package.scripts.indexOf(script.path) >= 0;
|
||||
});
|
||||
vm.scripts = scripts;
|
||||
});
|
||||
|
||||
function selectLanguage(language) {
|
||||
// Get all partial views
|
||||
entityResource.getAll("PartialView").then(partialViews => {
|
||||
partialViews.forEach(view => {
|
||||
view.selected = vm.package.partialViews.indexOf(view.path) >= 0;
|
||||
});
|
||||
vm.partialViews = partialViews;
|
||||
});
|
||||
|
||||
// Check if the language is already selected.
|
||||
var index = vm.package.languages.indexOf(language.id);
|
||||
// Get all macros
|
||||
entityResource.getAll("Macro").then(macros => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
macros.forEach(macro => {
|
||||
macro.id = macro.id.toString();
|
||||
macro.selected = vm.package.macros.indexOf(macro.id) !== -1;
|
||||
});
|
||||
vm.macros = macros;
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.languages.push(language.id);
|
||||
} else {
|
||||
vm.package.languages.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Get all languages
|
||||
entityResource.getAll("Language").then(languages => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
languages.forEach(language => {
|
||||
language.id = language.id.toString();
|
||||
language.selected = vm.package.languages.indexOf(language.id) !== -1;
|
||||
});
|
||||
vm.languages = languages;
|
||||
});
|
||||
|
||||
function selectDictionaryItem(dictionaryItem) {
|
||||
// Get all dictionary items
|
||||
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dictionaryItems.forEach(dictionaryItem => {
|
||||
dictionaryItem.id = dictionaryItem.id.toString();
|
||||
dictionaryItem.selected = vm.package.dictionaryItems.indexOf(dictionaryItem.id) !== -1;
|
||||
});
|
||||
vm.dictionaryItems = dictionaryItems;
|
||||
});
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dictionaryItems.indexOf(dictionaryItem.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dictionaryItems.push(dictionaryItem.id);
|
||||
} else {
|
||||
vm.package.dictionaryItems.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDataType(dataType) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dataTypes.indexOf(dataType.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dataTypes.push(dataType.id);
|
||||
} else {
|
||||
vm.package.dataTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function getVals(array) {
|
||||
var vals = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
vals.push({ value: array[i] });
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
|
||||
onInit();
|
||||
// Get all data types
|
||||
entityResource.getAll("DataType").then(dataTypes => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dataTypes.forEach(dataType => {
|
||||
dataType.id = dataType.id.toString();
|
||||
dataType.selected = vm.package.dataTypes.indexOf(dataType.id) !== -1;
|
||||
});
|
||||
vm.dataTypes = dataTypes;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Packages.EditController", EditController);
|
||||
function downloadFile(id) {
|
||||
var url = umbRequestHelper.getApiUrl(
|
||||
"packageApiBaseUrl",
|
||||
"DownloadCreatedPackage",
|
||||
{ id: id });
|
||||
|
||||
umbRequestHelper.downloadFile(url).then(function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function back() {
|
||||
$location.path("packages/packages/created").search("create", null).search("packageId", null);
|
||||
}
|
||||
|
||||
function createOrUpdatePackage(editPackageForm) {
|
||||
|
||||
// Split by comma and remove empty entries
|
||||
vm.package.mediaUdis = vm.mediaPickerModel.value.split(",").filter(i => i);
|
||||
if (formHelper.submitForm({ formCtrl: editPackageForm, scope: $scope })) {
|
||||
|
||||
vm.buttonState = "busy";
|
||||
|
||||
packageResource.savePackage(vm.package).then((updatedPackage) => {
|
||||
|
||||
vm.package = updatedPackage;
|
||||
vm.buttonState = "success";
|
||||
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm });
|
||||
|
||||
if (create) {
|
||||
//if we are creating, then redirect to the correct url and reload
|
||||
$location.path("packages/packages/edit/" + vm.package.id).search("create", null);
|
||||
//don't add a browser history for this
|
||||
$location.replace();
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
formHelper.resetForm({ scope: $scope, formCtrl: editPackageForm, hasErrors: true });
|
||||
formHelper.handleError(err);
|
||||
vm.buttonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeContentItem() {
|
||||
vm.package.contentNodeId = null;
|
||||
}
|
||||
|
||||
function openContentPicker() {
|
||||
const contentPicker = {
|
||||
submit: function (model) {
|
||||
if (model.selection && model.selection.length > 0) {
|
||||
vm.package.contentNodeId = model.selection[0].id.toString();
|
||||
vm.contentNodeDisplayModel = model.selection[0];
|
||||
}
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.contentPicker(contentPicker);
|
||||
}
|
||||
|
||||
function openViewPicker() {
|
||||
const controlPicker = {
|
||||
title: "Select view",
|
||||
section: "settings",
|
||||
treeAlias: "files",
|
||||
entityType: "file",
|
||||
onlyInitialized: false,
|
||||
filter: function (i) {
|
||||
if (i.name.indexOf(".html") === -1 &&
|
||||
i.name.indexOf(".htm") === -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
filterCssClass: "not-allowed",
|
||||
select: function (node) {
|
||||
const id = decodeURIComponent(node.id.replace(/\+/g, " "));
|
||||
vm.package.packageView = id;
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
editorService.close();
|
||||
}
|
||||
};
|
||||
editorService.treePicker(controlPicker);
|
||||
}
|
||||
|
||||
function removePackageView() {
|
||||
vm.package.packageView = null;
|
||||
}
|
||||
|
||||
function selectDocumentType(doctype) {
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.documentTypes.indexOf(doctype.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.documentTypes.push(doctype.id);
|
||||
} else {
|
||||
vm.package.documentTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectMediaType(mediatype) {
|
||||
|
||||
// Check if the document type is already selected.
|
||||
var index = vm.package.mediaTypes.indexOf(mediatype.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.mediaTypes.push(mediatype.id);
|
||||
} else {
|
||||
vm.package.mediaTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectTemplate(template) {
|
||||
|
||||
// Check if the template is already selected.
|
||||
var index = vm.package.templates.indexOf(template.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.templates.push(template.id);
|
||||
} else {
|
||||
vm.package.templates.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectStyleSheet(stylesheet) {
|
||||
|
||||
// Check if the style sheet is already selected.
|
||||
var index = vm.package.stylesheets.indexOf(stylesheet.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.stylesheets.push(stylesheet.path);
|
||||
} else {
|
||||
vm.package.stylesheets.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectScript(script) {
|
||||
|
||||
// Check if the script is already selected.
|
||||
var index = vm.package.scripts.indexOf(script.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.scripts.push(script.path);
|
||||
} else {
|
||||
vm.package.scripts.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectPartialView(view) {
|
||||
|
||||
// Check if the view is already selected.
|
||||
var index = vm.package.partialViews.indexOf(view.path);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.partialViews.push(view.path);
|
||||
} else {
|
||||
vm.package.partialViews.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectMacro(macro) {
|
||||
|
||||
// Check if the macro is already selected.
|
||||
var index = vm.package.macros.indexOf(macro.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.macros.push(macro.id);
|
||||
} else {
|
||||
vm.package.macros.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectLanguage(language) {
|
||||
|
||||
// Check if the language is already selected.
|
||||
var index = vm.package.languages.indexOf(language.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.languages.push(language.id);
|
||||
} else {
|
||||
vm.package.languages.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDictionaryItem(dictionaryItem) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dictionaryItems.indexOf(dictionaryItem.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dictionaryItems.push(dictionaryItem.id);
|
||||
} else {
|
||||
vm.package.dictionaryItems.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function selectDataType(dataType) {
|
||||
|
||||
// Check if the dictionary item is already selected.
|
||||
var index = vm.package.dataTypes.indexOf(dataType.id);
|
||||
|
||||
if (index === -1) {
|
||||
vm.package.dataTypes.push(dataType.id);
|
||||
} else {
|
||||
vm.package.dataTypes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function getVals(array) {
|
||||
var vals = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
vals.push({ value: array[i] });
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Packages.EditController", EditController);
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,177 +1,193 @@
|
||||
<div data-element="editor-packages" ng-controller="Umbraco.Editors.Packages.EditController as vm">
|
||||
|
||||
<form name="editPackageForm" no-validate val-form-manager>
|
||||
<form name="editPackageForm" no-validate val-form-manager>
|
||||
|
||||
<umb-editor-view>
|
||||
<umb-editor-view>
|
||||
|
||||
<umb-editor-header
|
||||
name="vm.package.name"
|
||||
on-back="vm.back()"
|
||||
show-back-button="vm.showBackButton"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
<umb-editor-header name="vm.package.name"
|
||||
on-back="vm.back()"
|
||||
show-back-button="vm.showBackButton"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container class="form-horizontal">
|
||||
<umb-editor-container class="form-horizontal">
|
||||
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
|
||||
<div class="umb-expansion-panel">
|
||||
<div class="umb-expansion-panel">
|
||||
|
||||
<div class="umb-expansion-panel__header">
|
||||
<span><localize key="packager_packageContent">Package Content</localize></span>
|
||||
</div>
|
||||
<div class="umb-expansion-panel__header">
|
||||
<span><localize key="packager_packageContent">Package Content</localize></span>
|
||||
</div>
|
||||
|
||||
<div class="umb-expansion-panel__content">
|
||||
<div class="umb-expansion-panel__content">
|
||||
|
||||
<umb-control-group label="@general_content">
|
||||
<umb-control-group label="@general_content">
|
||||
|
||||
<umb-node-preview
|
||||
ng-if="vm.package.contentNodeId"
|
||||
<umb-node-preview ng-if="vm.package.contentNodeId"
|
||||
icon="vm.contentNodeDisplayModel.icon"
|
||||
name="vm.contentNodeDisplayModel.name"
|
||||
allow-edit="true"
|
||||
allow-remove="true"
|
||||
on-edit="vm.openContentPicker()"
|
||||
on-remove="vm.removeContentItem()">
|
||||
</umb-node-preview>
|
||||
</umb-node-preview>
|
||||
|
||||
<button type="button"
|
||||
ng-if="!vm.package.contentNodeId"
|
||||
style="margin-bottom: 10px;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()">
|
||||
<localize key="general_add">Add</localize>
|
||||
</button>
|
||||
<button type="button"
|
||||
ng-if="!vm.package.contentNodeId"
|
||||
style="margin-bottom: 10px;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()">
|
||||
<localize key="general_add">Add</localize>
|
||||
</button>
|
||||
|
||||
<umb-checkbox model="vm.package.contentLoadChildNodes"
|
||||
disabled="!vm.package.contentNodeId"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
<umb-checkbox model="vm.package.contentLoadChildNodes"
|
||||
disabled="!vm.package.contentNodeId"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
|
||||
</umb-control-group>
|
||||
</umb-control-group>
|
||||
|
||||
|
||||
|
||||
<umb-control-group label="@general_media">
|
||||
<umb-control-group label="@general_media">
|
||||
|
||||
|
||||
|
||||
<umb-property property="vm.mediaPickerModel" ng-if="vm.loading === false">
|
||||
<umb-property-editor model="vm.mediaPickerModel" is-pre-value="true"></umb-property-editor>
|
||||
</umb-property>
|
||||
<umb-property property="vm.mediaPickerModel" ng-if="vm.loading === false">
|
||||
<umb-property-editor model="vm.mediaPickerModel" is-pre-value="true"></umb-property-editor>
|
||||
</umb-property>
|
||||
|
||||
<umb-checkbox model="vm.package.mediaLoadChildNodes"
|
||||
disabled="vm.mediaPickerModel.value.length === 0"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
</umb-control-group>
|
||||
<umb-checkbox model="vm.package.mediaLoadChildNodes"
|
||||
disabled="vm.mediaPickerModel.value.length === 0"
|
||||
text="{{vm.labels.includeAllChildNodes}}">
|
||||
</umb-checkbox>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_documentTypes">
|
||||
<div ng-repeat="doctype in ::vm.documentTypes | orderBy:'name'">
|
||||
<umb-checkbox model="doctype.selected"
|
||||
on-change="vm.selectDocumentType(doctype)"
|
||||
text="{{doctype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_documentTypes">
|
||||
<div ng-repeat="doctype in ::vm.documentTypes | orderBy:'name'">
|
||||
<umb-checkbox model="doctype.selected"
|
||||
on-change="vm.selectDocumentType(doctype)"
|
||||
text="{{doctype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_mediaTypes">
|
||||
<div ng-repeat="mediatype in ::vm.mediaTypes | orderBy:'name'">
|
||||
<umb-checkbox model="mediatype.selected"
|
||||
on-change="vm.selectMediaType(mediatype)"
|
||||
text="{{mediatype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_mediaTypes">
|
||||
<div ng-repeat="mediatype in ::vm.mediaTypes | orderBy:'name'">
|
||||
<umb-checkbox model="mediatype.selected"
|
||||
on-change="vm.selectMediaType(mediatype)"
|
||||
text="{{mediatype.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_templates">
|
||||
<div ng-repeat="template in ::vm.templates | orderBy:'name'">
|
||||
<umb-checkbox model="template.selected"
|
||||
on-change="vm.selectTemplate(template)"
|
||||
text="{{template.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_macros">
|
||||
<div ng-repeat="macro in ::vm.macros | orderBy:'name'">
|
||||
<umb-checkbox model="macro.selected"
|
||||
on-change="vm.selectMacro(macro)"
|
||||
text="{{macro.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_stylesheets">
|
||||
<div ng-repeat="stylesheet in ::vm.stylesheets | orderBy:'name'">
|
||||
<umb-checkbox model="stylesheet.selected"
|
||||
on-change="vm.selectStyleSheet(stylesheet)"
|
||||
text="{{stylesheet.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_languages">
|
||||
<div ng-repeat="language in ::vm.languages | orderBy:'name'">
|
||||
<umb-checkbox model="language.selected"
|
||||
on-change="vm.selectLanguage(language)"
|
||||
text="{{language.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_macros">
|
||||
<div ng-repeat="macro in ::vm.macros | orderBy:'name'">
|
||||
<umb-checkbox model="macro.selected"
|
||||
on-change="vm.selectMacro(macro)"
|
||||
text="{{macro.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_dictionary">
|
||||
<div ng-repeat="dictionaryItem in ::vm.dictionaryItems | orderBy:'name'">
|
||||
<umb-checkbox model="dictionaryItem.selected"
|
||||
on-change="vm.selectDictionaryItem(dictionaryItem)"
|
||||
text="{{dictionaryItem.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_languages">
|
||||
<div ng-repeat="language in ::vm.languages | orderBy:'name'">
|
||||
<umb-checkbox model="language.selected"
|
||||
on-change="vm.selectLanguage(language)"
|
||||
text="{{language.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_dataTypes">
|
||||
<div ng-repeat="dataType in ::vm.dataTypes | orderBy:'name'">
|
||||
<umb-checkbox model="dataType.selected"
|
||||
on-change="vm.selectDataType(dataType)"
|
||||
text="{{dataType.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_dictionary">
|
||||
<div ng-repeat="dictionaryItem in ::vm.dictionaryItems | orderBy:'name'">
|
||||
<umb-checkbox model="dictionaryItem.selected"
|
||||
on-change="vm.selectDictionaryItem(dictionaryItem)"
|
||||
text="{{dictionaryItem.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_templates">
|
||||
<div ng-repeat="template in ::vm.templates | orderBy:'name'">
|
||||
<umb-checkbox model="template.selected"
|
||||
on-change="vm.selectTemplate(template)"
|
||||
text="{{template.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@treeHeaders_dataTypes">
|
||||
<div ng-repeat="dataType in ::vm.dataTypes | orderBy:'name'">
|
||||
<umb-checkbox model="dataType.selected"
|
||||
on-change="vm.selectDataType(dataType)"
|
||||
text="{{dataType.name}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
<umb-control-group label="@treeHeaders_stylesheets">
|
||||
<div ng-repeat="stylesheet in ::vm.stylesheets | orderBy:'path'">
|
||||
<umb-checkbox model="stylesheet.selected"
|
||||
on-change="vm.selectStyleSheet(stylesheet)"
|
||||
text="{{stylesheet.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</div>
|
||||
<umb-control-group label="@treeHeaders_scripts">
|
||||
<div ng-repeat="script in ::vm.scripts | orderBy:'path'">
|
||||
<umb-checkbox model="script.selected"
|
||||
on-change="vm.selectScript(script)"
|
||||
text="{{script.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</div>
|
||||
<umb-control-group label="@treeHeaders_partialViews">
|
||||
<div ng-repeat="partialView in ::vm.partialViews | orderBy:'path'">
|
||||
<umb-checkbox model="partialView.selected"
|
||||
on-change="vm.selectPartialView(partialView)"
|
||||
text="{{partialView.path}}">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</umb-control-group>
|
||||
|
||||
</umb-editor-container>
|
||||
</div>
|
||||
|
||||
<umb-editor-footer>
|
||||
</div>
|
||||
|
||||
<umb-editor-footer-content-right>
|
||||
</umb-editor-container>
|
||||
|
||||
<umb-button ng-if="vm.package.packagePath"
|
||||
type="button"
|
||||
action="vm.downloadFile(vm.package.id)"
|
||||
disabled="vm.loading || vm.buttonState=='busy'"
|
||||
button-style="info"
|
||||
label-key="general_download">
|
||||
</umb-button>
|
||||
<umb-editor-footer>
|
||||
|
||||
<umb-button type="button"
|
||||
action="vm.createOrUpdatePackage(editPackageForm)"
|
||||
state="vm.buttonState"
|
||||
button-style="success"
|
||||
label="{{vm.labels.button}}"
|
||||
disabled="vm.loading">
|
||||
</umb-button>
|
||||
<umb-editor-footer-content-right>
|
||||
|
||||
</umb-editor-footer-content-right>
|
||||
<umb-button ng-if="vm.package.packagePath"
|
||||
type="button"
|
||||
action="vm.downloadFile(vm.package.id)"
|
||||
disabled="vm.loading || vm.buttonState=='busy'"
|
||||
button-style="info"
|
||||
label-key="general_download">
|
||||
</umb-button>
|
||||
|
||||
</umb-editor-footer>
|
||||
<umb-button type="button"
|
||||
action="vm.createOrUpdatePackage(editPackageForm)"
|
||||
state="vm.buttonState"
|
||||
button-style="success"
|
||||
label="{{vm.labels.button}}"
|
||||
disabled="vm.loading">
|
||||
</umb-button>
|
||||
|
||||
</umb-editor-view>
|
||||
</umb-editor-footer-content-right>
|
||||
|
||||
</form>
|
||||
</umb-editor-footer>
|
||||
|
||||
</umb-editor-view>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user