Merge pull request #8980 from umbraco/v8/bugfix/8911-ensure-scaffold-exists

Review: Check that scaffold exists
This commit is contained in:
Warren Buckley
2020-09-30 15:45:18 +01:00
committed by GitHub
8 changed files with 98 additions and 46 deletions

View File

@@ -425,7 +425,11 @@
if (self.scaffolds) {
self.scaffolds.push(formatScaffoldData(scaffold));
}
}));
}).catch(
() => {
// Do nothing if we get an error.
}
));
});
return $q.all(tasks);
@@ -439,7 +443,14 @@
* @return {Array} array of strings representing alias.
*/
getAvailableAliasesForBlockContent: function () {
return this.blockConfigurations.map(blockConfiguration => this.getScaffoldFromKey(blockConfiguration.contentElementTypeKey).contentTypeAlias);
return this.blockConfigurations.map(
(blockConfiguration) => {
var scaffold = this.getScaffoldFromKey(blockConfiguration.contentElementTypeKey);
if (scaffold) {
return scaffold.contentTypeAlias;
}
}
);
},
/**
@@ -519,7 +530,7 @@
var dataModel = getDataByUdi(contentUdi, this.value.contentData);
if (dataModel === null) {
console.error("Couldn't find content model of " + contentUdi)
console.error("Couldn't find content data of " + contentUdi)
return null;
}
@@ -591,7 +602,7 @@
var settingsData = getDataByUdi(settingsUdi, this.value.settingsData);
if (settingsData === null) {
console.error("Couldnt find content settings data of " + settingsUdi)
console.error("Couldnt find settings data of " + settingsUdi)
return null;
}

View File

@@ -1,11 +1,17 @@
<div class="__showcase" ng-style="{'background-color':vm.blockConfigModel.backgroundColor, 'background-image': vm.styleBackgroundImage}">
<i ng-if="vm.blockConfigModel.thumbnail == null && vm.elementTypeModel.icon" class="__icon {{ vm.elementTypeModel.icon }}" ng-attr-style="{{'color:'+vm.blockConfigModel.iconColor+' !important'}}" aria-hidden="true"></i>
<div class="__showcase"
ng-class="{'--error':vm.elementTypeModel === null}"
ng-style="{'background-color':vm.blockConfigModel.backgroundColor, 'background-image': vm.styleBackgroundImage}">
<i ng-if="vm.blockConfigModel.thumbnail == null" class="__icon {{ vm.elementTypeModel ? vm.elementTypeModel.icon : 'icon-block' }}" ng-attr-style="{{'color:'+vm.blockConfigModel.iconColor+' !important'}}" aria-hidden="true"></i>
</div>
<div class="__info">
<div class="__info" ng-if="vm.elementTypeModel !== null">
<div class="__name" ng-bind="vm.elementTypeModel.name"></div>
<div class="__subname" ng-if="vm.elementTypeModel.description" ng-bind="vm.elementTypeModel.description"></div>
</div>
<div class="__info --error" ng-if="vm.elementTypeModel === null">
<div class="__name"><localize key="blockEditor_elementTypeDoesNotExistHeadline">Other</localize></div>
<div class="__subname"><localize key="blockEditor_elementTypeDoesNotExistDescription">Other</localize></div>
</div>
<ng-transclude></ng-transclude>

View File

@@ -60,6 +60,14 @@ umb-block-card {
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
&.--error {
border: 2px solid @errorBackground;
border-bottom: none;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
box-sizing: border-box;
}
.__icon {
position: absolute;
@@ -75,26 +83,35 @@ umb-block-card {
.__info {
width: 100%;
background-color: #fff;
padding-top: 10px;
padding-bottom: 11px;// 10 + 1 to compentiate for the -1 substraction in margin-bottom.
&.--error {
background-color: @errorBackground;
.__name, .__subname {
color: @errorText;
}
}
.__name {
font-weight: bold;
font-size: 14px;
color: @ui-action-type;
margin-left: 16px;
margin-top: 10px;
margin-bottom: -1px;
}
.__subname {
color: @gray-4;
font-size: 12px;
margin-left: 16px;
margin-top: 1px;
margin-bottom: -1px;
line-height: 1.5em;
}
}
&:hover {
.__info {
.__info:not(.--error) {
.__name {
color: @ui-action-type-hover;
}

View File

@@ -54,7 +54,7 @@
var contentElementType = vm.getElementTypeByKey($scope.model.value[index].contentElementTypeKey);
overlayService.confirmDelete({
title: data[0],
content: localizationService.tokenReplace(data[1], [contentElementType.name]),
content: localizationService.tokenReplace(data[1], [contentElementType ? contentElementType.name : "(Unavailable ElementType)"]),
confirmMessage: data[2],
close: function () {
overlayService.close();
@@ -91,7 +91,7 @@
if (vm.elementTypes) {
return vm.elementTypes.find(function (type) {
return type.key === key;
});
}) || null;
}
};
@@ -99,8 +99,11 @@
//we have to add the 'alias' property to the objects, to meet the data requirements of itempicker.
var selectedItems = Utilities.copy($scope.model.value).forEach((obj) => {
obj.alias = vm.getElementTypeByKey(obj.contentElementTypeKey).alias;
return obj;
var elementType = vm.getElementTypeByKey(obj.contentElementTypeKey);
if(elementType) {
obj.alias = elementType.alias;
return obj;
}
});
var availableItems = vm.getAvailableElementTypes()
@@ -178,31 +181,37 @@
vm.openBlockOverlay = function (block) {
localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [vm.getElementTypeByKey(block.contentElementTypeKey).name]).then(function (data) {
var elementType = vm.getElementTypeByKey(block.contentElementTypeKey);
var clonedBlockData = Utilities.copy(block);
vm.openBlock = block;
if(elementType) {
localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [elementType.name]).then(function (data) {
var overlayModel = {
block: clonedBlockData,
title: data,
view: "views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.overlay.html",
size: "small",
submit: function(overlayModel) {
loadElementTypes()// lets load elementType again, to ensure we are up to date.
TransferProperties(overlayModel.block, block);// transfer properties back to block object. (Doing this cause we dont know if block object is added to model jet, therefor we cant use index or replace the object.)
overlayModel.close();
},
close: function() {
editorService.close();
vm.openBlock = null;
}
};
var clonedBlockData = Utilities.copy(block);
vm.openBlock = block;
// open property settings editor
editorService.open(overlayModel);
var overlayModel = {
block: clonedBlockData,
title: data,
view: "views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.overlay.html",
size: "small",
submit: function(overlayModel) {
loadElementTypes()// lets load elementType again, to ensure we are up to date.
TransferProperties(overlayModel.block, block);// transfer properties back to block object. (Doing this cause we dont know if block object is added to model jet, therefor we cant use index or replace the object.)
overlayModel.close();
},
close: function() {
editorService.close();
vm.openBlock = null;
}
};
});
// open property settings editor
editorService.open(overlayModel);
});
} else {
alert("Cannot be edited cause ElementType does not exist.");
}
};

View File

@@ -35,17 +35,20 @@
};
vm.openElementType = function(elementTypeKey) {
var elementTypeId = vm.getElementTypeByKey(elementTypeKey).id;
const editor = {
id: elementTypeId,
submit: function (model) {
editorService.close();
},
close: function () {
editorService.close();
}
};
editorService.documentTypeEditor(editor);
var elementType = vm.getElementTypeByKey(elementTypeKey);
if (elementType) {
var elementTypeId = elementType.id;
const editor = {
id: elementTypeId,
submit: function (model) {
editorService.close();
},
close: function () {
editorService.close();
}
};
editorService.documentTypeEditor(editor);
}
};
vm.createElementTypeAndCallback = function(callback) {
@@ -110,7 +113,7 @@
overlayService.confirmRemove({
title: data[0],
content: localizationService.tokenReplace(data[1], [settingsElementType.name]),
content: localizationService.tokenReplace(data[1], [(settingsElementType ? settingsElementType.name : "(Unavailable ElementType)")]),
close: function () {
overlayService.close();
},

View File

@@ -1856,6 +1856,8 @@ Mange hilsner fra Umbraco robotten
<key alias="blockHasChanges">Du har lavet ændringer til dette indhold. Er du sikker på at du vil kassere dem?</key>
<key alias="confirmCancelBlockCreationHeadline">Annuller oprettelse?</key>
<key alias="confirmCancelBlockCreationMessage"><![CDATA[Er du sikker på at du vil annullere oprettelsen.]]></key>
<key alias="elementTypeDoesNotExistHeadline">Error!</key>
<key alias="elementTypeDoesNotExistDescription">The ElementType of this block does not exist anymore</key>
</area>
</language>

View File

@@ -2472,6 +2472,8 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="blockHasChanges">You have made changes to this content. Are you sure you want to discard them?</key>
<key alias="confirmCancelBlockCreationHeadline">Discard creation?</key>
<key alias="confirmCancelBlockCreationMessage"><![CDATA[Are you sure you want to cancel the creation.]]></key>
<key alias="elementTypeDoesNotExistHeadline">Error!</key>
<key alias="elementTypeDoesNotExistDescription">The ElementType of this block does not exist anymore</key>
</area>
<area alias="contentTemplatesDashboard">
<key alias="whatHeadline">What are Content Templates?</key>

View File

@@ -2492,6 +2492,8 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="blockHasChanges">You have made changes to this content. Are you sure you want to discard them?</key>
<key alias="confirmCancelBlockCreationHeadline">Discard creation?</key>
<key alias="confirmCancelBlockCreationMessage"><![CDATA[Are you sure you want to cancel the creation.]]></key>
<key alias="elementTypeDoesNotExistHeadline">Error!</key>
<key alias="elementTypeDoesNotExistDescription">The ElementType of this block does not exist anymore</key>
</area>
<area alias="contentTemplatesDashboard">
<key alias="whatHeadline">What are Content Templates?</key>