'ActivityType' => array($subTypeId),
);
$entities = array(
- array('entity_name' => 'individual_1', 'entity_type' => 'IndividualModel'),
+ array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'),
array('entity_name' => 'activity_1', 'entity_type' => 'ActivityModel', 'entity_sub_type' => $subTypeId),
);
$this->addProfileSelector('contact_profile_id', ts('Contact Info'), $allowCoreTypes, $allowSubTypes, $entities);
// Register 'individual_1' model
$entities = array();
- $entities[] = array('entity_name' => 'individual_1', 'entity_type' => 'IndividualModel');
+ $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
$allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$allowSubTypes = array();
);
$entities = array(
- array('entity_name' => 'individual_1',
- 'entity_type' => 'IndividualModel'
- ),
- array('entity_name' => 'organization_1',
- 'entity_type' => 'OrganizationModel'
- ),
- array('entity_name' => 'household_1',
- 'entity_type' => 'HouseholdModel'
+ array(
+ 'entity_name' => 'contact_1',
+ 'entity_type' => 'IndividualModel',
),
);
+
$allowCoreTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$allowSubTypes = array();
$this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities);
+ CRM_UF_Page_ProfileEditor::registerProfileScripts();
+ CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel','HouseholdModel'));
+
if (!empty($this->_submitValues['honor_block_is_active'])) {
$this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required');
* ...
* cj('.crm-profile-selector').crmProfileSelector({
* groupTypeFilter: "Contact,Individual,Activity;;ActivityType:7",
- * entities: "individual_1:IndividualModel,activity_1:ActivityModel"
+ * entities: "contact_1:IndividualModel,activity_1:ActivityModel"
* });
*
* Note: The system does not currently support dynamic entities -- it only supports
- * a couple of entities named "individual_1" and "activity_1". See also
+ * a couple of entities named "contact_1" and "activity_1". See also
* CRM.UF.guessEntityName().
*/
$.fn.crmProfileSelector = function(options) {
switch (field_type) {
case 'Contact':
case 'Individual':
- return 'individual_1';
case 'Organization':
- return 'organization_1';
case 'Household':
- return 'household_1';
+ return 'contact_1';
case 'Activity':
return 'activity_1';
case 'Contribution':
},
resetEntities: function() {
var ufGroupModel = this;
+ var deleteFieldList = [];
ufGroupModel.getRel('ufFieldCollection').each(function(ufFieldModel){
if (!ufFieldModel.getFieldSchema()) {
- CRM.alert(ts('The data model no longer includes field "%1"! All references to the field have been removed.', {
- 1: ufFieldModel.get('entity_name') + "." + ufFieldModel.get('field_name')
+ CRM.alert(ts('This profile no longer includes field "%1"! All references to the field have been removed.', {
+ 1: ufFieldModel.get('label')
}), '', 'alert', {expires: false});
- ufFieldModel.destroyLocal();
+ deleteFieldList.push(ufFieldModel);
}
});
+
+ _.each(deleteFieldList, function(ufFieldModel) {
+ ufFieldModel.destroyLocal();
+ });
+
this.getRel('paletteFieldCollection').reset(this.buildPaletteFields());
+
+ // reset to redraw the cancel after entity type is updated.
+ ufGroupModel.getRel('ufFieldCollection').reset(ufGroupModel.getRel('ufFieldCollection').toJSON());
},
/**
*
paletteView.model.getRel('ufEntityCollection').each(function(ufEntityModel){
_.each(ufEntityModel.getSections(), function(section, sectionKey){
- // build filter select
- if (sectionKey == 'default') {
- paletteView.$('.crm-contact-types').append('<option value="' + ufEntityModel.get('entity_name') + '">' + section.title + '</option>');
- }
-
- if (!paletteView.selectedContactType) {
- paletteView.selectedContactType = paletteView.$('.crm-contact-types option:first').val();
- }
// set selected option as default, since we are rebuilding palette
- paletteView.$('.crm-contact-types').val(paletteView.selectedContactType).prop('selected','selected');
-
- if (paletteView.selectedContactType != ufEntityModel.get('entity_name')) {
- return true;
- }
+ paletteView.$('.crm-contact-types').val(ufEntityModel.attributes.entity_type).prop('selected','selected');
var entitySection = ufEntityModel.get('entity_name') + '-' + sectionKey;
var items = [];
$('.crm-designer-palette-tree').jstree("search", $(event.target).val());
},
doSetPaletteEntity: function(event) {
- this.selectedContactType = $('.crm-contact-types :selected').val();
- this.render();
+ // loop through entity collection and remove non-valid entity section's
+ var newUfEntityModels = [];
+ this.model.getRel('ufEntityCollection').each(function(oldUfEntityModel){
+ var values = oldUfEntityModel.toJSON();
+ if (values.entity_name == 'contact_1') {
+ values.entity_type = $('.crm-contact-types :selected').val();
+ }
+ newUfEntityModels.push(new CRM.UF.UFEntityModel(values));
+ });
+ this.model.getRel('ufEntityCollection').reset(newUfEntityModels);
},
doAddToCanvas: function(event) {
var paletteFieldModel = this.model.getRel('paletteFieldCollection').get($(event.currentTarget).attr('data-plm-cid'));
var paletteFieldCollection = this.model.getRel('paletteFieldCollection');
var paletteFieldModel = paletteFieldCollection.getFieldByName(ufFieldModel.get('entity_name'), ufFieldModel.get('field_name'));
var isAddable = ufFieldCollection.isAddable(ufFieldModel);
- this.$('[data-plm-cid='+paletteFieldModel.cid+']').toggleClass('disabled', !isAddable);
+ if (paletteFieldModel) {
+ this.$('[data-plm-cid='+paletteFieldModel.cid+']').toggleClass('disabled', !isAddable);
+ }
},
toggleAll: function(event) {
if ($('.crm-designer-palette-search input').val() == '') {
this.model.getRel('ufFieldCollection')
.on('add', this.updatePlaceholder, this)
.on('remove', this.updatePlaceholder, this)
- .on('add', this.addUFFieldView, this);
+ .on('add', this.addUFFieldView, this)
+ .on('reset', this.render, this);
},
onClose: function() {
this.model.getRel('ufFieldCollection')
.off('add', this.updatePlaceholder, this)
.off('remove', this.updatePlaceholder, this)
- .off('add', this.addUFFieldView, this);
+ .off('add', this.addUFFieldView, this)
+ .off('reset', this.render, this);
},
render: function() {
var ufFieldCanvasView = this;
<div class="crm-designer-palette">
<div class="crm-designer-palette-search">
<div class="crm-filter-objects">
- <span>{ts}Field Type{/ts}: <select class="crm-contact-types"></select></span>
+ <span>{ts}Field Type{/ts}:
+ <select class="crm-contact-types">
+ <option value="IndividualModel">{ts}Individual{/ts}</option>
+ <option value="OrganizationModel">{ts}Organization{/ts}</option>
+ <option value="HouseholdModel">{ts}Household{/ts}</option>
+ </select>
+ </span>
</div>
<hr>
<input type="text" placeholder="{ts}Search Fields{/ts}" />