still have the ability to retrive a scaffold model by alias, since we are still using alias in clipboard service.

This commit is contained in:
Niels Lyngsø
2020-06-12 13:56:14 +02:00
parent 80dfea8743
commit cbca5bd9e6
2 changed files with 18 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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