converting code to use contentTypeKey instead of contentTypeAlias, still missing a few TODOs.
This commit is contained in:
@@ -197,11 +197,11 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_7_0
|
||||
[JsonProperty("thumbnail")]
|
||||
public string Thumbnail { get; set; }
|
||||
|
||||
[JsonProperty("contentTypeAlias")]
|
||||
public string Alias { get; set; }
|
||||
[JsonProperty("contentTypeKey")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("settingsElementTypeAlias")]
|
||||
public string SettingsElementTypeAlias { get; set; }
|
||||
[JsonProperty("settingsElementTypeKey")]
|
||||
public string settingsElementTypeKey { get; set; }
|
||||
|
||||
[JsonProperty("view")]
|
||||
public string View { get; set; }
|
||||
@@ -256,7 +256,8 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_7_0
|
||||
|
||||
var udi = new GuidUdi(Constants.UdiEntityType.Element, key).ToString();
|
||||
obj["udi"] = udi;
|
||||
obj["contentTypeAlias"] = ct.Alias;
|
||||
// TODO: retrive the key for the content type.
|
||||
//obj["contentTypeAlias"] = ct.Alias;
|
||||
|
||||
if (ct.StringToRawProperties != null && ct.StringToRawProperties.Length > 0)
|
||||
{
|
||||
|
||||
@@ -508,6 +508,51 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
return $q.when(umbDataFormatter.formatContentGetData(result));
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.contentResource#getScaffoldByID
|
||||
* @methodOf umbraco.resources.contentResource
|
||||
*
|
||||
* @description
|
||||
* Returns a scaffold of an empty content item, given the id of the content item to place it underneath and the content type alias.
|
||||
*
|
||||
* - Parent Id must be provided so umbraco knows where to store the content
|
||||
* - Content Type Id must be provided so umbraco knows which properties to put on the content scaffold
|
||||
*
|
||||
* The scaffold is used to build editors for content that has not yet been populated with data.
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* contentResource.getScaffoldById(1234, '...')
|
||||
* .then(function(scaffold) {
|
||||
* var myDoc = scaffold;
|
||||
* myDoc.name = "My new document";
|
||||
*
|
||||
* contentResource.publish(myDoc, true)
|
||||
* .then(function(content){
|
||||
* alert("Retrieved, updated and published again");
|
||||
* });
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param {Int} parentId id of content item to return
|
||||
* @param {String} contentTypeGuid contenttype guid to base the scaffold on
|
||||
* @returns {Promise} resourcePromise object containing the content scaffold.
|
||||
*
|
||||
*/
|
||||
getScaffoldByKey: function (parentId, contentTypeKey) {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"GetEmptyByKey",
|
||||
[{ contentTypeKey: contentTypeKey }, { parentId: parentId }])),
|
||||
'Failed to retrieve data for empty content item id ' + contentTypeId)
|
||||
.then(function (result) {
|
||||
return $q.when(umbDataFormatter.formatContentGetData(result));
|
||||
});
|
||||
},
|
||||
|
||||
getBlueprintScaffold: function (parentId, blueprintId) {
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
* ####Use the Model Object to retrive Content Models for the blocks you want to edit. Content Models contains all the data about the properties of that content and as well handles syncroniztion so your data is always up-to-date.
|
||||
*
|
||||
* <pre>
|
||||
* function addNewBlock(index, contentTypeAlias) {
|
||||
* function addNewBlock(index, contentTypeKey) {
|
||||
*
|
||||
* // Create layout entry. (not added to property model jet.)
|
||||
* var layoutEntry = modelObject.create(contentTypeAlias);
|
||||
* var layoutEntry = modelObject.create(contentTypeKey);
|
||||
* if (layoutEntry === null) {
|
||||
* return false;
|
||||
* }
|
||||
@@ -267,27 +267,27 @@
|
||||
|
||||
BlockEditorModelObject.prototype = {
|
||||
|
||||
getBlockConfiguration: function(alias) {
|
||||
return this.blockConfigurations.find(bc => bc.contentTypeAlias === alias);
|
||||
getBlockConfiguration: function(key) {
|
||||
return this.blockConfigurations.find(bc => bc.contentTypeKey === key);
|
||||
},
|
||||
|
||||
loadScaffolding: function() {
|
||||
var tasks = [];
|
||||
|
||||
var scaffoldAliases = [];
|
||||
var scaffoldKeys = [];
|
||||
|
||||
this.blockConfigurations.forEach(blockConfiguration => {
|
||||
scaffoldAliases.push(blockConfiguration.contentTypeAlias);
|
||||
if (blockConfiguration.settingsElementTypeAlias != null) {
|
||||
scaffoldAliases.push(blockConfiguration.settingsElementTypeAlias);
|
||||
scaffoldKeys.push(blockConfiguration.contentTypeKey);
|
||||
if (blockConfiguration.settingsElementTypeKey != null) {
|
||||
scaffoldKeys.push(blockConfiguration.settingsElementTypeKey);
|
||||
}
|
||||
});
|
||||
|
||||
// removing dublicates.
|
||||
scaffoldAliases = scaffoldAliases.filter((value, index, self) => self.indexOf(value) === index);
|
||||
scaffoldKeys = scaffoldKeys.filter((value, index, self) => self.indexOf(value) === index);
|
||||
|
||||
scaffoldAliases.forEach((elementTypeAlias => {
|
||||
tasks.push(contentResource.getScaffold(-20, elementTypeAlias).then(scaffold => {
|
||||
scaffoldKeys.forEach((contentTypeKey => {
|
||||
tasks.push(contentResource.getScaffoldByKey(-20, contentTypeKey).then(scaffold => {
|
||||
this.scaffolds.push(replaceUnsupportedProperties(scaffold));
|
||||
}));
|
||||
}));
|
||||
@@ -300,7 +300,7 @@
|
||||
* @return {Array} array of strings representing alias.
|
||||
*/
|
||||
getAvailableAliasesForBlockContent: function() {
|
||||
return this.blockConfigurations.map(blockConfiguration => blockConfiguration.contentTypeAlias);
|
||||
return this.blockConfigurations.map(blockConfiguration => getScaffoldFor(blockConfiguration.contentTypeKey).contentTypeAlias);
|
||||
},
|
||||
|
||||
getAvailableBlocksForBlockPicker: function() {
|
||||
@@ -308,7 +308,7 @@
|
||||
var blocks = [];
|
||||
|
||||
this.blockConfigurations.forEach(blockConfiguration => {
|
||||
var scaffold = this.getScaffoldFor(blockConfiguration.contentTypeAlias);
|
||||
var scaffold = this.getScaffoldFor(blockConfiguration.contentTypeKey);
|
||||
if(scaffold) {
|
||||
blocks.push({
|
||||
blockConfigModel: blockConfiguration,
|
||||
@@ -320,8 +320,8 @@
|
||||
return blocks;
|
||||
},
|
||||
|
||||
getScaffoldFor: function(contentTypeAlias) {
|
||||
return this.scaffolds.find(o => o.contentTypeAlias === contentTypeAlias);
|
||||
getScaffoldFor: function(contentTypeKey) {
|
||||
return this.scaffolds.find(o => o.contentTypeKey === contentTypeKey);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -340,10 +340,10 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
var blockConfiguration = this.getBlockConfiguration(dataModel.contentTypeAlias);
|
||||
var blockConfiguration = this.getBlockConfiguration(dataModel.contentTypeKey);
|
||||
|
||||
if (blockConfiguration === null) {
|
||||
console.error("The block entry of "+udi+" is not begin initialized cause its contentTypeAlias is not allowed for this PropertyEditor")
|
||||
console.error("The block entry of "+udi+" is not begin initialized cause its contentTypeKey is not allowed for this PropertyEditor")
|
||||
// This is not an allowed block type, therefor we return null;
|
||||
return null;
|
||||
}
|
||||
@@ -374,17 +374,17 @@
|
||||
blockModel.layout = layoutEntry;
|
||||
blockModel.watchers = [];
|
||||
|
||||
if (blockConfiguration.settingsElementTypeAlias) {
|
||||
var settingsScaffold = this.getScaffoldFor(blockConfiguration.settingsElementTypeAlias);
|
||||
if (blockConfiguration.settingsElementTypeKey) {
|
||||
var settingsScaffold = this.getScaffoldFor(blockConfiguration.settingsElementTypeKey);
|
||||
if (settingsScaffold === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// make basics from scaffold
|
||||
blockModel.settings = Utilities.copy(settingsScaffold);
|
||||
layoutEntry.settings = layoutEntry.settings || { key: String.CreateGuid(), contentTypeAlias: blockConfiguration.settingsElementTypeAlias };
|
||||
layoutEntry.settings = layoutEntry.settings || {};
|
||||
if (!layoutEntry.settings.key) { layoutEntry.settings.key = String.CreateGuid(); }
|
||||
if (!layoutEntry.settings.contentTypeAlias) { layoutEntry.settings.contentTypeAlias = blockConfiguration.settingsElementTypeAlias; }
|
||||
if (!layoutEntry.settings.contentTypeAlias) { layoutEntry.settings.contentTypeKey = blockConfiguration.settingsElementTypeKey; }
|
||||
mapToElementModel(blockModel.settings, layoutEntry.settings);
|
||||
} else {
|
||||
layoutEntry.settings = null;
|
||||
@@ -446,19 +446,19 @@
|
||||
* @param {Object} blockConfiguration
|
||||
* @return {Object} Layout entry object, to be inserted at a decired location in the layout object.
|
||||
*/
|
||||
create: function(contentTypeAlias) {
|
||||
create: function(contentTypeKey) {
|
||||
|
||||
var blockConfiguration = this.getBlockConfiguration(contentTypeAlias);
|
||||
var blockConfiguration = this.getBlockConfiguration(contentTypeKey);
|
||||
if(blockConfiguration === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var entry = {
|
||||
udi: this._createDataEntry(contentTypeAlias)
|
||||
udi: this._createDataEntry(contentTypeKey)
|
||||
}
|
||||
|
||||
if (blockConfiguration.settingsElementTypeAlias != null) {
|
||||
entry.settings = { key: String.CreateGuid(), contentTypeAlias: blockConfiguration.settingsElementTypeAlias };
|
||||
if (blockConfiguration.settingsElementTypeKey != null) {
|
||||
entry.settings = { key: String.CreateGuid(), contentTypeKey: blockConfiguration.settingsElementTypeKey };
|
||||
}
|
||||
|
||||
return entry;
|
||||
@@ -472,9 +472,9 @@
|
||||
|
||||
elementTypeDataModel = Utilities.copy(elementTypeDataModel);
|
||||
|
||||
var contentTypeAlias = elementTypeDataModel.contentTypeAlias;
|
||||
var contentTypeKey = elementTypeDataModel.contentTypeKey;
|
||||
|
||||
var layoutEntry = this.create(contentTypeAlias);
|
||||
var layoutEntry = this.create(contentTypeKey);
|
||||
if(layoutEntry === null) {
|
||||
return null;
|
||||
}
|
||||
@@ -491,9 +491,9 @@
|
||||
},
|
||||
|
||||
// private
|
||||
_createDataEntry: function(elementTypeAlias) {
|
||||
_createDataEntry: function(elementTypeKey) {
|
||||
var content = {
|
||||
contentTypeAlias: elementTypeAlias,
|
||||
contentTypeKey: elementTypeKey,
|
||||
udi: udiService.create("element")
|
||||
};
|
||||
this.value.data.push(content);
|
||||
|
||||
@@ -390,6 +390,7 @@
|
||||
vm.page.saveButtonState = "success";
|
||||
|
||||
if(infiniteMode && $scope.model.submit) {
|
||||
$scope.model.documentTypeKey = vm.contentType.key;
|
||||
$scope.model.documentTypeAlias = vm.contentType.alias;
|
||||
$scope.model.submit($scope.model);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
vm.availableContentTypes = modelObject.getAvailableAliasesForBlockContent();
|
||||
vm.availableContentTypesAliases = modelObject.getAvailableAliasForBlockContent();
|
||||
vm.availableBlockTypes = modelObject.getAvailableBlocksForBlockPicker();
|
||||
|
||||
vm.loading = false;
|
||||
@@ -145,16 +145,16 @@
|
||||
// Lets apply fallback views, and make the view available directly on the blockModel.
|
||||
block.view = (block.config.view ? "/" + block.config.view : (inlineEditing ? "views/propertyeditors/blocklist/blocklistentryeditors/inlineblock/inlineblock.editor.html" : "views/propertyeditors/blocklist/blocklistentryeditors/labelblock/labelblock.editor.html"));
|
||||
|
||||
block.showSettings = block.config.settingsElementTypeAlias != null;
|
||||
block.showSettings = block.config.settingsElementTypeKey != null;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
function addNewBlock(index, contentTypeAlias) {
|
||||
function addNewBlock(index, contentTypeKey) {
|
||||
|
||||
// Create layout entry. (not added to property model jet.)
|
||||
var layoutEntry = modelObject.create(contentTypeAlias);
|
||||
var layoutEntry = modelObject.create(contentTypeKey);
|
||||
if (layoutEntry === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -210,7 +210,7 @@
|
||||
var blockContentClone = Utilities.copy(blockModel.content);
|
||||
var blockSettingsClone = null;
|
||||
|
||||
if (blockModel.config.settingsElementTypeAlias) {
|
||||
if (blockModel.config.settingsElementTypeKey) {
|
||||
blockSettingsClone = Utilities.copy(blockModel.settings);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
if (blockEditorModel.content !== null) {
|
||||
blockEditorService.mapElementValues(blockEditorModel.content, blockModel.content)
|
||||
}
|
||||
if (blockModel.config.settingsElementTypeAlias !== null) {
|
||||
if (blockModel.config.settingsElementTypeKey !== null) {
|
||||
blockEditorService.mapElementValues(blockEditorModel.settings, blockModel.settings)
|
||||
}
|
||||
editorService.close();
|
||||
@@ -280,7 +280,7 @@
|
||||
submit: function(blockPickerModel, mouseEvent) {
|
||||
var added = false;
|
||||
if (blockPickerModel && blockPickerModel.selectedItem) {
|
||||
added = addNewBlock(createIndex, blockPickerModel.selectedItem.blockConfigModel.contentTypeAlias);
|
||||
added = addNewBlock(createIndex, blockPickerModel.selectedItem.blockConfigModel.contentTypeKey);
|
||||
}
|
||||
|
||||
if(!(mouseEvent.ctrlKey || mouseEvent.metaKey)) {
|
||||
@@ -296,19 +296,19 @@
|
||||
};
|
||||
|
||||
blockPickerModel.clickClearClipboard = function ($event) {
|
||||
clipboardService.clearEntriesOfType("elementType", vm.availableContentTypes);
|
||||
clipboardService.clearEntriesOfType("elementTypeArray", vm.availableContentTypes);
|
||||
clipboardService.clearEntriesOfType("elementType", vm.availableContentTypesAliases);
|
||||
clipboardService.clearEntriesOfType("elementTypeArray", vm.availableContentTypesAliases);
|
||||
};
|
||||
|
||||
blockPickerModel.clipboardItems = [];
|
||||
|
||||
var singleEntriesForPaste = clipboardService.retriveEntriesOfType("elementType", vm.availableContentTypes);
|
||||
var singleEntriesForPaste = clipboardService.retriveEntriesOfType("elementType", vm.availableContentTypesAliases);
|
||||
singleEntriesForPaste.forEach(function (entry) {
|
||||
blockPickerModel.clipboardItems.push(
|
||||
{
|
||||
type: "elementType",
|
||||
pasteData: entry.data,
|
||||
blockConfigModel: modelObject.getScaffoldFor(entry.alias),
|
||||
blockConfigModel: modelObject.getScaffoldFor(entry.key),
|
||||
elementTypeModel: {
|
||||
name: entry.label,
|
||||
icon: entry.icon
|
||||
@@ -317,7 +317,7 @@
|
||||
);
|
||||
});
|
||||
|
||||
var arrayEntriesForPaste = clipboardService.retriveEntriesOfType("elementTypeArray", vm.availableContentTypes);
|
||||
var arrayEntriesForPaste = clipboardService.retriveEntriesOfType("elementTypeArray", vm.availableContentTypesAliases);
|
||||
arrayEntriesForPaste.forEach(function (entry) {
|
||||
blockPickerModel.clipboardItems.push(
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
vm.requestRemoveBlockByIndex = function (index) {
|
||||
localizationService.localizeMany(["general_delete", "blockEditor_confirmDeleteBlockMessage", "blockEditor_confirmDeleteBlockNotice"]).then(function (data) {
|
||||
var contentElementType = vm.getElementTypeByAlias($scope.model.value[index].contentTypeAlias);
|
||||
var contentElementType = vm.getElementTypeByKey($scope.model.value[index].contentTypeKey);
|
||||
overlayService.confirmDelete({
|
||||
title: data[0],
|
||||
content: localizationService.tokenReplace(data[1], [contentElementType.name]),
|
||||
@@ -71,22 +71,22 @@
|
||||
vm.getAvailableElementTypes = function () {
|
||||
return vm.elementTypes.filter(function (type) {
|
||||
return !$scope.model.value.find(function (entry) {
|
||||
return type.alias === entry.contentTypeAlias;
|
||||
return type.key === entry.contentTypeKey;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
vm.getElementTypeByAlias = function(alias) {
|
||||
vm.getElementTypeByKey = function(key) {
|
||||
return _.find(vm.elementTypes, function (type) {
|
||||
return type.alias === alias;
|
||||
return type.key === key;
|
||||
});
|
||||
};
|
||||
|
||||
vm.openAddDialog = function ($event, entry) {
|
||||
|
||||
//we have to add the alias to the objects (they are stored as contentTypeAlias)
|
||||
var selectedItems = _.each($scope.model.value, function (obj) {
|
||||
obj.alias = obj.contentTypeAlias;
|
||||
//we have to add the 'alias' property to the objects, to make the data match the requirements of itempicker.
|
||||
var selectedItems = _.each(Utilities.copy($scope.model.value), function (obj) {
|
||||
obj.alias = vm.getElementTypeByKey(obj.contentTypeKey).alias;
|
||||
return obj;
|
||||
});
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
createNewItem: {
|
||||
action: function() {
|
||||
overlayService.close();
|
||||
vm.createElementTypeAndAdd(vm.addBlockFromElementTypeAlias);
|
||||
vm.createElementTypeAndAdd(vm.addBlockFromElementTypeKey);
|
||||
},
|
||||
icon: "icon-add",
|
||||
name: localized[1]
|
||||
@@ -111,7 +111,7 @@
|
||||
event: $event,
|
||||
size: availableItems.length < 7 ? "small" : "medium",
|
||||
submit: function (overlay) {
|
||||
vm.addBlockFromElementTypeAlias(overlay.selectedItem.alias);
|
||||
vm.addBlockFromElementTypeKey(overlay.selectedItem.key);
|
||||
overlayService.close();
|
||||
},
|
||||
close: function () {
|
||||
@@ -131,7 +131,7 @@
|
||||
isElement: true,
|
||||
submit: function (model) {
|
||||
loadElementTypes().then( function () {
|
||||
callback(model.documentTypeAlias);
|
||||
callback(model.documentTypeKey);
|
||||
});
|
||||
editorService.close();
|
||||
},
|
||||
@@ -142,13 +142,13 @@
|
||||
editorService.documentTypeEditor(editor);
|
||||
}
|
||||
|
||||
vm.addBlockFromElementTypeAlias = function(alias) {
|
||||
vm.addBlockFromElementTypeKey = function(key) {
|
||||
|
||||
var entry = {
|
||||
"contentTypeAlias": alias,
|
||||
"contentTypeKey": key,
|
||||
"view": null,
|
||||
"labelTemplate": "",
|
||||
"settingsElementTypeAlias": null
|
||||
"settingsElementTypeKey": null
|
||||
};
|
||||
|
||||
$scope.model.value.push(entry);
|
||||
@@ -160,7 +160,7 @@
|
||||
|
||||
vm.openBlockOverlay = function (block) {
|
||||
|
||||
localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [vm.getElementTypeByAlias(block.contentTypeAlias).name]).then(function (data) {
|
||||
localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [vm.getElementTypeByKey(block.contentTypeKey).name]).then(function (data) {
|
||||
|
||||
var clonedBlockData = Utilities.copy(block);
|
||||
vm.openBlock = block;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<umb-block-card
|
||||
block-config-model="block"
|
||||
element-type-model="vm.getElementTypeByAlias(block.contentTypeAlias)"
|
||||
element-type-model="vm.getElementTypeByKey(block.contentTypeKey)"
|
||||
ng-repeat="block in model.value"
|
||||
ng-class="{'--isOpen':vm.openBlock === block}"
|
||||
ng-click="vm.openBlockOverlay(block)">
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
});
|
||||
}
|
||||
|
||||
vm.getElementTypeByAlias = function(alias) {
|
||||
vm.getElementTypeByKey = function(key) {
|
||||
return _.find(vm.elementTypes, function (type) {
|
||||
return type.alias === alias;
|
||||
return type.key === key;
|
||||
});
|
||||
};
|
||||
|
||||
vm.openElementType = function(elementTypeAlias) {
|
||||
var elementTypeId = vm.getElementTypeByAlias(elementTypeAlias).id;
|
||||
vm.openElementType = function(elementTypeKey) {
|
||||
var elementTypeId = vm.getElementTypeByKey(elementTypeKey).id;
|
||||
const editor = {
|
||||
id: elementTypeId,
|
||||
submit: function (model) {
|
||||
@@ -78,14 +78,14 @@
|
||||
|
||||
});
|
||||
};
|
||||
vm.applySettingsToBlock = function(block, alias) {
|
||||
block.settingsElementTypeAlias = alias;
|
||||
vm.applySettingsToBlock = function(block, key) {
|
||||
block.settingsElementTypeKey = key;
|
||||
};
|
||||
|
||||
vm.requestRemoveSettingsForBlock = function(block) {
|
||||
localizationService.localizeMany(["general_remove", "defaultdialogs_confirmremoveusageof"]).then(function (data) {
|
||||
|
||||
var settingsElementType = vm.getElementTypeByAlias(entry.settingsElementTypeAlias);
|
||||
var settingsElementType = vm.getElementTypeByAlias(entry.settingsElementTypeKey);
|
||||
|
||||
overlayService.confirmRemove({
|
||||
title: data[0],
|
||||
@@ -101,7 +101,7 @@
|
||||
});
|
||||
};
|
||||
vm.removeSettingsForEntry = function(entry) {
|
||||
entry.settingsElementTypeAlias = null;
|
||||
entry.settingsElementTypeKey = null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -106,11 +106,11 @@
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label"><localize key="blockEditor_labelContentElementType">Content ElementType</localize></label>
|
||||
<div class="controls">
|
||||
<div class="__settings-input --hasValue" ng-if="vm.block.contentTypeAlias !== null" >
|
||||
{{ contentPreview = vm.getElementTypeByAlias(vm.block.contentTypeAlias); "" }}
|
||||
<div class="__settings-input --hasValue" ng-if="vm.block.contentTypeKey !== null" >
|
||||
{{ contentPreview = vm.getElementTypeByKey(vm.block.contentTypeKey); "" }}
|
||||
<umb-node-preview icon="contentPreview.icon" name="contentPreview.name"></umb-node-preview>
|
||||
<div class="__control-actions">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(vm.block.contentTypeAlias)">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(vm.block.contentTypeKey)">
|
||||
<i class="icon icon-edit"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -124,11 +124,11 @@
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label"><localize key="blockEditor_labelSettingsElementType">Settings Element Type</localize></label>
|
||||
<div class="controls">
|
||||
<div class="__settings-input --hasValue" ng-if="vm.block.settingsElementTypeAlias !== null">
|
||||
{{ settingsPreview = vm.getElementTypeByAlias(vm.block.settingsElementTypeAlias); "" }}
|
||||
<div class="__settings-input --hasValue" ng-if="vm.block.settingsElementTypeKey !== null">
|
||||
{{ settingsPreview = vm.getElementTypeByKey(vm.block.settingsElementTypeKey); "" }}
|
||||
<umb-node-preview icon="settingsPreview.icon" name="settingsPreview.name"></umb-node-preview>
|
||||
<div class="__control-actions">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(vm.block.settingsElementTypeAlias)">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(vm.block.settingsElementTypeKey)">
|
||||
<i class="icon icon-edit"></i>
|
||||
</button>
|
||||
<button type="button" class="btn-reset __control-actions-btn --remove umb-outline" ng-click="vm.requestRemoveSettingsForBlock(vm.block)">
|
||||
@@ -136,32 +136,12 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-reset __settings-input --noValue umb-outline" ng-if="vm.block.settingsElementTypeAlias === null" ng-click="vm.addSettingsForBlock($event, vm.block)">
|
||||
<button type="button" class="btn-reset __settings-input --noValue umb-outline" ng-if="vm.block.settingsElementTypeKey === null" ng-click="vm.addSettingsForBlock($event, vm.block)">
|
||||
<localize key="blockEditor_addSettingsElementType">Add settings</localize>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recursive
|
||||
<div class="control-group umb-control-group">
|
||||
<div class="umb-el-wrap">
|
||||
<div class="controls">
|
||||
<label class="control-label">
|
||||
<localize key="templateEditor_recursive">Recursive</localize>
|
||||
</label>
|
||||
<div class="flex">
|
||||
<umb-checkbox name="recursive"
|
||||
disabled="!vm.field"
|
||||
model="vm.recursive"
|
||||
text="Yes, make it recursive"
|
||||
label-key="templateEditor_recursiveDescr">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -246,86 +226,3 @@
|
||||
</umb-editor-view>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!--
|
||||
<div class="umb-table">
|
||||
<div class="umb-table-head">
|
||||
<div class="umb-table-row">
|
||||
<div class="umb-table-cell not-fixed umb-table__name">
|
||||
<localize key="blockEditor_labelContentElementType">Custom view</localize>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<localize key="blockEditor_labelLabelTemplate">Label</localize>
|
||||
<button type="button" class="btn-reset">
|
||||
<i class="icon icon-help-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<localize key="blockEditor_labelCustomView">Custom view</localize>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<localize key="blockEditor_labelSettingsElementType">Custom view</localize>
|
||||
</div>
|
||||
<div class="umb-table-cell action-cell">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-table-body" ui-sortable="vm.sortableOptions" ng-model="model.value">
|
||||
<div class="umb-table-row block-entry" ng-repeat="entry in model.value">
|
||||
<div class="umb-table-cell not-fixed umb-table__name">
|
||||
{{ contentPreview = vm.getElementTypeByAlias(entry.contentTypeAlias); "" }}
|
||||
<umb-node-preview icon="contentPreview.icon" name="contentPreview.name"></umb-node-preview>
|
||||
<div class="__control-actions">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(entry.contentTypeAlias)">
|
||||
<i class="icon icon-edit"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<input type="text" ng-model="entry.label" class="text-input"/>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<div class="__settings-input --hasValue" ng-if="entry.view !== null" >
|
||||
|
||||
<umb-node-preview icon="'icon-document'" name="entry.view"></umb-node-preview>
|
||||
<div class="__control-actions">
|
||||
<button type="button" class="btn-reset __control-actions-btn --remove umb-outline" ng-click="vm.requestRemoveViewForEntry(entry)">
|
||||
<i class="icon icon-wrong"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-reset __settings-input --noValue umb-outline" ng-if="entry.view === null" ng-click="vm.addViewForEntry(entry)">
|
||||
<localize key="blockEditor_addCustomView">Add custom view</localize>
|
||||
</button>
|
||||
</div>
|
||||
<div class="umb-table-cell">
|
||||
<div class="__settings-input --hasValue" ng-if="entry.settingsElementTypeAlias !== null" >
|
||||
{{ settingsPreview = vm.getElementTypeByAlias(entry.settingsElementTypeAlias); "" }}
|
||||
<umb-node-preview icon="settingsPreview.icon" name="settingsPreview.name"></umb-node-preview>
|
||||
<div class="__control-actions">
|
||||
<button type="button" class="btn-reset __control-actions-btn --open umb-outline" ng-click="vm.openElementType(entry.settingsElementTypeAlias)">
|
||||
<i class="icon icon-edit"></i>
|
||||
</button>
|
||||
<button type="button" class="btn-reset __control-actions-btn --remove umb-outline" ng-click="vm.requestRemoveSettingsForEntry(entry)">
|
||||
<i class="icon icon-wrong"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-reset __settings-input --noValue umb-outline" ng-if="entry.settingsElementTypeAlias === null" ng-click="vm.addSettingsForEntry($event, entry)">
|
||||
<localize key="blockEditor_addSettingsElementType">Add settings</localize>
|
||||
</button>
|
||||
</div>
|
||||
<div class="umb-table-cell action-cell --noOverflow">
|
||||
<button type="button" class="btn-icon umb-outline" ng-click="vm.requestRemoveEntryByIndex($index)">
|
||||
<i class="icon icon-trash" aria-hidden="true"></i>
|
||||
<localize key="general_delete" class="sr-only">Delete</localize>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-reset add-button" ng-click="vm.openAddDialog($event)" ng-disabled="!vm.enableAddEntry">
|
||||
<localize key="general_add">Add</localize>
|
||||
</button>
|
||||
-->
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
}));
|
||||
|
||||
|
||||
var blockConfigurationMock = {contentTypeAlias: "testAlias", label:"Test label", settingsElementTypeAlias: null, view: "testview.html"};
|
||||
var blockConfigurationMock = {contentTypeKey: "testKey", label:"Test label", settingsElementTypeKey: null, view: "testview.html"};
|
||||
|
||||
var propertyModelMock = {
|
||||
layout: {
|
||||
@@ -39,7 +39,7 @@
|
||||
data: [
|
||||
{
|
||||
udi: 1234,
|
||||
contentTypeAlias: "testAlias",
|
||||
contentTypeKey: "testKey",
|
||||
testproperty: "myTestValue"
|
||||
}
|
||||
]
|
||||
@@ -64,7 +64,7 @@
|
||||
it('getBlockConfiguration provide the requested block configurtion', function () {
|
||||
var modelObject = blockEditorService.createModelObject({}, "Umbraco.TestBlockEditor", [blockConfigurationMock], $scope);
|
||||
|
||||
expect(modelObject.getBlockConfiguration(blockConfigurationMock.contentTypeAlias).label).toBe(blockConfigurationMock.label);
|
||||
expect(modelObject.getBlockConfiguration(blockConfigurationMock.contentTypeKey).label).toBe(blockConfigurationMock.label);
|
||||
});
|
||||
|
||||
it('loadScaffolding provides data for itemPicker', function (done) {
|
||||
@@ -73,7 +73,7 @@
|
||||
modelObject.loadScaffolding().then(() => {
|
||||
var itemPickerOptions = modelObject.getAvailableBlocksForBlockPicker();
|
||||
expect(itemPickerOptions.length).toBe(1);
|
||||
expect(itemPickerOptions[0].blockConfigModel.contentTypeAlias).toBe(blockConfigurationMock.contentTypeAlias);
|
||||
expect(itemPickerOptions[0].blockConfigModel.contentTypeKey).toBe(blockConfigurationMock.contentTypeKey);
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
@@ -369,6 +369,38 @@ namespace Umbraco.Web.Editors
|
||||
return mapped;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets an empty content item for the document type.
|
||||
/// </summary>
|
||||
/// <param name="contentTypeKey"></param>
|
||||
/// <param name="parentId"></param>
|
||||
[OutgoingEditorModelEvent]
|
||||
public ContentItemDisplay GetEmptyByKey(string contentTypeKey, int parentId)
|
||||
{
|
||||
|
||||
Guid.TryParse(contentTypeKey, out Guid contentTypeGuid);
|
||||
|
||||
var contentType = Services.ContentTypeService.Get(contentTypeGuid);
|
||||
if (contentType == null)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var emptyContent = Services.ContentService.Create("", parentId, contentType.Alias, Security.GetUserId().ResultOr(0));
|
||||
var mapped = MapToDisplay(emptyContent);
|
||||
// translate the content type name if applicable
|
||||
mapped.ContentTypeName = Services.TextService.UmbracoDictionaryTranslate(mapped.ContentTypeName);
|
||||
// if your user type doesn't have access to the Settings section it would not get this property mapped
|
||||
if (mapped.DocumentType != null)
|
||||
mapped.DocumentType.Name = Services.TextService.UmbracoDictionaryTranslate(mapped.DocumentType.Name);
|
||||
|
||||
//remove the listview app if it exists
|
||||
mapped.ContentApps = mapped.ContentApps.Where(x => x.Alias != "umbListView").ToList();
|
||||
|
||||
return mapped;
|
||||
}
|
||||
|
||||
[OutgoingEditorModelEvent]
|
||||
public ContentItemDisplay GetEmpty(int blueprintId, int parentId)
|
||||
{
|
||||
@@ -821,7 +853,7 @@ namespace Umbraco.Web.Editors
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// For invariant, the variants collection count will be 1 and this will check if that invariant item has the critical values for persistence (i.e. Name)
|
||||
///
|
||||
///
|
||||
/// For variant, each variant will be checked for critical data for persistence and if it's not there then it's flags will be reset and it will not
|
||||
/// be persisted. However, we also need to deal with the case where all variants don't pass this check and then there is nothing to save. This also deals
|
||||
/// with removing the Name validation keys based on data annotations validation for items that haven't been marked to be saved.
|
||||
@@ -908,8 +940,8 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
var savedWithoutErrors = contentItem.Variants
|
||||
.Where(x => x.Save && !variantErrors.Contains((x.Culture, x.Segment)))
|
||||
.Select(x => (culture: x.Culture, segment: x.Segment));
|
||||
|
||||
.Select(x => (culture: x.Culture, segment: x.Segment));
|
||||
|
||||
foreach (var (culture, segment) in savedWithoutErrors)
|
||||
{
|
||||
var variantName = GetVariantName(culture, segment);
|
||||
@@ -1258,7 +1290,7 @@ namespace Umbraco.Web.Editors
|
||||
//Now check if there are validation errors on each variant.
|
||||
//If validation errors are detected on a variant and it's state is set to 'publish', then we
|
||||
//need to change it to 'save'.
|
||||
//It is a requirement that this is performed AFTER ValidatePublishingMandatoryLanguages.
|
||||
//It is a requirement that this is performed AFTER ValidatePublishingMandatoryLanguages.
|
||||
foreach (var variant in contentItem.Variants)
|
||||
{
|
||||
if (variantErrors.Contains((variant.Culture, variant.Segment)))
|
||||
@@ -1389,7 +1421,7 @@ namespace Umbraco.Web.Editors
|
||||
/// <param name="segment">Segment to assign the error to</param>
|
||||
/// <param name="localizationKey"></param>
|
||||
/// <param name="cultureToken">
|
||||
/// The culture used in the localization message, null by default which means <see cref="culture"/> will be used.
|
||||
/// The culture used in the localization message, null by default which means <see cref="culture"/> will be used.
|
||||
/// </param>
|
||||
private void AddVariantValidationError(string culture, string segment, string localizationKey, string cultureToken = null)
|
||||
{
|
||||
@@ -1402,7 +1434,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the human readable variant name based on culture and segment
|
||||
/// Creates the human readable variant name based on culture and segment
|
||||
/// </summary>
|
||||
/// <param name="culture">Culture</param>
|
||||
/// <param name="segment">Segment</param>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
public abstract class BlockEditorPropertyEditor : DataEditor
|
||||
{
|
||||
public const string ContentTypeAliasPropertyKey = "contentTypeAlias";
|
||||
public const string ContentTypeKeyPropertyKey = "contentTypeKey";
|
||||
public const string UdiPropertyKey = "udi";
|
||||
private readonly IBlockEditorDataHelper _dataHelper;
|
||||
private readonly Lazy<PropertyEditorCollection> _propertyEditors;
|
||||
@@ -166,13 +166,13 @@ namespace Umbraco.Web.PropertyEditors
|
||||
public BlockEditorValues(IBlockEditorDataHelper dataHelper, IContentTypeService contentTypeService)
|
||||
{
|
||||
_dataHelper = dataHelper;
|
||||
_contentTypes = new Lazy<Dictionary<string, IContentType>>(() => contentTypeService.GetAll().ToDictionary(c => c.Alias));
|
||||
_contentTypes = new Lazy<Dictionary<string, IContentType>>(() => contentTypeService.GetAll().ToDictionary(c => c.Key));
|
||||
}
|
||||
|
||||
private IContentType GetElementType(JObject item)
|
||||
{
|
||||
var contentTypeAlias = item[ContentTypeAliasPropertyKey]?.ToObject<string>() ?? string.Empty;
|
||||
_contentTypes.Value.TryGetValue(contentTypeAlias, out var contentType);
|
||||
var contentTypeKey = item[ContentTypeKeyPropertyKey]?.ToObject<string>() ?? string.Empty;
|
||||
_contentTypes.Value.TryGetValue(contentTypeKey, out var contentType);
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@@ -270,6 +270,6 @@ namespace Umbraco.Web.PropertyEditors
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static bool IsSystemPropertyKey(string propertyKey) => ContentTypeAliasPropertyKey == propertyKey || UdiPropertyKey == propertyKey;
|
||||
private static bool IsSystemPropertyKey(string propertyKey) => ContentTypeKeyPropertyKey == propertyKey || UdiPropertyKey == propertyKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace Umbraco.Web.PropertyEditors
|
||||
[JsonProperty("thumbnail")]
|
||||
public string Thumbnail { get; set; }
|
||||
|
||||
[JsonProperty("contentTypeAlias")]
|
||||
public string Alias { get; set; }
|
||||
[JsonProperty("contentTypeKey")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("settingsElementTypeAlias")]
|
||||
public string SettingsElementTypeAlias { get; set; }
|
||||
[JsonProperty("settingsElementTypeKey")]
|
||||
public string SettingsElementTypeKey { get; set; }
|
||||
|
||||
[JsonProperty("view")]
|
||||
public string View { get; set; }
|
||||
|
||||
@@ -20,15 +20,16 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
}
|
||||
|
||||
public IPublishedElement ConvertToElement(
|
||||
JObject sourceObject, string contentTypeAliasPropertyKey,
|
||||
JObject sourceObject, string contentTypeKeyPropertyKey,
|
||||
PropertyCacheLevel referenceCacheLevel, bool preview)
|
||||
{
|
||||
var elementTypeAlias = sourceObject[contentTypeAliasPropertyKey]?.ToObject<string>();
|
||||
if (string.IsNullOrEmpty(elementTypeAlias))
|
||||
var elementTypeKey = sourceObject[contentTypeKeyPropertyKey]?.ToObject<string>();
|
||||
if (string.IsNullOrEmpty(elementTypeKey))
|
||||
return null;
|
||||
|
||||
// only convert element types - content types will cause an exception when PublishedModelFactory creates the model
|
||||
var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias);
|
||||
// TODO: make this work with keys.
|
||||
var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeKey);
|
||||
if (publishedContentType == null || publishedContentType.IsElement == false)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
{
|
||||
var configuration = propertyType.DataType.ConfigurationAs<BlockListConfiguration>();
|
||||
var contentTypes = configuration.Blocks;
|
||||
var contentTypeMap = contentTypes.ToDictionary(x => x.Alias);
|
||||
var contentTypeMap = contentTypes.ToDictionary(x => x.Key);
|
||||
var elements = (contentTypes.Length == 1
|
||||
? (IList<IPublishedElement>)_publishedModelFactory.CreateModelList(contentTypes[0].Alias)
|
||||
// TODO: make this work with key
|
||||
? (IList<IPublishedElement>)_publishedModelFactory.CreateModelList(contentTypes[0].Key)
|
||||
: new List<IPublishedElement>())
|
||||
.ToDictionary(x => x.Key, x => x);
|
||||
|
||||
@@ -80,7 +81,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
// parse the data elements
|
||||
foreach (var data in jsonData.Cast<JObject>())
|
||||
{
|
||||
var element = _blockConverter.ConvertToElement(data, BlockEditorPropertyEditor.ContentTypeAliasPropertyKey, referenceCacheLevel, preview);
|
||||
var element = _blockConverter.ConvertToElement(data, BlockEditorPropertyEditor.contentTypeKeyPropertyKey, referenceCacheLevel, preview);
|
||||
if (element == null) continue;
|
||||
elements[element.Key] = element;
|
||||
}
|
||||
@@ -92,7 +93,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
{
|
||||
var settingsJson = blockListLayout["settings"] as JObject;
|
||||
// the result of this can be null, that's ok
|
||||
var element = settingsJson != null ? _blockConverter.ConvertToElement(settingsJson, BlockEditorPropertyEditor.ContentTypeAliasPropertyKey, referenceCacheLevel, preview) : null;
|
||||
var element = settingsJson != null ? _blockConverter.ConvertToElement(settingsJson, BlockEditorPropertyEditor.contentTypeKeyPropertyKey, referenceCacheLevel, preview) : null;
|
||||
|
||||
if (!Udi.TryParse(blockListLayout.Value<string>("udi"), out var udi) || !(udi is GuidUdi guidUdi))
|
||||
continue;
|
||||
@@ -101,11 +102,11 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
if (!elements.TryGetValue(guidUdi.Guid, out var data))
|
||||
continue;
|
||||
|
||||
if (!contentTypeMap.TryGetValue(data.ContentType.Alias, out var blockConfig))
|
||||
if (!contentTypeMap.TryGetValue(data.ContentType.Key, out var blockConfig))
|
||||
continue;
|
||||
|
||||
// this can happen if they have a settings type, save content, remove the settings type, and display the front-end page before saving the content again
|
||||
if (element != null && string.IsNullOrWhiteSpace(blockConfig.SettingsElementTypeAlias))
|
||||
if (element != null && string.IsNullOrWhiteSpace(blockConfig.SettingsElementTypeKey))
|
||||
element = null;
|
||||
|
||||
var layoutRef = new BlockListLayoutReference(udi, data, element);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
var configuration = propertyType.DataType.ConfigurationAs<NestedContentConfiguration>();
|
||||
var contentTypes = configuration.ContentTypes;
|
||||
var elements = contentTypes.Length == 1
|
||||
? PublishedModelFactory.CreateModelList(contentTypes[0].Alias)
|
||||
? PublishedModelFactory.CreateModelList(contentTypes[0].Key)
|
||||
: new List<IPublishedElement>();
|
||||
|
||||
var value = (string)inter;
|
||||
|
||||
Reference in New Issue
Block a user