$scope.elementList = [];
$scope.elementTitles = [];
+ function getEntityType() {
+ return $scope.entity.type === 'Contact' ? $scope.entity.data.contact_type : $scope.entity.type;
+ }
+
$scope.getMeta = function() {
- var type = $scope.entity.type === 'Contact' ? $scope.entity.data.contact_type : $scope.entity.type;
- return $scope.editor ? $scope.editor.meta.entities[type] : {};
+ return $scope.editor ? $scope.editor.meta.entities[getEntityType()] : {};
};
$scope.valuesFields = function() {
function buildFieldList(search) {
$scope.fieldList.length = 0;
- _.each($scope.getMeta().fields, function(field) {
- if (!search || _.contains(field.name, search) || _.contains(field.title.toLowerCase(), search)) {
+ $scope.fieldList.push({
+ entityName: $scope.entity.name,
+ entityType: getEntityType(),
+ label: ts('%1 Fields', {1: $scope.getMeta().label}),
+ fields: filterFields($scope.getMeta().fields)
+ });
+
+ _.each($scope.editor.meta.entities, function(entity, entityName) {
+ if (check($scope.editor.scope.layout['#children'], {'af-join': entityName})) {
$scope.fieldList.push({
- "#tag": "af-field",
- name: field.name
+ entityName: $scope.entity.name + '-join-' + entityName,
+ entityType: entityName,
+ label: ts('%1 Fields', {1: entity.label}),
+ fields: filterFields(entity.fields)
});
}
});
+
+ function filterFields(fields) {
+ return _.transform(fields, function(fieldList, field) {
+ if (!search || _.contains(field.name, search) || _.contains(field.title.toLowerCase(), search)) {
+ fieldList.push({
+ "#tag": "af-field",
+ name: field.name
+ });
+ }
+ }, []);
+ }
}
function buildBlockList(search) {
</div>
</div>
</div>
- <div ng-if="fieldList.length">
- <label>{{ ts('Fields') }}</label>
- <div ui-sortable="{update: buildPaletteLists, items: '> div:not(.disabled)', connectWith: '[data-entity=' + entity.name + '] > [ui-sortable]'}" ng-model="fieldList">
- <div ng-repeat="field in fieldList" ng-class="{disabled: fieldInUse(field.name)}">
- {{ editor.getField(entity.type, field.name).title }}
+ <div ng-repeat="fieldGroup in fieldList">
+ <div ng-if="fieldGroup.fields.length">
+ <label>{{ fieldGroup.label }}</label>
+ <div ui-sortable="{update: buildPaletteLists, items: '> div:not(.disabled)', connectWith: '[data-entity=' + fieldGroup.entityName + '] > [ui-sortable]'}" ng-model="fieldGroup.fields">
+ <div ng-repeat="field in fieldGroup.fields" ng-class="{disabled: fieldInUse(field.name)}">
+ {{ editor.getField(fieldGroup.entityType, field.name).title }}
+ </div>
</div>
</div>
</div>