Falling back to contentTypeName when Block List label is empty (#10963)
* Falling back to contentTypeName when Block List label is empty * Adding $contentTypeName variable for Block List labels
This commit is contained in:
@@ -99,20 +99,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate label for Block, uses either the labelInterpolator or falls back to the contentTypeName.
|
||||
* @param {Object} blockObject BlockObject to recive data values from.
|
||||
*/
|
||||
function getBlockLabel(blockObject) {
|
||||
if (blockObject.labelInterpolator !== undefined) {
|
||||
var labelVars = Object.assign({"$settings": blockObject.settingsData || {}, "$layout": blockObject.layout || {}, "$index": (blockObject.index || 0)+1 }, blockObject.data);
|
||||
return blockObject.labelInterpolator(labelVars);
|
||||
var labelVars = Object.assign({"$contentTypeName": blockObject.content.contentTypeName, "$settings": blockObject.settingsData || {}, "$layout": blockObject.layout || {}, "$index": (blockObject.index || 0)+1 }, blockObject.data);
|
||||
var label = blockObject.labelInterpolator(labelVars);
|
||||
if (label) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
return blockObject.content.contentTypeName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to add watchers on all properties in a content or settings model
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user