<div class="form-inline">
<input class="collapsible-optgroups form-control" ng-model="entity" ng-disabled="!entities.length" ng-class="{loading: !entities.length}" crm-ui-select="{placeholder: ts('Entity'), data: entities}" />
<input class="collapsible-optgroups form-control" ng-model="action" ng-disabled="!entity || !actions.length" ng-class="{loading: entity && !actions.length}" crm-ui-select="{placeholder: ts('Action'), data: actions}" />
- <input class="form-control api4-index" ng-model="index" ng-mouseenter="help('index', indexHelp)" ng-mouseleave="help()" placeholder="{{ ts('Index') }}" />
+ <input class="form-control api4-index" type="search" ng-model="index" ng-mouseenter="help('index', indexHelp)" ng-mouseleave="help()" placeholder="{{ ts('Index') }}" />
<button class="btn btn-success pull-right" crm-icon="fa-bolt" ng-disabled="!entity || !action || loading" ng-click="execute()">{{ ts('Execute') }}</button>
</div>
</div>
$scope.params.select = [];
} else {
$scope.params.select = ['row_count'];
+ $scope.index = '';
if ($scope.params.limit == 25) {
$scope.params.limit = 0;
}
entity = $scope.entity,
action = $scope.action,
params = getParams(),
- index = isInt($scope.index) ? +$scope.index : $scope.index,
+ index = isInt($scope.index) ? +$scope.index : parseYaml($scope.index),
result = 'result';
if ($scope.entity && $scope.action) {
if (action.slice(0, 3) === 'get') {
}
});
code.oop += "\n ->execute()";
- if (_.isNumber(index)) {
+ if (isSelectRowCount) {
+ code.oop += "\n ->count()";
+ } else if (_.isNumber(index)) {
code.oop += !index ? '\n ->first()' : (index === -1 ? '\n ->last()' : '\n ->itemAt(' + index + ')');
} else if (index) {
- code.oop += "\n ->indexBy('" + index + "')";
- } else if (isSelectRowCount) {
- code.oop += "\n ->count()";
+ if (_.isString(index) || (_.isPlainObject(index) && !index[0] && !index['0'])) {
+ code.oop += "\n ->indexBy('" + (_.isPlainObject(index) ? _.keys(index)[0] : index) + "')";
+ }
+ if (_.isArray(index) || _.isPlainObject(index)) {
+ code.oop += "\n ->column('" + (_.isArray(index) ? index[0] : _.values(index)[0]) + "')";
+ }
}
code.oop += ";\n";
if (!_.isNumber(index) && !isSelectRowCount) {
$scope.loading = true;
$http.post(CRM.url('civicrm/ajax/api4/' + $scope.entity + '/' + $scope.action, {
params: angular.toJson(getParams()),
- index: $scope.index
+ index: isInt($scope.index) ? +$scope.index : parseYaml($scope.index)
}), null, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
#bootstrap-theme.api4-explorer-page .api4-operator,
#bootstrap-theme.api4-explorer-page .api4-chain-index,
-#bootstrap-theme.api4-explorer-page .api4-index,
#bootstrap-theme.api4-explorer-page .api4-chain-action {
width: 90px;
}
#bootstrap-theme.api4-explorer-page .api4-chain-params {
- width: calc(100% - 386px);
+ width: calc(100% - 390px);
}
#bootstrap-theme.api4-explorer-page .api4-add-where-group-menu {