Skip to content

Commit

Permalink
Merge branch 'v8/8.7' into v8/dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/SolutionInfo.cs
#	src/Umbraco.Web.UI.Client/package.json
#	src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js
#	src/Umbraco.Web.UI.Client/src/views/common/overlays/itempicker/itempicker.controller.js
#	src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html
#	src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.controller.js
#	src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html
#	src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.controller.js
#	src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html
#	src/Umbraco.Web.UI.Client/src/views/datatypes/delete.html
#	src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html
#	src/Umbraco.Web.UI.Client/src/views/logviewer/search.html
#	src/Umbraco.Web.UI.Client/src/views/member/member.edit.controller.js
#	src/Umbraco.Web.UI.Client/src/views/packages/edit.html
#	src/Umbraco.Web.UI.Client/src/views/propertyeditors/dropdownFlexible/dropdownFlexible.controller.js
#	src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/layouts.prevalues.html
#	src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js
#	src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.prevalues.html
  • Loading branch information
nul800sebastiaan committed Sep 2, 2020
2 parents 2ac0ff9 + 9d4536a commit 79ac19b
Show file tree
Hide file tree
Showing 108 changed files with 1,130 additions and 658 deletions.
36 changes: 0 additions & 36 deletions src/Umbraco.Core/Models/Blocks/BlockEditorModel.cs

This file was deleted.

10 changes: 8 additions & 2 deletions src/Umbraco.Core/Models/Blocks/BlockItemData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ public class BlockItemData
/// </summary>
public class BlockPropertyValue
{
public object Value { get; set; }
public PropertyType PropertyType { get; set; }
public BlockPropertyValue(object value, PropertyType propertyType)
{
Value = value;
PropertyType = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
}

public object Value { get; }
public PropertyType PropertyType { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace Umbraco.Core.Models.Blocks
/// <summary>
/// Represents a layout item for the Block List editor
/// </summary>
[DataContract(Name = "blockListLayout", Namespace = "")]
public class BlockListLayoutReference : IBlockReference<IPublishedElement>
[DataContract(Name = "block", Namespace = "")]
public class BlockListItem : IBlockReference<IPublishedElement>
{
public BlockListLayoutReference(Udi contentUdi, IPublishedElement content, Udi settingsUdi, IPublishedElement settings)
public BlockListItem(Udi contentUdi, IPublishedElement content, Udi settingsUdi, IPublishedElement settings)
{
ContentUdi = contentUdi ?? throw new ArgumentNullException(nameof(contentUdi));
Content = content ?? throw new ArgumentNullException(nameof(content));
Expand All @@ -33,19 +33,13 @@ public BlockListLayoutReference(Udi contentUdi, IPublishedElement content, Udi s
/// <summary>
/// The content data item referenced
/// </summary>
/// <remarks>
/// This is ignored from serialization since it is just a reference to the actual data element
/// </remarks>
[IgnoreDataMember]
[DataMember(Name = "content")]
public IPublishedElement Content { get; }

/// <summary>
/// The settings data item referenced
/// </summary>
/// <remarks>
/// This is ignored from serialization since it is just a reference to the actual data element
/// </remarks>
[IgnoreDataMember]
[DataMember(Name = "settings")]
public IPublishedElement Settings { get; }
}
}
49 changes: 40 additions & 9 deletions src/Umbraco.Core/Models/Blocks/BlockListModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Core.Models.PublishedContent;

Expand All @@ -8,26 +11,54 @@ namespace Umbraco.Core.Models.Blocks
/// The strongly typed model for the Block List editor
/// </summary>
[DataContract(Name = "blockList", Namespace = "")]
public class BlockListModel : BlockEditorModel
public class BlockListModel : IReadOnlyList<BlockListItem>
{
private readonly IReadOnlyList<BlockListItem> _layout = new List<BlockListItem>();

public static BlockListModel Empty { get; } = new BlockListModel();

private BlockListModel()
{
}

public BlockListModel(IEnumerable<IPublishedElement> contentData, IEnumerable<IPublishedElement> settingsData, IEnumerable<BlockListLayoutReference> layout)
: base(contentData, settingsData)
public BlockListModel(IEnumerable<BlockListItem> layout)
{
Layout = layout;
_layout = layout.ToList();
}

public int Count => _layout.Count;

/// <summary>
/// Get the block by index
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public BlockListItem this[int index] => _layout[index];

/// <summary>
/// Get the block by content Guid
/// </summary>
/// <param name="contentKey"></param>
/// <returns></returns>
public BlockListItem this[Guid contentKey] => _layout.FirstOrDefault(x => x.Content.Key == contentKey);

/// <summary>
/// The layout items of the Block List editor
/// Get the block by content element Udi
/// </summary>
[DataMember(Name = "layout")]
public IEnumerable<BlockListLayoutReference> Layout { get; } = new List<BlockListLayoutReference>();
/// <param name="contentUdi"></param>
/// <returns></returns>
public BlockListItem this[Udi contentUdi]
{
get
{
if (!(contentUdi is GuidUdi guidUdi)) return null;
return _layout.FirstOrDefault(x => x.Content.Key == guidUdi.Guid);
}
}

public IEnumerator<BlockListItem> GetEnumerator() => _layout.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public IEnumerable<string> GetAllContentTypeAliases(params Guid[] objectTypes)

if (objectTypes.Any())
{
sql = sql.Where("umbracoNode.nodeObjectType IN (@objectTypes)", objectTypes);
sql = sql.Where("umbracoNode.nodeObjectType IN (@objectTypes)", new { objectTypes = objectTypes });
}

return Database.Fetch<string>(sql);
Expand Down
3 changes: 1 addition & 2 deletions src/Umbraco.Core/Umbraco.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@
<Compile Include="Persistence\Repositories\Implement\InstallationRepository.cs" />
<Compile Include="Services\Implement\InstallationService.cs" />
<Compile Include="Migrations\Upgrade\V_8_6_0\AddMainDomLock.cs" />
<Compile Include="Models\Blocks\BlockEditorModel.cs" />
<Compile Include="Models\Blocks\BlockListLayoutReference.cs" />
<Compile Include="Models\Blocks\BlockListItem.cs" />
<Compile Include="Models\Blocks\BlockListModel.cs" />
<Compile Include="Models\UpgradeResult.cs" />
<Compile Include="Persistence\Repositories\Implement\UpgradeCheckRepository.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,13 @@ public void Convert_Null_Empty()
var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);

json = string.Empty;
converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);
}

[Test]
Expand All @@ -177,17 +175,15 @@ public void Convert_Valid_Empty_Json()
var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);

json = @"{
layout: {},
data: []}";
converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);

// Even though there is a layout, there is no data, so the conversion will result in zero elements in total
json = @"
Expand All @@ -205,8 +201,7 @@ public void Convert_Valid_Empty_Json()
converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);

// Even though there is a layout and data, the data is invalid (missing required keys) so the conversion will result in zero elements in total
json = @"
Expand All @@ -228,8 +223,7 @@ public void Convert_Valid_Empty_Json()
converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(0, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);

// Everthing is ok except the udi reference in the layout doesn't match the data so it will be empty
json = @"
Expand All @@ -252,8 +246,7 @@ public void Convert_Valid_Empty_Json()
converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(1, converted.ContentData.Count());
Assert.AreEqual(0, converted.Layout.Count());
Assert.AreEqual(0, converted.Count);
}

[Test]
Expand Down Expand Up @@ -283,14 +276,12 @@ public void Convert_Valid_Json()
var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(1, converted.ContentData.Count());
var item0 = converted.ContentData.ElementAt(0);
Assert.AreEqual(1, converted.Count);
var item0 = converted[0].Content;
Assert.AreEqual(Guid.Parse("1304E1DD-AC87-4396-84FE-8A399231CB3D"), item0.Key);
Assert.AreEqual("Test1", item0.ContentType.Alias);
Assert.AreEqual(1, converted.Layout.Count());
var layout0 = converted.Layout.ElementAt(0);
Assert.IsNull(layout0.Settings);
Assert.AreEqual(Udi.Parse("umb://element/1304E1DDAC87439684FE8A399231CB3D"), layout0.ContentUdi);
Assert.IsNull(converted[0].Settings);
Assert.AreEqual(Udi.Parse("umb://element/1304E1DDAC87439684FE8A399231CB3D"), converted[0].ContentUdi);
}

[Test]
Expand Down Expand Up @@ -348,17 +339,15 @@ public void Get_Data_From_Layout_Item()
var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(3, converted.ContentData.Count());
Assert.AreEqual(3, converted.SettingsData.Count());
Assert.AreEqual(2, converted.Layout.Count());
Assert.AreEqual(2, converted.Count);

var item0 = converted.Layout.ElementAt(0);
var item0 = converted[0];
Assert.AreEqual(Guid.Parse("1304E1DD-AC87-4396-84FE-8A399231CB3D"), item0.Content.Key);
Assert.AreEqual("Test1", item0.Content.ContentType.Alias);
Assert.AreEqual(Guid.Parse("1F613E26CE274898908A561437AF5100"), item0.Settings.Key);
Assert.AreEqual("Setting2", item0.Settings.ContentType.Alias);

var item1 = converted.Layout.ElementAt(1);
var item1 = converted[1];
Assert.AreEqual(Guid.Parse("0A4A416E-547D-464F-ABCC-6F345C17809A"), item1.Content.Key);
Assert.AreEqual("Test2", item1.Content.ContentType.Alias);
Assert.AreEqual(Guid.Parse("63027539B0DB45E7B70459762D4E83DD"), item1.Settings.Key);
Expand Down Expand Up @@ -434,11 +423,9 @@ public void Data_Item_Removed_If_Removed_From_Config()
var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel;

Assert.IsNotNull(converted);
Assert.AreEqual(2, converted.ContentData.Count());
Assert.AreEqual(0, converted.SettingsData.Count());
Assert.AreEqual(1, converted.Layout.Count());
Assert.AreEqual(1, converted.Count);

var item0 = converted.Layout.ElementAt(0);
var item0 = converted[0];
Assert.AreEqual(Guid.Parse("0A4A416E-547D-464F-ABCC-6F345C17809A"), item0.Content.Key);
Assert.AreEqual("Test2", item0.Content.ContentType.Alias);
Assert.IsNull(item0.Settings);
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"lazyload-js": "1.0.0",
"moment": "2.22.2",
"ng-file-upload": "12.2.13",
"nouislider": "14.6.0",
"nouislider": "14.6.1",
"npm": "^6.14.7",
"signalr": "2.4.0",
"spectrum-colorpicker": "1.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
vm.inviteStep = 2;

}, function (err) {
formHelper.resetForm({ scope: $scope, hasErrors: true });
formHelper.handleError(err);
vm.invitedUserPasswordModel.buttonState = "error";
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
eventsService.emit("content.unpublished", { content: $scope.content });
overlayService.close();
}, function (err) {
formHelper.resetForm({ scope: $scope, hasErrors: true });
$scope.page.buttonGroupState = 'error';
handleHttpException(err);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Use this directive to construct a header inside the main editor window.
</ul>
@param {string} name The content name.
@param {boolean=} nameRequired Require name to be defined. (True by default)
@param {array=} tabs Array of tabs. See example above.
@param {array=} navigation Array of sub views. See example above.
@param {boolean=} nameLocked Set to <code>true</code> to lock the name.
Expand All @@ -199,15 +200,15 @@ Use this directive to construct a header inside the main editor window.
@param {boolean=} hideAlias Set to <code>true</code> to hide alias.
@param {string=} description Add a description to the content.
@param {boolean=} hideDescription Set to <code>true</code> to hide description.
@param {boolean=} setpagetitle If true the page title will be set to reflect the type of data the header is working with
@param {boolean=} setpagetitle If true the page title will be set to reflect the type of data the header is working with
@param {string=} editorfor The localization to use to aid accessibility on the edit and create screen
**/

(function () {
'use strict';

function EditorHeaderDirective(editorService, localizationService, editorState, $rootScope) {

function link(scope, $injector) {

scope.vm = {};
Expand Down Expand Up @@ -329,11 +330,11 @@ Use this directive to construct a header inside the main editor window.
}
scope.accessibility.a11yMessageVisible = !isEmptyOrSpaces(scope.accessibility.a11yMessage);
scope.accessibility.a11yNameVisible = !isEmptyOrSpaces(scope.accessibility.a11yName);

});
}



function isEmptyOrSpaces(str) {
return str === null || str===undefined || str.trim ==='';
Expand All @@ -348,7 +349,7 @@ Use this directive to construct a header inside the main editor window.
});
}



var directive = {
transclude: true,
Expand All @@ -358,6 +359,7 @@ Use this directive to construct a header inside the main editor window.
scope: {
name: "=",
nameLocked: "=",
nameRequired: "=?",
menu: "=",
hideActionsMenu: "<?",
icon: "=",
Expand Down
Loading

0 comments on commit 79ac19b

Please sign in to comment.