X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=js%2Fmodel%2Fcrm.designer.js;h=752cf86415c8fb75292ce486a7400b7ccc2341c7;hb=eb27db612849178c2d194583d8f11f84f7d0e5dc;hp=729778ae6a4775a68208972aaca89551eed7cb01;hpb=e68bce7b9d941cb8dbf44bc27ca08571df3a4811;p=civicrm-core.git diff --git a/js/model/crm.designer.js b/js/model/crm.designer.js index 729778ae6a..752cf86415 100644 --- a/js/model/crm.designer.js +++ b/js/model/crm.designer.js @@ -1,5 +1,4 @@ -(function($) { - var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {}); +(function($, _) { if (!CRM.Designer) CRM.Designer = {}; // TODO Optimize this class @@ -71,7 +70,9 @@ label: this.getLabel(), entity_name: this.get('entityName'), field_type: this.getFieldSchema().civiFieldType, - field_name: this.get('fieldName') + // For some reason the 'formatting' field gets a random number appended in core so we mimic that here. + // TODO: Why? + field_name: this.get('fieldName') == 'formatting' ? 'formatting_' + (Math.floor(Math.random() * 8999) + 1000) : this.get('fieldName') }); return model; } @@ -96,6 +97,9 @@ * @return {CRM.Designer.PaletteFieldModel} */ getFieldByName: function(entityName, fieldName) { + if (fieldName.indexOf('formatting') === 0) { + fieldName = 'formatting'; + } return this.find(function(paletteFieldModel) { return ((!entityName || paletteFieldModel.get('entityName') == entityName) && paletteFieldModel.get('fieldName') == fieldName); }); @@ -114,4 +118,4 @@ return fieldsByEntitySection; } }); -})(cj); +})(CRM.$, CRM._);