joinEntity = dotSplit.length > 1 ? dotSplit[0] : null,
fieldName = _.last(dotSplit).split(':')[0],
entityName = searchEntity;
+ // Custom fields contain a dot in their fieldname
+ // If 3 segments, the first is the joinEntity and the last 2 are the custom field
+ if (dotSplit.length === 3) {
+ fieldName = dotSplit[1] + '.' + fieldName;
+ }
+ // If 2 segments, it's ambiguous whether this is a custom field or joined field. Search the main entity first.
+ if (dotSplit.length === 2) {
+ var field = _.find(getEntity(true).fields, {name: dotSplit[0] + '.' + fieldName});
+ if (field) {
+ return field;
+ }
+ }
if (joinEntity) {
entityName = _.find(CRM.vars.search.links[entityName], {alias: joinEntity}).entity;
}
}
result.field = getField(fieldName);
var split = fieldName.split(':'),
- dotPos = split[0].indexOf('.');
+ prefixPos = split[0].indexOf(result.field.name);
result.path = split[0];
- result.prefix = result.path.substring(0, dotPos + 1);
+ result.prefix = prefixPos > 0 ? result.path.substring(0, prefixPos) : '';
result.suffix = !split[1] ? '' : ':' + split[1];
return result;
}
}
this.$onInit = function() {
- loadFieldOptions();
-
$scope.$bindToRoute({
expr: '$ctrl.params.select',
param: 'select',
});
}
$scope.$watch('$ctrl.params.having', onChangeFilters, true);
+
+ loadFieldOptions();
};
$scope.saveGroup = function() {