Merge branch 'temp8' into temp8-backoffice-search-with-variants

This commit is contained in:
Shannon
2018-12-12 12:06:21 +11:00
20 changed files with 581 additions and 330 deletions
-39
View File
@@ -1,39 +0,0 @@
namespace Umbraco.Core
{
public static class ByteArrayExtensions
{
private static readonly char[] BytesToHexStringLookup = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
public static string ToHexString(this byte[] bytes)
{
int i = 0, p = 0, bytesLength = bytes.Length;
var chars = new char[bytesLength * 2];
while (i < bytesLength)
{
var b = bytes[i++];
chars[p++] = BytesToHexStringLookup[b / 0x10];
chars[p++] = BytesToHexStringLookup[b % 0x10];
}
return new string(chars, 0, chars.Length);
}
public static string ToHexString(this byte[] bytes, char separator, int blockSize, int blockCount)
{
int p = 0, bytesLength = bytes.Length, count = 0, size = 0;
var chars = new char[bytesLength * 2 + blockCount];
for (var i = 0; i < bytesLength; i++)
{
var b = bytes[i++];
chars[p++] = BytesToHexStringLookup[b / 0x10];
chars[p++] = BytesToHexStringLookup[b % 0x10];
if (count == blockCount) continue;
if (++size < blockSize) continue;
chars[p++] = '/';
size = 0;
count++;
}
return new string(chars, 0, chars.Length);
}
}
}
+44
View File
@@ -0,0 +1,44 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Umbraco.Core
{
/// <summary>
/// Utility methods for the <see cref="Guid"/> struct.
/// </summary>
internal static class GuidUtils
{
/// <summary>
/// Combines two guid instances utilizing an exclusive disjunction.
/// The resultant guid is not guaranteed to be unique since the number of unique bits is halved.
/// </summary>
/// <param name="a">The first guid.</param>
/// <param name="b">The seconds guid.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Guid Combine(Guid a, Guid b)
{
var ad = new DecomposedGuid(a);
var bd = new DecomposedGuid(b);
ad.Hi ^= bd.Hi;
ad.Lo ^= bd.Lo;
return ad.Value;
}
/// <summary>
/// A decomposed guid. Allows access to the high and low bits without unsafe code.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
private struct DecomposedGuid
{
[FieldOffset(00)] public Guid Value;
[FieldOffset(00)] public long Hi;
[FieldOffset(08)] public long Lo;
public DecomposedGuid(Guid value) : this() => this.Value = value;
}
}
}
+84
View File
@@ -0,0 +1,84 @@
using System.Linq;
using System.Runtime.CompilerServices;
namespace Umbraco.Core
{
/// <summary>
/// Provides methods for encoding byte arrays into hexidecimal strings.
/// </summary>
internal static class HexEncoder
{
// LUT's that provide the hexidecimal representation of each possible byte value.
private static readonly char[] HexLutBase = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
// The base LUT arranged in 16x each item order. 0 * 16, 1 * 16, .... F * 16
private static readonly char[] HexLutHi = Enumerable.Range(0, 256).Select(x => HexLutBase[x / 0x10]).ToArray();
// The base LUT repeated 16x.
private static readonly char[] HexLutLo = Enumerable.Range(0, 256).Select(x => HexLutBase[x % 0x10]).ToArray();
/// <summary>
/// Converts a <see cref="T:byte[]"/> to a hexidecimal formatted <see cref="string"/> padded to 2 digits.
/// </summary>
/// <param name="bytes">The bytes.</param>
/// <returns>The <see cref="string"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Encode(byte[] bytes)
{
var length = bytes.Length;
var chars = new char[length * 2];
var index = 0;
for (var i = 0; i < length; i++)
{
var byteIndex = bytes[i];
chars[index++] = HexLutHi[byteIndex];
chars[index++] = HexLutLo[byteIndex];
}
return new string(chars, 0, chars.Length);
}
/// <summary>
/// Converts a <see cref="T:byte[]"/> to a hexidecimal formatted <see cref="string"/> padded to 2 digits
/// and split into blocks with the given char separator.
/// </summary>
/// <param name="bytes">The bytes.</param>
/// <param name="separator">The separator.</param>
/// <param name="blockSize">The block size.</param>
/// <param name="blockCount">The block count.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Encode(byte[] bytes, char separator, int blockSize, int blockCount)
{
var length = bytes.Length;
var chars = new char[(length * 2) + blockCount];
var count = 0;
var size = 0;
var index = 0;
for (var i = 0; i < length; i++)
{
var byteIndex = bytes[i];
chars[index++] = HexLutHi[byteIndex];
chars[index++] = HexLutLo[byteIndex];
if (count == blockCount)
{
continue;
}
if (++size < blockSize)
{
continue;
}
chars[index++] = separator;
size = 0;
count++;
}
return new string(chars, 0, chars.Length);
}
}
}
@@ -20,24 +20,11 @@ namespace Umbraco.Core.IO.MediaPathSchemes
{
// assumes that cuid and puid keys can be trusted - and that a single property type
// for a single content cannot store two different files with the same name
var directory = Combine(itemGuid, propertyGuid).ToHexString(/*'/', 2, 4*/); // could use ext to fragment path eg 12/e4/f2/...
var directory = HexEncoder.Encode(GuidUtils.Combine(itemGuid, propertyGuid).ToByteArray()/*'/', 2, 4*/); // could use ext to fragment path eg 12/e4/f2/...
return Path.Combine(directory, filename).Replace('\\', '/');
}
/// <inheritdoc />
public string GetDeleteDirectory(string filepath)
{
return Path.GetDirectoryName(filepath);
}
private static byte[] Combine(Guid guid1, Guid guid2)
{
var bytes1 = guid1.ToByteArray();
var bytes2 = guid2.ToByteArray();
var bytes = new byte[bytes1.Length];
for (var i = 0; i < bytes1.Length; i++)
bytes[i] = (byte) (bytes1[i] ^ bytes2[i]);
return bytes;
}
public string GetDeleteDirectory(string filepath) => Path.GetDirectoryName(filepath);
}
}
+2 -1
View File
@@ -111,7 +111,6 @@
<Compile Include="AttemptOfTResultTStatus.cs" />
<Compile Include="Components\AuditEventsComponent.cs" />
<Compile Include="BindingRedirects.cs" />
<Compile Include="ByteArrayExtensions.cs" />
<Compile Include="Cache\CacheHelper.cs" />
<Compile Include="Cache\CacheKeys.cs" />
<Compile Include="Cache\CacheProviderExtensions.cs" />
@@ -320,6 +319,8 @@
<Compile Include="Events\ExportedMemberEventArgs.cs" />
<Compile Include="Events\RolesEventArgs.cs" />
<Compile Include="Events\UserGroupWithUsers.cs" />
<Compile Include="GuidUtils.cs" />
<Compile Include="HexEncoder.cs" />
<Compile Include="IO\MediaPathSchemes\CombinedGuidsMediaPathScheme.cs" />
<Compile Include="IO\IMediaPathScheme.cs" />
<Compile Include="IO\MediaPathSchemes\OriginalMediaPathScheme.cs" />
+5 -6
View File
@@ -5,18 +5,17 @@ using Umbraco.Core.Models;
namespace Umbraco.Examine
{
/// <summary>
/// Creates a collection of <see cref="ValueSet"/> to be indexed based on a collection of <see cref="TContent"/>
/// Creates a collection of <see cref="ValueSet"/> to be indexed based on a collection of <see cref="T"/>
/// </summary>
/// <typeparam name="TContent"></typeparam>
public interface IValueSetBuilder<in TContent>
where TContent : IContentBase
/// <typeparam name="T"></typeparam>
public interface IValueSetBuilder<in T>
{
/// <summary>
/// Creates a collection of <see cref="ValueSet"/> to be indexed based on a collection of <see cref="TContent"/>
/// Creates a collection of <see cref="ValueSet"/> to be indexed based on a collection of <see cref="T"/>
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
IEnumerable<ValueSet> GetValueSets(params TContent[] content);
IEnumerable<ValueSet> GetValueSets(params T[] content);
}
}
@@ -0,0 +1,48 @@
using System;
using BenchmarkDotNet.Attributes;
using Umbraco.Core;
using Umbraco.Tests.Benchmarks.Config;
namespace Umbraco.Tests.Benchmarks
{
[QuickRunWithMemoryDiagnoserConfig]
public class CombineGuidBenchmarks
{
private static readonly Guid _a = Guid.NewGuid();
private static readonly Guid _b = Guid.NewGuid();
[Benchmark]
public byte[] CombineUtils() => GuidUtils.Combine(_a, _b).ToByteArray();
[Benchmark]
public byte[] CombineLoop() => Combine(_a, _b);
private static byte[] Combine(Guid guid1, Guid guid2)
{
var bytes1 = guid1.ToByteArray();
var bytes2 = guid2.ToByteArray();
var bytes = new byte[bytes1.Length];
for (var i = 0; i < bytes1.Length; i++)
{
bytes[i] = (byte)(bytes1[i] ^ bytes2[i]);
}
return bytes;
}
}
// Nov 8 2018
//BenchmarkDotNet=v0.11.2, OS=Windows 10.0.17763.55 (1809/October2018Update/Redstone5)
//Intel Core i7-6600U CPU 2.60GHz(Skylake), 1 CPU, 4 logical and 2 physical cores
// [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3190.0
// Job-JIATTD : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3190.0
//IterationCount=3 IterationTime=100.0000 ms LaunchCount = 1
//WarmupCount=3
// Method | Mean | Error | StdDev | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
//------------- |---------:|----------:|----------:|------------:|------------:|------------:|--------------------:|
// CombineUtils | 33.34 ns | 8.086 ns | 0.4432 ns | 0.0133 | - | - | 28 B |
// CombineLoop | 55.03 ns | 11.311 ns | 0.6200 ns | 0.0395 | - | - | 84 B |
}
@@ -0,0 +1,69 @@
using System;
using System.Text;
using BenchmarkDotNet.Attributes;
using Umbraco.Core;
using Umbraco.Tests.Benchmarks.Config;
namespace Umbraco.Tests.Benchmarks
{
[QuickRunConfig]
public class HexStringBenchmarks
{
private byte[] _buffer;
[Params(8, 16, 32, 64, 128, 256)]
public int Count { get; set; }
[GlobalSetup]
public void Setup()
{
this._buffer = new byte[this.Count];
var random = new Random();
random.NextBytes(this._buffer);
}
[Benchmark(Baseline = true)]
public string ToHexStringBuilder()
{
var sb = new StringBuilder(this._buffer.Length * 2);
for (var i = 0; i < this._buffer.Length; i++)
{
sb.Append(this._buffer[i].ToString("X2"));
}
return sb.ToString();
}
[Benchmark]
public string ToHexStringEncoder() => HexEncoder.Encode(this._buffer);
}
// Nov 8 2018
//BenchmarkDotNet=v0.11.2, OS=Windows 10.0.17763.55 (1809/October2018Update/Redstone5)
//Intel Core i7-6600U CPU 2.60GHz(Skylake), 1 CPU, 4 logical and 2 physical cores
// [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3190.0
// Job-JIATTD : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.7.3190.0
//IterationCount=3 IterationTime=100.0000 ms LaunchCount = 1
//WarmupCount=3
// Method | Count | Mean | Error | StdDev | Ratio |
//------------------- |------ |-------------:|-------------:|-----------:|------:|
// ToHexStringBuilder | 8 | 786.49 ns | 319.92 ns | 17.536 ns | 1.00 |
// ToHexStringEncoder | 8 | 64.19 ns | 30.21 ns | 1.656 ns | 0.08 |
// | | | | | |
// ToHexStringBuilder | 16 | 1,442.43 ns | 503.00 ns | 27.571 ns | 1.00 |
// ToHexStringEncoder | 16 | 133.46 ns | 177.55 ns | 9.732 ns | 0.09 |
// | | | | | |
// ToHexStringBuilder | 32 | 2,869.23 ns | 924.35 ns | 50.667 ns | 1.00 |
// ToHexStringEncoder | 32 | 181.03 ns | 96.64 ns | 5.297 ns | 0.06 |
// | | | | | |
// ToHexStringBuilder | 64 | 5,775.33 ns | 2,825.42 ns | 154.871 ns | 1.00 |
// ToHexStringEncoder | 64 | 331.16 ns | 125.63 ns | 6.886 ns | 0.06 |
// | | | | | |
// ToHexStringBuilder | 128 | 11,662.35 ns | 4,908.03 ns | 269.026 ns | 1.00 |
// ToHexStringEncoder | 128 | 633.78 ns | 57.56 ns | 3.155 ns | 0.05 |
// | | | | | |
// ToHexStringBuilder | 256 | 22,960.11 ns | 14,111.47 ns | 773.497 ns | 1.00 |
// ToHexStringEncoder | 256 | 1,224.76 ns | 547.27 ns | 29.998 ns | 0.05 |
}
@@ -46,10 +46,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BulkInsertBenchmarks.cs" />
<Compile Include="CombineGuidBenchmarks.cs" />
<Compile Include="ConcurrentDictionaryBenchmarks.cs" />
<Compile Include="Config\QuickRunConfigAttribute.cs" />
<Compile Include="Config\QuickRunWithMemoryDiagnoserConfigAttribute.cs" />
<Compile Include="CtorInvokeBenchmarks.cs" />
<Compile Include="HexStringBenchmarks.cs" />
<Compile Include="EnumeratorBenchmarks.cs" />
<Compile Include="LinqCastBenchmarks.cs" />
<Compile Include="ModelToSqlExpressionHelperBenchmarks.cs" />
@@ -0,0 +1,32 @@
using System;
using NUnit.Framework;
using Umbraco.Core;
namespace Umbraco.Tests.CoreThings
{
public class GuidUtilsTests
{
[Test]
public void GuidCombineMethodsAreEqual()
{
var a = Guid.NewGuid();
var b = Guid.NewGuid();
Assert.AreEqual(GuidUtils.Combine(a, b).ToByteArray(), Combine(a, b));
}
// Reference implementation taken from original code.
private static byte[] Combine(Guid guid1, Guid guid2)
{
var bytes1 = guid1.ToByteArray();
var bytes2 = guid2.ToByteArray();
var bytes = new byte[bytes1.Length];
for (var i = 0; i < bytes1.Length; i++)
{
bytes[i] = (byte)(bytes1[i] ^ bytes2[i]);
}
return bytes;
}
}
}
@@ -0,0 +1,71 @@
using System;
using System.Text;
using NUnit.Framework;
using Umbraco.Core;
namespace Umbraco.Tests.CoreThings
{
public class HexEncoderTests
{
[Test]
public void ToHexStringCreatesCorrectValue()
{
var buffer = new byte[255];
var random = new Random();
random.NextBytes(buffer);
var sb = new StringBuilder(buffer.Length * 2);
for (var i = 0; i < buffer.Length; i++)
{
sb.Append(buffer[i].ToString("X2"));
}
var expected = sb.ToString();
var actual = HexEncoder.Encode(buffer);
Assert.AreEqual(expected, actual);
}
[Test]
public void ToHexStringWithSeparatorCreatesCorrectValue()
{
var buffer = new byte[255];
var random = new Random();
random.NextBytes(buffer);
var expected = ToHexString(buffer, '/', 2, 4);
var actual = HexEncoder.Encode(buffer, '/', 2, 4);
Assert.AreEqual(expected, actual);
}
private static readonly char[] _bytesToHexStringLookup = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
// Reference implementation taken from original extension method.
private static string ToHexString(byte[] bytes, char separator, int blockSize, int blockCount)
{
int p = 0, bytesLength = bytes.Length, count = 0, size = 0;
var chars = new char[(bytesLength * 2) + blockCount];
for (var i = 0; i < bytesLength; i++)
{
var b = bytes[i];
chars[p++] = _bytesToHexStringLookup[b / 0x10];
chars[p++] = _bytesToHexStringLookup[b % 0x10];
if (count == blockCount)
{
continue;
}
if (++size < blockSize)
{
continue;
}
chars[p++] = separator;
size = 0;
count++;
}
return new string(chars, 0, chars.Length);
}
}
}
@@ -148,7 +148,7 @@ namespace Umbraco.Tests.Services
//change the content type to be invariant, we will also update the name here to detect the copy changes
doc.SetCultureName("Hello2", "en-US");
ServiceContext.ContentService.Save(doc);
contentType.Variations = ContentVariation.Nothing;
contentType.Variations = ContentVariation.Nothing;
ServiceContext.ContentTypeService.Save(contentType);
doc = ServiceContext.ContentService.GetById(doc.Id); //re-get
@@ -372,7 +372,7 @@ namespace Umbraco.Tests.Services
doc2 = ServiceContext.ContentService.GetById(doc2.Id); //re-get
//this will be null because the doc type was changed back to variant but it's property types don't get changed back
Assert.IsNull(doc.GetValue("title", "en-US"));
Assert.IsNull(doc.GetValue("title", "en-US"));
Assert.IsNull(doc2.GetValue("title", "en-US"));
}
@@ -1714,50 +1714,65 @@ namespace Umbraco.Tests.Services
// Arrange
var service = ServiceContext.ContentTypeService;
// create 'page' content type with a 'Content_' group
var page = MockedContentTypes.CreateSimpleContentType("page", "Page", null, false, "Content_");
Assert.IsTrue(page.PropertyGroups.Contains("Content_"));
Assert.AreEqual(3, page.PropertyTypes.Count());
service.Save(page);
// create 'contentPage' content type as a child of 'page'
var contentPage = MockedContentTypes.CreateSimpleContentType("contentPage", "Content Page", page, true);
service.Save(contentPage);
var composition = MockedContentTypes.CreateMetaContentType();
composition.AddPropertyGroup("Content");
service.Save(composition);
//Adding Meta-composition to child doc type
contentPage.AddContentType(composition);
Assert.AreEqual(3, contentPage.PropertyTypes.Count());
service.Save(contentPage);
// Act
var propertyTypeOne = new PropertyType(Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext, "testTextbox")
// add 'Content' group to 'meta' content type
var meta = MockedContentTypes.CreateMetaContentType();
meta.AddPropertyGroup("Content");
Assert.AreEqual(2, meta.PropertyTypes.Count());
service.Save(meta);
// add 'meta' content type to 'contentPage' composition
contentPage.AddContentType(meta);
service.Save(contentPage);
// add property 'prop1' to 'contentPage' group 'Content_'
var prop1 = new PropertyType(Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext, "testTextbox")
{
Name = "Test Textbox", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = -88
};
var firstOneAdded = contentPage.AddPropertyType(propertyTypeOne, "Content_");
var propertyTypeTwo = new PropertyType(Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext, "anotherTextbox")
var prop1Added = contentPage.AddPropertyType(prop1, "Content_");
Assert.IsTrue(prop1Added);
// add property 'prop2' to 'contentPage' group 'Content'
var prop2 = new PropertyType(Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext, "anotherTextbox")
{
Name = "Another Test Textbox", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = -88
};
var secondOneAdded = contentPage.AddPropertyType(propertyTypeTwo, "Content");
var prop2Added = contentPage.AddPropertyType(prop2, "Content");
Assert.IsTrue(prop2Added);
// save 'contentPage' content type
service.Save(contentPage);
Assert.That(page.PropertyGroups.Contains("Content_"), Is.True);
var propertyGroup = page.PropertyGroups["Content_"];
page.PropertyGroups.Add(new PropertyGroup(true) { Id = propertyGroup.Id, Name = "ContentTab", SortOrder = 0});
var group = page.PropertyGroups["Content_"];
group.Name = "ContentTab"; // rename the group
service.Save(page);
Assert.AreEqual(3, page.PropertyTypes.Count());
// Assert
Assert.That(firstOneAdded, Is.True);
Assert.That(secondOneAdded, Is.True);
// get 'contentPage' content type again
var contentPageAgain = service.Get("contentPage");
Assert.IsNotNull(contentPageAgain);
var contentType = service.Get("contentPage");
Assert.That(contentType, Is.Not.Null);
// assert that 'Content_' group is still there because we don't propagate renames
var findGroup = contentPageAgain.CompositionPropertyGroups.FirstOrDefault(x => x.Name == "Content_");
Assert.IsNotNull(findGroup);
var compositionPropertyGroups = contentType.CompositionPropertyGroups;
// now it is still 1, because we don't propagate renames anymore
Assert.That(compositionPropertyGroups.Count(x => x.Name.Equals("Content_")), Is.EqualTo(1));
var propertyTypeCount = contentType.PropertyTypes.Count();
var compPropertyTypeCount = contentType.CompositionPropertyTypes.Count();
// count all property types (local and composed)
var propertyTypeCount = contentPageAgain.PropertyTypes.Count();
Assert.That(propertyTypeCount, Is.EqualTo(5));
// count composed property types
var compPropertyTypeCount = contentPageAgain.CompositionPropertyTypes.Count();
Assert.That(compPropertyTypeCount, Is.EqualTo(10));
}
+2
View File
@@ -118,6 +118,8 @@
<Compile Include="Collections\OrderedHashSetTests.cs" />
<Compile Include="CoreThings\CallContextTests.cs" />
<Compile Include="Components\ComponentTests.cs" />
<Compile Include="CoreThings\GuidUtilsTests.cs" />
<Compile Include="CoreThings\HexEncoderTests.cs" />
<Compile Include="CoreXml\RenamedRootNavigatorTests.cs" />
<Compile Include="Manifest\ManifestContentAppTests.cs" />
<Compile Include="Migrations\MigrationPlanTests.cs" />
@@ -124,58 +124,6 @@
</tr>
</table>
<h1>Content Picker</h1>
Opens a content picker.</br>
<strong>view: </strong>contentpicker
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tr>
<td>model.multiPicker</td>
<td>Boolean</td>
<td>Pick one or multiple items</td>
</tr>
</table>
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tr>
<td>model.selection</td>
<td>Array</td>
<td>Array of content objects</td>
</tr>
</table>
<h1>Icon Picker</h1>
Opens an icon picker.</br>
<strong>view: </strong>iconpicker
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tr>
<td>model.icon</td>
<td>String</td>
<td>The icon class</td>
</tr>
</table>
<h1>Item Picker</h1>
Opens an item picker.</br>
<strong>view: </strong>itempicker
@@ -220,170 +168,6 @@ Opens an item picker.</br>
</tr>
</table>
<h1>Macro Picker</h1>
Opens a media picker.</br>
<strong>view: </strong>macropicker
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.dialogData</td>
<td>Object</td>
<td>Object which contains array of allowedMacros. Set to <code>null</code> to allow all.</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.macroParams</td>
<td>Array</td>
<td>Array of macro params</td>
</tr>
<tr>
<td>model.selectedMacro</td>
<td>Object</td>
<td>The selected macro</td>
</tr>
</tbody>
</table>
<h1>Media Picker</h1>
Opens a media picker.</br>
<strong>view: </strong>mediapicker
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.multiPicker</td>
<td>Boolean</td>
<td>Pick one or multiple items</td>
</tr>
<tr>
<td>model.onlyImages</td>
<td>Boolean</td>
<td>Only display files that have an image file-extension</td>
</tr>
<tr>
<td>model.disableFolderSelect</td>
<td>Boolean</td>
<td>Disable folder selection</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.selectedImages</td>
<td>Array</td>
<td>Array of selected images</td>
</tr>
</tbody>
</table>
<h1>Member Group Picker</h1>
Opens a member group picker.</br>
<strong>view: </strong>membergrouppicker
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.multiPicker</td>
<td>Boolean</td>
<td>Pick one or multiple items</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.selectedMemberGroup</td>
<td>String</td>
<td>The selected member group</td>
</tr>
<tr>
<td>model.selectedMemberGroups (multiPicker)</td>
<td>Array</td>
<td>The selected member groups</td>
</tr>
</tbody>
</table>
<h1>Member Picker</h1>
Opens a member picker. </br>
<strong>view: </strong>memberpicker
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.multiPicker</td>
<td>Boolean</td>
<td>Pick one or multiple items</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Returns</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>model.selection</td>
<td>Array</td>
<td>Array of selected members/td>
</tr>
</tbody>
</table>
<h1>YSOD</h1>
Opens an overlay to show a custom YSOD. </br>
<strong>view: </strong>ysod
@@ -35,7 +35,7 @@ function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
/**
* @ngdoc method
* @name umbraco.resources.relationTypeResource#getRelationObjectTypes
* @methodof umbraco.resources.relationTypeResource
* @methodOf umbraco.resources.relationTypeResource
*
* @description
* Gets a list of Umbraco object types which can be associated with a relation.
@@ -54,7 +54,7 @@ function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
/**
* @ngdoc method
* @name umbraco.resources.relationTypeResource#save
* @methodof umbraco.resources.relationTypeResource
* @methodOf umbraco.resources.relationTypeResource
*
* @description
* Updates a relation type.
@@ -74,7 +74,7 @@ function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
/**
* @ngdoc method
* @name umbraco.resources.relationTypeResource#create
* @methodof umbraco.resources.relationTypeResource
* @methodOf umbraco.resources.relationTypeResource
*
* @description
* Creates a new relation type.
@@ -94,7 +94,7 @@ function relationTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
/**
* @ngdoc method
* @name umbraco.resources.relationTypeResource#deleteById
* @methodof umbraco.resources.relationTypeResource
* @methodOf umbraco.resources.relationTypeResource
*
* @description
* Deletes a relation type with a given ID.
@@ -4,6 +4,76 @@
*
* @description
* Added in Umbraco 8.0. Application-wide service for handling infinite editing.
*
*
<h3>Markup example</h3>
<pre>
<div ng-controller="My.Controller as vm">
<button type="button" ng-click="vm.open()">Open</button>
</div>
</pre>
<h3>Controller example</h3>
<pre>
(function () {
"use strict";
function Controller() {
var vm = this;
vm.open = open;
function open() {
var mediaPickerOptions = {
multiPicker: true,
submit: function(model) {
editorService.close();
},
close: function() {
editorService.close();
}
}
editorService.mediaPicker(mediaPickerOptions);
};
}
angular.module("umbraco").controller("My.Controller", Controller);
})();
</pre>
<h3>Custom view example</h3>
<pre>
(function () {
"use strict";
function Controller() {
var vm = this;
vm.open = open;
function open() {
var options = {
view: "path/to/view.html"
submit: function(model) {
editorService.close();
},
close: function() {
editorService.close();
}
}
editorService.open(options);
};
}
angular.module("umbraco").controller("My.Controller", Controller);
})();
</pre>
*/
(function () {
"use strict";
@@ -43,6 +113,10 @@
*
* @description
* Method to open a new editor in infinite editing
*
* @param {Object} editor rendering options
* @param {String} editor.view Path to view
* @param {String} editor.size Sets the size of the editor ("Small"). If nothing is set it will use full width.
*/
function open(editor) {
@@ -108,8 +182,12 @@
*
* @description
* Opens a media editor in infinite editing, the submit callback returns the updated content item
* @param {Object} editor rendering options
* @param {String} editor.id The id of the content item
* @param {Boolean} editor.create Create new content item
* @param {Function} editor.submit Callback function when the publish and close button is clicked. Returns the editor model object
* @param {Function} editor.close Callback function when the close button is clicked.
*
* @returns {Object} editor object
*/
function contentEditor(editor) {
@@ -124,6 +202,12 @@
*
* @description
* Opens a content picker in infinite editing, the submit callback returns an array of selected items
*
* @param {Object} editor rendering options
* @param {Boolean} editor.multiPicker Pick one or multiple items
* @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
* @param {Function} editor.close Callback function when the close button is clicked.
*
* @returns {Object} editor object
*/
function contentPicker(editor) {
@@ -218,11 +302,13 @@
*
* @description
* Opens an embed editor in infinite editing.
* @param {Object} editor rendering options
* @param {String} editor.icon The icon class
* @param {String} editor.color The color class
* @param {Callback} editor.submit Saves, submits, and closes the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
*/
function linkPicker(editor) {
editor.view = "views/common/infiniteeditors/linkpicker/linkpicker.html";
editor.size = "small";
@@ -236,6 +322,7 @@
*
* @description
* Opens a media editor in infinite editing, the submit callback returns the updated media item
* @param {Object} editor rendering options
* @param {String} editor.id The id of the media item
* @param {Boolean} editor.create Create new media item
* @param {Callback} editor.submit Saves, submits, and closes the editor
@@ -254,6 +341,7 @@
*
* @description
* Opens a media picker in infinite editing, the submit callback returns an array of selected media items
* @param {Object} editor rendering options
* @param {Boolean} editor.multiPicker Pick one or multiple items
* @param {Boolean} editor.onlyImages Only display files that have an image file-extension
* @param {Boolean} editor.disableFolderSelect Disable folder selection
@@ -276,6 +364,7 @@
*
* @description
* Opens an icon picker in infinite editing, the submit callback returns the selected icon
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -293,6 +382,7 @@
*
* @description
* Opens the document type editor in infinite editing, the submit callback returns the saved document type
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -309,6 +399,7 @@
*
* @description
* Opens the media type editor in infinite editing, the submit callback returns the saved media type
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -318,24 +409,75 @@
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#queryBuilder
* @methodOf umbraco.services.editorService
*
* @description
* Opens the query builder in infinite editing, the submit callback returns the generted query
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
*/
function queryBuilder(editor) {
editor.view = "views/common/infiniteeditors/querybuilder/querybuilder.html";
editor.size = "small";
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#treePicker
* @methodOf umbraco.services.editorService
*
* @description
* Opens the query builder in infinite editing, the submit callback returns the generted query
* @param {Object} editor rendering options
* @param {String} options.section tree section to display
* @param {String} options.treeAlias specific tree to display
* @param {Boolean} options.multiPicker should the tree pick one or multiple items before returning
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
*/
function treePicker(editor) {
editor.view = "views/common/infiniteeditors/treepicker/treepicker.html";
editor.size = "small";
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#nodePermissions
* @methodOf umbraco.services.editorService
*
* @description
* Opens the an editor to set node permissions.
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
*/
function nodePermissions(editor) {
editor.view = "views/common/infiniteeditors/nodepermissions/nodepermissions.html";
editor.size = "small";
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#insertCodeSnippet
* @methodOf umbraco.services.editorService
*
* @description
* Open an editor to insert code snippets into the code editor
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
*/
function insertCodeSnippet(editor) {
editor.view = "views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.html";
editor.size = "small";
@@ -349,6 +491,7 @@
*
* @description
* Opens the user group picker in infinite editing, the submit callback returns an array of the selected user groups
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -366,6 +509,7 @@
*
* @description
* Opens the user group picker in infinite editing, the submit callback returns the saved template
* @param {Object} editor rendering options
* @param {String} editor.id The template id
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
@@ -382,7 +526,8 @@
* @methodOf umbraco.services.editorService
*
* @description
* Opens the section picker in infinite editing, the submit callback returns an array of the selected sections
* Opens the section picker in infinite editing, the submit callback returns an array of the selected sections¨
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -400,6 +545,7 @@
*
* @description
* Opens the insert field editor in infinite editing, the submit callback returns the code snippet
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -417,6 +563,7 @@
*
* @description
* Opens the template sections editor in infinite editing, the submit callback returns the type to insert
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -429,11 +576,12 @@
/**
* @ngdoc method
* @name umbraco.services.editorService#sectionPicker
* @name umbraco.services.editorService#userPicker
* @methodOf umbraco.services.editorService
*
* @description
* Opens the section picker in infinite editing, the submit callback returns an array of the selected users
* @param {Object} editor rendering options
* @param {Callback} editor.submit Submits the editor
* @param {Callback} editor.close Closes the editor
* @returns {Object} editor object
@@ -452,6 +600,7 @@
* @description
* Opens the section picker in infinite editing, the submit callback returns an array of the selected items
*
* @param {Object} editor rendering options
* @param {Array} editor.availableItems Array of available items.
* @param {Array} editor.selectedItems Array of selected items. When passed in the selected items will be filtered from the available items.
* @param {Boolean} editor.filter Set to false to hide the filter.
@@ -485,12 +634,14 @@
/**
* @ngdoc method
* @name umbraco.services.editorService#macroPicker
* @name umbraco.services.editorService#memberGroupPicker
* @methodOf umbraco.services.editorService
*
* @description
* Opens a member group picker in infinite editing.
*
* @param {Object} editor rendering options
* @param {Object} editor.multiPicker Pick one or multiple items.
* @param {Callback} editor.submit Submits the editor.
* @param {Callback} editor.close Closes the editor.
* @returns {Object} editor object
@@ -1,13 +1,14 @@
.umb-dashboards-forms-install {
background: url('../img/forms/installer-background.png');
background-repeat: repeat-x;
position: relative;
top: -30px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-top: 30px;
box-shadow: inset 0px -40px 30px 25px rgba(255,255,255,1);
-moz-border-radius: 0px 0px 200px 200px;
-webkit-border-radius: 0px 0px 200px 200px;
border-radius: 0px 0px 200px 200px;
background-color: @white;
overflow: auto;
small {
font-size: 14px;
@@ -1,10 +0,0 @@
{
"dashboards": [
{
"name": "Install Umbraco Forms",
"alias": "installUmbracoForms",
"view": "views/dashboard/forms/formsdashboardintro.html",
"sections": [ "forms" ]
}
]
}
-1
View File
@@ -231,7 +231,6 @@
<Content Include="Umbraco\Install\Views\Web.config" />
<Content Include="App_Plugins\ModelsBuilder\package.manifest" />
<Content Include=".eslintignore" />
<Content Include="App_Plugins\UmbracoForms\package.manifest" />
<None Include="Config\404handlers.Release.config">
<DependentUpon>404handlers.config</DependentUpon>
</None>
@@ -22,6 +22,17 @@
</tab>
</section>
<section alias="StartupFormsDashboardSection">
<areas>
<area>forms</area>
</areas>
<tab caption="Install Umbraco Forms">
<control panelCaption="">
views/dashboard/forms/formsdashboardintro.html
</control>
</tab>
</section>
<section alias="StartupMediaDashboardSection">
<areas>
<area>media</area>