Skip to content

Commit

Permalink
Falling back to contentTypeName when Block List label is empty (#10963)
Browse files Browse the repository at this point in the history
* Falling back to contentTypeName when Block List label is empty

* Adding $contentTypeName variable for Block List labels
  • Loading branch information
callumbwhyte authored Sep 21, 2021
1 parent 1e1276f commit 405ed44
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 405ed44

Please sign in to comment.