var PHONE_TYPES = _.map(CRM.PseudoConstant.phoneType, function(value, key) {
return {val: key, label: value};
});
+
+ var WEBSITE_TYPES = _.map(CRM.PseudoConstant.websiteType, function(value, key) {
+ return {val: key, label: value};
+ });
var DEFAULT_PHONE_TYPE_ID = PHONE_TYPES[0].val;
+ var DEFAULT_WEBSITE_TYPE_ID = WEBSITE_TYPES[0].val;
/**
* Add a help link to a form label
var coreTypesExpr = parts[0];
var subTypesExpr = parts[1];
- if (coreTypesExpr && coreTypesExpr != '') {
+ if (!_.isEmpty(coreTypesExpr)) {
_.each(coreTypesExpr.split(','), function(coreType){
typeList.coreTypes[coreType] = true;
});
}
//CRM-15427 Allow Multiple subtype filtering
- if (subTypesExpr && subTypesExpr != '') {
+ if (!_.isEmpty(subTypesExpr)) {
if (subTypesExpr.indexOf(';;') !== -1) {
var subTypeparts = subTypesExpr.replace(/;;/g,'\0').split('\0');
_.each(subTypeparts, function(subTypepart) {
case 'Individual':
case 'Organization':
case 'Household':
+ case 'Formatting':
return 'contact_1';
case 'Activity':
return 'activity_1';
throw "Cannot guess entity name for field_type=" + field_type;
}
}
- }
+ };
/**
* Represents a field in a customizable form.
type: 'Select',
options: LOCATION_TYPES
},
+ 'website_type_id': {
+ title: ts('Website Type'),
+ type: 'Select',
+ options: WEBSITE_TYPES
+ },
'phone_type_id': {
title: ts('Phone Type'),
type: 'Select',
}
},
initialize: function() {
+ if (this.get('field_name').indexOf('formatting') === 0) {
+ this.schema.help_pre.title = ts('Markup');
+ }
this.set('entity_name', CRM.UF.guessEntityName(this.get('field_type')));
this.on("rel:ufGroupModel", this.applyDefaults, this);
this.on('change', watchChanges);
if (fieldSchema && fieldSchema.civiIsLocation && !this.get('location_type_id')) {
this.set('location_type_id', DEFAULT_LOCATION_TYPE_ID);
}
+ if (fieldSchema && fieldSchema.civiIsWebsite && !this.get('website_type_id')) {
+ this.set('website_type_id', DEFAULT_WEBSITE_TYPE_ID);
+ }
if (fieldSchema && fieldSchema.civiIsPhone && !this.get('phone_type_id')) {
this.set('phone_type_id', DEFAULT_PHONE_TYPE_ID);
}
* @return {String}
*/
getSignature: function() {
- return this.get("entity_name")
- + '::' + this.get("field_name")
- + '::' + (this.get("location_type_id") ? this.get("location_type_id") : '')
- + '::' + (this.get("phone_type_id") ? this.get("phone_type_id") : '');
+ return this.get("entity_name") +
+ '::' + this.get("field_name") +
+ '::' + (this.get("location_type_id") ? this.get("location_type_id") : this.get("website_type_id") ? this.get("website_type_id") : '') +
+ '::' + (this.get("phone_type_id") ? this.get("phone_type_id") : '');
},
/**
var entity_name = ufFieldModel.get('entity_name'),
field_name = ufFieldModel.get('field_name'),
fieldSchema = this.getRel('ufGroupModel').getFieldSchema(ufFieldModel.get('entity_name'), ufFieldModel.get('field_name'));
-
+ if (field_name.indexOf('formatting') === 0) {
+ return true;
+ }
if (! fieldSchema) {
return false;
}
if (fieldSchema.civiIsLocation) {
limit *= LOCATION_TYPES.length;
}
+ if (fieldSchema.civiIsWebsite) {
+ limit *= WEBSITE_TYPES.length;
+ }
if (fieldSchema.civiIsPhone) {
limit *= PHONE_TYPES.length;
}
},
watchDuplicates: function(model, collection, options) {
model.on('change:location_type_id', this.markDuplicates, this);
+ model.on('change:website_type_id', this.markDuplicates, this);
model.on('change:phone_type_id', this.markDuplicates, this);
this.markDuplicates();
},
unwatchDuplicates: function(model, collection, options) {
model.off('change:location_type_id', this.markDuplicates, this);
+ model.off('change:website_type_id', this.markDuplicates, this);
model.off('change:phone_type_id', this.markDuplicates, this);
this.markDuplicates();
},
},
'help_post': {
title: ts('Post-form Help'),
- help: ts('Explanatory text displayed at the end of the form.')
- + ts('Note that this help text is displayed on profile create/edit screens only.'),
+ help: ts('Explanatory text displayed at the end of the form.') +
+ ts('Note that this help text is displayed on profile create/edit screens only.'),
type: 'TextArea'
},
'help_pre': {
- title: ts('Pre-form Help '),
- help: ts('Explanatory text displayed at the beginning of the form.')
- + ts('Note that this help text is displayed on profile create/edit screens only.'),
+ title: ts('Pre-form Help'),
+ help: ts('Explanatory text displayed at the beginning of the form.') +
+ ts('Note that this help text is displayed on profile create/edit screens only.'),
type: 'TextArea'
},
'is_active': {
options: YESNO
},
'is_proximity_search': {
- title: ts('Proximity search'),
+ title: ts('Proximity Search'),
help: ts('FIXME'),
type: 'Select',
options: YESNO // FIXME
ufGroupModel: this
});
paletteFieldCollection.sync = function(method, model, options) {
- options || (options = {});
+ if (!options) options = {};
// console.log(method, model, options);
switch (method) {
case 'read':
case 'create':
case 'update':
case 'delete':
+ throw 'Unsupported method: ' + method;
+
default:
throw 'Unsupported method: ' + method;
}
return ufEntity.getModelClass();
},
getFieldSchema: function(entity_name, field_name) {
+ if (field_name.indexOf('formatting') === 0) {
+ field_name = 'formatting';
+ }
var modelClass = this.getModelClass(entity_name);
var fieldSchema = modelClass.prototype.schema[field_name];
if (!fieldSchema) {
- if (console.log) {
- console.log('Failed to locate field: ' + entity_name + "." + field_name);
- }
+ CRM.console('warn', 'Failed to locate field: ' + entity_name + "." + field_name);
return null;
}
return fieldSchema;
checkGroupType: function(validTypesExpr, allowAllSubtypes) {
var allMatched = true;
allowAllSubtypes = allowAllSubtypes || false;
- if (! this.get('group_type') || this.get('group_type') == '') {
+ if (_.isEmpty(this.get('group_type'))) {
return true;
}