|
101 | 101 |
|
102 | 102 | /**
|
103 | 103 | * Generate label for Block, uses either the labelInterpolator or falls back to the contentTypeName.
|
104 |
| - * @param {Object} blockObject BlockObject to recive data values from. |
| 104 | + * @param {Object} blockObject BlockObject to receive data values from. |
105 | 105 | */
|
106 | 106 | function getBlockLabel(blockObject) {
|
107 | 107 | if (blockObject.labelInterpolator !== undefined) {
|
108 |
| - var labelVars = Object.assign({"$contentTypeName": blockObject.content.contentTypeName, "$settings": blockObject.settingsData || {}, "$layout": blockObject.layout || {}, "$index": (blockObject.index || 0)+1 }, blockObject.data); |
| 108 | + // blockobject.content may be null if the block is no longer allowed, |
| 109 | + // so try and fall back to the label in the config, |
| 110 | + // if that too is null, there's not much we can do, so just default to empty string. |
| 111 | + var contentTypeName; |
| 112 | + if(blockObject.content != null){ |
| 113 | + contentTypeName = blockObject.content.contentTypeName; |
| 114 | + } |
| 115 | + else if(blockObject.config != null && blockObject.config.label != null){ |
| 116 | + contentTypeName = blockObject.config.label; |
| 117 | + } |
| 118 | + else { |
| 119 | + contentTypeName = ""; |
| 120 | + } |
| 121 | + |
| 122 | + var labelVars = Object.assign({ |
| 123 | + "$contentTypeName": contentTypeName, |
| 124 | + "$settings": blockObject.settingsData || {}, |
| 125 | + "$layout": blockObject.layout || {}, |
| 126 | + "$index": (blockObject.index || 0)+1 |
| 127 | + }, blockObject.data); |
109 | 128 | var label = blockObject.labelInterpolator(labelVars);
|
110 | 129 | if (label) {
|
111 | 130 | return label;
|
|
511 | 530 | * @methodOf umbraco.services.blockEditorModelObject
|
512 | 531 | * @description Retrieve a Block Object for the given layout entry.
|
513 | 532 | * The Block Object offers the necessary data to display and edit a block.
|
514 |
| - * The Block Object setups live syncronization of content and settings models back to the data of your Property Editor model. |
515 |
| - * The returned object, named ´BlockObject´, contains several usefull models to make editing of this block happen. |
| 533 | + * The Block Object setups live synchronization of content and settings models back to the data of your Property Editor model. |
| 534 | + * The returned object, named ´BlockObject´, contains several useful models to make editing of this block happen. |
516 | 535 | * The ´BlockObject´ contains the following properties:
|
517 |
| - * - key {string}: runtime generated key, usefull for tracking of this object |
| 536 | + * - key {string}: runtime generated key, useful for tracking of this object |
518 | 537 | * - content {Object}: Content model, the content data in a ElementType model.
|
519 | 538 | * - settings {Object}: Settings model, the settings data in a ElementType model.
|
520 | 539 | * - config {Object}: A local deep copy of the block configuration model.
|
521 | 540 | * - label {string}: The label for this block.
|
522 | 541 | * - updateLabel {Method}: Method to trigger an update of the label for this block.
|
523 | 542 | * - data {Object}: A reference to the content data object from your property editor model.
|
524 | 543 | * - settingsData {Object}: A reference to the settings data object from your property editor model.
|
525 |
| - * - layout {Object}: A refernce to the layout entry from your property editor model. |
| 544 | + * - layout {Object}: A reference to the layout entry from your property editor model. |
526 | 545 | * @param {Object} layoutEntry the layout entry object to build the block model from.
|
527 |
| - * @return {Object | null} The BlockObject for the given layout entry. Or null if data or configuration wasnt found for this block. |
| 546 | + * @return {Object | null} The BlockObject for the given layout entry. Or null if data or configuration wasn't found for this block. |
528 | 547 | */
|
529 | 548 | getBlockObject: function (layoutEntry) {
|
530 |
| - |
531 | 549 | var contentUdi = layoutEntry.contentUdi;
|
532 | 550 |
|
533 | 551 | var dataModel = getDataByUdi(contentUdi, this.value.contentData);
|
|
0 commit comments