From cbca5bd9e6d75eae9f402ec8bb9e131cce035f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 12 Jun 2020 13:56:14 +0200 Subject: [PATCH] still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service. --- .../common/services/blockeditor.service.js | 19 ++++++++++++++----- .../blocklist/blocklist.component.js | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/blockeditor.service.js b/src/Umbraco.Web.UI.Client/src/common/services/blockeditor.service.js index f36490fd1c..8ef6bfa214 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/blockeditor.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/blockeditor.service.js @@ -310,7 +310,7 @@ * @return {Array} array of strings representing alias. */ getAvailableAliasesForBlockContent: function() { - return this.blockConfigurations.map(blockConfiguration => this.getScaffoldFor(blockConfiguration.contentTypeKey).contentTypeKey); + return this.blockConfigurations.map(blockConfiguration => this.getScaffoldFromKey(blockConfiguration.contentTypeKey).contentTypeKey); }, /** @@ -323,7 +323,7 @@ var blocks = []; this.blockConfigurations.forEach(blockConfiguration => { - var scaffold = this.getScaffoldFor(blockConfiguration.contentTypeKey); + var scaffold = this.getScaffoldFromKey(blockConfiguration.contentTypeKey); if(scaffold) { blocks.push({ blockConfigModel: blockConfiguration, @@ -340,10 +340,19 @@ * @param {string} key contentTypeKey to recive the scaffold model for. * @returns {Object | null} Scaffold model for the that content type. Or null if the scaffolding model dosnt exist in this context. */ - getScaffoldFor: function(contentTypeKey) { + getScaffoldFromKey: function(contentTypeKey) { return this.scaffolds.find(o => o.contentTypeKey === contentTypeKey); }, + /** + * Get scaffold model for a given contentTypeAlias, used by clipboardService. + * @param {string} alias contentTypeAlias to recive the scaffold model for. + * @returns {Object | null} Scaffold model for the that content type. Or null if the scaffolding model dosnt exist in this context. + */ + getScaffoldFromAlias: function(contentTypeAlias) { + return this.scaffolds.find(o => o.contentTypeAlias === contentTypeAlias); + }, + /** * Retrieve editor friendly model of a block. * BlockModel is a class instance which setups live syncronization of content and settings models back to the data of your property editor model. @@ -379,7 +388,7 @@ return null; } - var contentScaffold = this.getScaffoldFor(blockConfiguration.contentTypeKey); + var contentScaffold = this.getScaffoldFromKey(blockConfiguration.contentTypeKey); if(contentScaffold === null) { return null; } @@ -406,7 +415,7 @@ blockModel.watchers = []; if (blockConfiguration.settingsElementTypeKey) { - var settingsScaffold = this.getScaffoldFor(blockConfiguration.settingsElementTypeKey); + var settingsScaffold = this.getScaffoldFromKey(blockConfiguration.settingsElementTypeKey); if (settingsScaffold === null) { return null; } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/blocklist.component.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/blocklist.component.js index c9ca360797..9de525e3ef 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/blocklist.component.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/blocklist.component.js @@ -132,6 +132,8 @@ vm.loading = false; + $scope.$evalAsync(); + } @@ -225,7 +227,7 @@ submit: function(blockEditorModel) { blockModel.retriveValuesFrom(blockEditorModel.content, blockEditorModel.settings) - + editorService.close(); }, close: function() { @@ -302,7 +304,7 @@ { type: "elementType", pasteData: entry.data, - blockConfigModel: modelObject.getScaffoldFor(entry.key), + blockConfigModel: modelObject.getScaffoldFromAlias(entry.alias), elementTypeModel: { name: entry.label, icon: entry.icon