<i class="crm-i fa-trash"></i>
</button>
</div>
-<div class="api4-where-group-sortable" ng-model="data.where" ui-sortable="{axis: 'y', connectWith: '.api4-where-group-sortable', containment: '.api4-where-fieldset', over: onSortOver, start: onSort, stop: onSort}">
- <div class="api4-input form-inline clearfix" ng-repeat="(index, clause) in data.where">
+<div class="api4-clause-group-sortable" ng-model="data.clauses" ui-sortable="{axis: 'y', connectWith: '.api4-clause-group-sortable', containment: '.api4-clause-fieldset', over: onSortOver}" ui-sortable-start="onSort" ui-sortable-stop="onSort">
+ <div class="api4-input form-inline clearfix" ng-repeat="(index, clause) in data.clauses">
<div class="api4-clause-badge" title="{{ ts('Drag to reposition') }}">
<span class="badge badge-info">
- <span ng-if="!index && !data.groupParent">Where</span>
+ <span ng-if="!index && !data.groupParent">{{ data.type }}</span>
<span ng-if="index || data.groupParent">{{ data.op }}</span>
<i class="crm-i fa-arrows"></i>
</span>
<select class="form-control api4-operator" ng-model="clause[1]" ng-options="o for o in operators" ></select>
<input class="form-control" ng-model="clause[2]" api4-exp-value="{field: clause[0], op: clause[1]}" />
</div>
- <fieldset class="clearfix" ng-if="clause[0] === 'AND' || clause[0] === 'OR' || clause[0] === 'NOT'" crm-api4-where-clause="{where: clause[1], op: clause[0], fields: data.fields, operators: data.operators, groupParent: data.where, groupIndex: index}">
+ <fieldset class="clearfix" ng-if="clause[0] === 'AND' || clause[0] === 'OR' || clause[0] === 'NOT'" crm-api4-clause="{type: data.type, clauses: clause[1], op: clause[0], fields: data.fields, groupParent: data.clauses, groupIndex: index}">
</fieldset>
</div>
</div>
<textarea class="form-control" type="{{ param.type[0] === 'int' && param.type.length === 1 ? 'number' : 'text' }}" id="api4-param-{{ name }}" ng-model="params[name]">
</textarea>
</div>
- <fieldset ng-if="availableParams.where" class="api4-where-fieldset" ng-mouseenter="help('where', availableParams.where)" ng-mouseleave="help()" crm-api4-where-clause="{where: params.where, required: availableParams.where.required, op: 'AND', label: 'where', fields: fieldsAndJoins}">
+ <fieldset ng-if="availableParams.where" class="api4-clause-fieldset" ng-mouseenter="help('where', availableParams.where)" ng-mouseleave="help()" crm-api4-clause="{type: 'where', clauses: params.where, required: availableParams.where.required, op: 'AND', label: 'where', fields: fieldsAndJoins}">
</fieldset>
<fieldset ng-repeat="name in ['values', 'defaults']" ng-if="availableParams[name]" ng-mouseenter="help(name, availableParams[name])" ng-mouseleave="help()">
<legend>{{ name }}<span class="crm-marker" ng-if="availableParams[name].required"> *</span></legend>
};
});
- angular.module('api4Explorer').directive('crmApi4WhereClause', function($timeout) {
+ angular.module('api4Explorer').directive('crmApi4Clause', function($timeout) {
return {
scope: {
- data: '=crmApi4WhereClause'
+ data: '=crmApi4Clause'
},
- templateUrl: '~/api4Explorer/WhereClause.html',
+ templateUrl: '~/api4Explorer/Clause.html',
link: function (scope, element, attrs) {
var ts = scope.ts = CRM.ts();
scope.newClause = '';
scope.operators = CRM.vars.api4.operators;
scope.addGroup = function(op) {
- scope.data.where.push([op, []]);
+ scope.data.clauses.push([op, []]);
};
scope.removeGroup = function() {
};
scope.onSort = function(event, ui) {
- $('.api4-where-fieldset').toggleClass('api4-sorting', event.type === 'sortstart');
+ $(element).closest('.api4-clause-fieldset').toggleClass('api4-sorting', event.type === 'sortstart');
$('.api4-input.form-inline').css('margin-left', '');
};
var field = value;
$timeout(function() {
if (field) {
- scope.data.where.push([field, '=', '']);
+ scope.data.clauses.push([field, '=', '']);
scope.newClause = null;
}
});
});
- scope.$watch('data.where', function(values) {
+ scope.$watch('data.clauses', function(values) {
// Remove empty values
_.each(values, function(clause, index) {
if (typeof clause !== 'undefined' && !clause[0]) {
top: -2px;
}
-#bootstrap-theme.api4-explorer-page .api4-where-fieldset fieldset {
+#bootstrap-theme.api4-explorer-page .api4-clause-fieldset fieldset {
float: right;
width: calc(100% - 58px);
margin-top: -8px;
}
-#bootstrap-theme.api4-explorer-page .api4-where-fieldset.api4-sorting fieldset .api4-where-group-sortable {
+#bootstrap-theme.api4-explorer-page .api4-clause-fieldset.api4-sorting fieldset .api4-clause-group-sortable {
min-height: 3.5em;
}