Returns ContentTypeKey from the server, updates js to use this everywhere and fix all js tests.

This commit is contained in:
Shannon
2020-06-11 17:16:43 +10:00
parent 1522260111
commit 12755e5db6
6 changed files with 13 additions and 8 deletions
@@ -296,6 +296,7 @@ angular.module('umbraco.mocks').
path: "-1,1234,2455",
allowedActions: ["U", "H", "A"],
contentTypeAlias: "testAlias",
contentTypeKey: "7C5B74D1-E2F9-45A3-AE4B-FC7A829BF8AB",
variants: [
{
name: "",
@@ -548,7 +548,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
"contentApiBaseUrl",
"GetEmptyByKey",
{ contentTypeKey: contentTypeKey, parentId: parentId })),
'Failed to retrieve data for empty content item id ' + contentTypeId)
'Failed to retrieve data for empty content item id ' + contentTypeKey)
.then(function (result) {
return $q.when(umbDataFormatter.formatContentGetData(result));
});
@@ -300,7 +300,7 @@
* @return {Array} array of strings representing alias.
*/
getAvailableAliasesForBlockContent: function() {
return this.blockConfigurations.map(blockConfiguration => getScaffoldFor(blockConfiguration.contentTypeKey).contentTypeAlias);
return this.blockConfigurations.map(blockConfiguration => getScaffoldFor(blockConfiguration.contentTypeKey).contentTypeKey);
},
getAvailableBlocksForBlockPicker: function() {
@@ -359,7 +359,7 @@
this.label = getBlockLabel(this);
}.bind(this))}.bind(blockModel), 10);
var contentScaffold = this.getScaffoldFor(blockConfiguration.contentTypeAlias);
var contentScaffold = this.getScaffoldFor(blockConfiguration.contentTypeKey);
if(contentScaffold === null) {
return null;
}
@@ -384,7 +384,7 @@
blockModel.settings = Utilities.copy(settingsScaffold);
layoutEntry.settings = layoutEntry.settings || {};
if (!layoutEntry.settings.key) { layoutEntry.settings.key = String.CreateGuid(); }
if (!layoutEntry.settings.contentTypeAlias) { layoutEntry.settings.contentTypeKey = blockConfiguration.settingsElementTypeKey; }
if (!layoutEntry.settings.contentTypeKey) { layoutEntry.settings.contentTypeKey = blockConfiguration.settingsElementTypeKey; }
mapToElementModel(blockModel.settings, layoutEntry.settings);
} else {
layoutEntry.settings = null;
@@ -15,7 +15,7 @@
$scope = $rootScope.$new();
contentResource = $injector.get("contentResource");
spyOn(contentResource, "getScaffold").and.callFake(
spyOn(contentResource, "getScaffoldByKey").and.callFake(
function () {
return Promise.resolve(mocksUtils.getMockVariantContent(1234))
}
@@ -26,7 +26,7 @@
}));
var blockConfigurationMock = {contentTypeKey: "testKey", label:"Test label", settingsElementTypeKey: null, view: "testview.html"};
var blockConfigurationMock = { contentTypeKey: "7C5B74D1-E2F9-45A3-AE4B-FC7A829BF8AB", label:"Test label", settingsElementTypeKey: null, view: "testview.html"};
var propertyModelMock = {
layout: {
@@ -39,7 +39,7 @@
data: [
{
udi: 1234,
contentTypeKey: "testKey",
contentTypeKey: "7C5B74D1-E2F9-45A3-AE4B-FC7A829BF8AB",
testproperty: "myTestValue"
}
]
@@ -66,7 +66,7 @@
expect(modelObject.getBlockConfiguration(blockConfigurationMock.contentTypeKey).label).toBe(blockConfigurationMock.label);
});
it('loadScaffolding provides data for itemPicker', function (done) {
var modelObject = blockEditorService.createModelObject({}, "Umbraco.TestBlockEditor", [blockConfigurationMock], $scope);
@@ -111,6 +111,9 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "contentTypeId")]
public int ContentTypeId { get; set; }
[DataMember(Name = "contentTypeKey")]
public Guid ContentTypeKey { get; set; }
[DataMember(Name = "contentTypeAlias", IsRequired = true)]
[Required(AllowEmptyStrings = false)]
public string ContentTypeAlias { get; set; }
@@ -76,6 +76,7 @@ namespace Umbraco.Web.Models.Mapping
target.AllowedTemplates = GetAllowedTemplates(source);
target.ContentApps = _commonMapper.GetContentApps(source);
target.ContentTypeId = source.ContentType.Id;
target.ContentTypeKey = source.ContentType.Key;
target.ContentTypeAlias = source.ContentType.Alias;
target.ContentTypeName = _localizedTextService.UmbracoDictionaryTranslate(source.ContentType.Name);
target.DocumentType = _commonMapper.GetContentType(source, context);