Merge pull request #17879 from colemanw/relCacheApi
[civicrm-core.git] / ang / api4Explorer / Explorer.html
1 <div id="bootstrap-theme" class="api4-explorer-page">
2 <div crm-ui-debug="availableParams"></div>
3
4 <h1 crm-page-title>
5 {{:: ts('CiviCRM APIv4') }}{{ entity ? (' (' + entity + '::' + action + ')') : '' }}
6 </h1>
7
8 <!--This warning will show if bootstrap is unavailable. Normally it will be hidden by the bootstrap .collapse class.-->
9 <div class="messages warning no-popup collapse">
10 <p>
11 <i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i>
12 <strong>{{:: ts('Bootstrap theme not found.') }}</strong>
13 </p>
14 <p>{{:: ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') }}</p>
15 </div>
16
17 <div class="api4-explorer-row">
18 <form name="api4-explorer" class="panel panel-default explorer-params-panel">
19 <div class="panel-heading">
20 <div class="form-inline">
21 <span ng-mouseenter="help('entity', paramDoc('$entity'))" ng-mouseleave="help()">
22 <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}" />
23 </span>
24 <span ng-mouseenter="help('action', paramDoc('$action'))" ng-mouseleave="help()">
25 <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}" />
26 </span>
27 <input class="form-control api4-index" type="search" ng-model="index" ng-mouseenter="help('index', paramDoc('$index'))" ng-mouseleave="help()" placeholder="{{:: ts('Index') }}" />
28 <button class="btn btn-success pull-right" crm-icon="fa-bolt" ng-disabled="!entity || !action || loading" ng-click="execute()" ng-mouseenter="help(ts('Execute'), executeDoc())" ng-mouseleave="help()">{{:: ts('Execute') }}</button>
29 <button class="btn btn-primary pull-right" crm-icon="fa-save" ng-show="perm.editGroups && action === 'get'" ng-click="save()" ng-mouseenter="help(ts('Save smart group'), saveDoc())" ng-mouseleave="help()">{{:: ts('Save...') }}</button>
30 </div>
31 </div>
32 <div class="panel-body">
33 <div class="api4-input form-inline">
34 <label class="form-control" ng-mouseenter="help(name, param)" ng-mouseleave="help()" ng-class="{'api4-option-selected': params[name]}" ng-repeat="(name, param) in ::getGenericParams(['bool'], false)">
35 <input type="checkbox" id="api4-param-{{:: name }}" ng-model="params[name]"/>
36 {{:: name }}<span class="crm-marker" ng-if="::param.required"> *</span>
37 </label>
38 <label class="form-control" ng-mouseenter="help('selectRowCount', availableParams.select)" ng-mouseleave="help()" ng-class="{'api4-option-selected': isSelectRowCount()}" ng-if="::availableParams.select">
39 <input type="checkbox" id="api4-param-selectRowCount" ng-checked="isSelectRowCount()" ng-click="selectRowCount()" />
40 SelectRowCount
41 </label>
42 </div>
43 <div class="api4-input form-inline" ng-mouseenter="help(name, param)" ng-mouseleave="help()" ng-repeat="(name, param) in ::getGenericParams(['bool'], true)">
44 <label>{{ name }}<span class="crm-marker" ng-if="::param.required"> *</span></label>
45 <label class="radio-inline">
46 <input type="radio" ng-model="params[name]" ng-value="true" />true
47 </label>
48 <label class="radio-inline">
49 <input type="radio" ng-model="params[name]" ng-value="false" />false
50 </label>
51 <a href class="crm-hover-button" title="Clear" ng-click="clearParam(name)" ng-show="params[name] !== null"><i class="crm-i fa-times" aria-hidden="true"></i></a>
52 </div>
53 <fieldset class="api4-input form-inline" ng-mouseenter="help('select', availableParams.select)" ng-mouseleave="help()" ng-if="availableParams.select">
54 <legend>select<span class="crm-marker" ng-if="::availableParams.select.required"> *</span></legend>
55 <div ng-model="params.select" ui-sortable="{axis: 'y'}">
56 <div class="api4-input form-inline" ng-repeat="item in params.select track by $index" ng-show="item !== 'row_count'">
57 <i class="crm-i fa-arrows" aria-hidden="true"></i>
58 <input class="form-control huge" type="text" ng-model="params.select[$index]" />
59 <a href class="crm-hover-button" title="Clear" ng-click="clearParam('select', $index)"><i class="crm-i fa-times" aria-hidden="true"></i></a>
60 </div>
61 </div>
62 <div class="api4-input form-inline">
63 <input class="collapsible-optgroups form-control huge" ng-model="controls.select" crm-ui-select="{data: fieldsAndJoinsAndFunctionsAndWildcards}" placeholder="Add select" />
64 </div>
65 </fieldset>
66 <fieldset id="api4-join-fieldset" class="api4-input form-inline" ng-mouseenter="help('join', availableParams.join)" ng-mouseleave="help()" ng-if="::availableParams.join">
67 <legend>join<span class="crm-marker" ng-if="::availableParams.join.required"> *</span></legend>
68 <div ng-model="params.join" ui-sortable="{axis: 'y', containment: '#api4-join-fieldset'}">
69 <fieldset ng-repeat="item in params.join track by $index">
70 <div class="api4-input form-inline">
71 <i class="crm-i fa-arrows"></i>
72 <input class="form-control twenty" type="text" ng-model="params.join[$index][0]" ng-model-options="{updateOn: 'blur'}" ng-change="$ctrl.buildFieldList()"/>
73 <label>{{:: ts('Required:') }}</label>
74 <select class="form-control" ng-model="params.join[$index][1]" ng-options="o.k as o.v for o in ::joinTypes" ></select>
75 <label>{{:: ts('Using:') }}</label>
76 <select class="form-control" ng-model="params.join[$index][2]" ng-options="e.name as e.name for e in ::bridgeEntities" ng-change="$ctrl.buildFieldList()">
77 <option value="">{{:: ts('- none -') }}</option>
78 </select>
79 <a href class="crm-hover-button" title="Clear" ng-click="clearParam('join', $index)"><i class="crm-i fa-times"></i></a>
80 </div>
81 <fieldset class="api4-clause-fieldset" crm-api4-clause="{skip: 3, clauses: params.join[$index], op: 'AND', label: 'On', fields: fieldsAndJoins, format: 'plain'}">
82 </fieldset>
83 </fieldset>
84 </div>
85 <div class="api4-input form-inline">
86 <input class="collapsible-optgroups form-control huge" ng-model="controls.join" crm-ui-select="{data: entities}" placeholder="Add join" />
87 </div>
88 </fieldset>
89 <div class="api4-input form-inline" ng-mouseenter="help('fields', availableParams.fields)" ng-mouseleave="help()" ng-if="::availableParams.fields">
90 <label for="api4-param-fields">fields<span class="crm-marker" ng-if="::availableParams.fields.required"> *</span></label>
91 <input class="form-control" ng-list crm-ui-select="::{data: fields, multiple: true}" id="api4-param-fields" ng-model="params.fields" style="width: 85%;"/>
92 </div>
93 <div class="api4-input form-inline" ng-mouseenter="help('action', availableParams.action)" ng-mouseleave="help()"ng-if="::availableParams.action">
94 <label for="api4-param-action">action<span class="crm-marker" ng-if="::availableParams.action.required"> *</span></label>
95 <input class="form-control" crm-ui-select="{data: actions, allowClear: true, placeholder: 'None'}" id="api4-param-action" ng-model="params.action"/>
96 </div>
97 <div class="api4-input form-inline" ng-mouseenter="help(name, param)" ng-mouseleave="help()" ng-repeat="(name, param) in ::getGenericParams(['string', 'int'])">
98 <label for="api4-param-{{:: name }}">{{:: name }}<span class="crm-marker" ng-if="::param.required"> *</span></label>
99 <input class="form-control" ng-if="::!param.options" type="{{:: param.type[0] === 'int' && param.type.length === 1 ? 'number' : 'text' }}" id="api4-param-{{:: name }}" ng-model="params[name]"/>
100 <select class="form-control" ng-if="::param.options" ng-options="o for o in ::param.options" id="api4-param-{{:: name }}" ng-model="params[name]"></select>
101 <a href class="crm-hover-button" title="Clear" ng-click="clearParam(name)" ng-show="!!params[name]"><i class="crm-i fa-times" aria-hidden="true"></i></a>
102 </div>
103 <div class="api4-input" ng-mouseenter="help(name, param)" ng-mouseleave="help()" ng-repeat="(name, param) in ::getGenericParams(['array', 'mixed'])">
104 <label for="api4-param-{{:: name }}">{{:: name }}<span class="crm-marker" ng-if="::param.required"> *</span></label>
105 <textarea class="form-control" type="{{:: param.type[0] === 'int' && param.type.length === 1 ? 'number' : 'text' }}" id="api4-param-{{:: name }}" ng-model="params[name]">
106 </textarea>
107 </div>
108 <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}">
109 </fieldset>
110 <fieldset ng-repeat="name in ['values', 'defaults']" ng-if="::availableParams[name]" ng-mouseenter="help(name, availableParams[name])" ng-mouseleave="help()">
111 <legend>{{:: name }}<span class="crm-marker" ng-if="::availableParams[name].required"> *</span></legend>
112 <div class="api4-input form-inline" ng-repeat="clause in params[name]" ng-mouseenter="help('value: ' + clause[0], fieldHelp(clause[0]))" ng-mouseleave="help(name, availableParams[name])">
113 <input class="collapsible-optgroups form-control twenty" ng-model="clause[0]" crm-ui-select="{formatResult: formatSelect2Item, formatSelection: formatSelect2Item, data: fieldList(name), allowClear: true, placeholder: 'Field'}" />
114 <input class="form-control" ng-model="clause[1]" api4-exp-value="{field: clause[0], action: action === 'getFields' ? params.action || 'get' : action}" />
115 </div>
116 <div class="api4-input form-inline">
117 <input class="collapsible-optgroups form-control twenty" ng-model="controls[name]" crm-ui-select="{formatResult: formatSelect2Item, formatSelection: formatSelect2Item, data: fieldList(name), placeholder: ts('Add %1', {1: name.slice(0, -1)})}"/>
118 </div>
119 </fieldset>
120 <fieldset ng-if="::availableParams.groupBy" ng-mouseenter="help('groupBy', availableParams.groupBy)" ng-mouseleave="help()">
121 <legend>groupBy<span class="crm-marker" ng-if="::availableParams.groupBy.required"> *</span></legend>
122 <div ng-model="params.groupBy" ui-sortable="{axis: 'y'}">
123 <div class="api4-input form-inline" ng-repeat="item in params.groupBy track by $index">
124 <i class="crm-i fa-arrows" aria-hidden="true"></i>
125 <input class="form-control huge" type="text" ng-model="params.groupBy[$index]" />
126 <a href class="crm-hover-button" title="Clear" ng-click="clearParam('groupBy', $index)"><i class="crm-i fa-times" aria-hidden="true"></i></a>
127 </div>
128 </div>
129 <div class="api4-input form-inline">
130 <input class="collapsible-optgroups form-control huge" ng-model="controls.groupBy" crm-ui-select="{data: fieldsAndJoinsAndFunctions}" placeholder="Add groupBy" />
131 </div>
132 </fieldset>
133 <fieldset ng-if="::availableParams.having" class="api4-clause-fieldset" ng-mouseenter="help('having', availableParams.having)" ng-mouseleave="help()" crm-api4-clause="{clauses: params.having, required: availableParams.having.required, op: 'AND', label: 'Having', fields: havingOptions}">
134 </fieldset>
135 <fieldset ng-if="::availableParams.orderBy" ng-mouseenter="help('orderBy', availableParams.orderBy)" ng-mouseleave="help()">
136 <legend>orderBy<span class="crm-marker" ng-if="::availableParams.orderBy.required"> *</span></legend>
137 <div ng-model="params.orderBy" ui-sortable="{axis: 'y'}">
138 <div class="api4-input form-inline" ng-repeat="clause in params.orderBy">
139 <i class="crm-i fa-arrows" aria-hidden="true"></i>
140 <input class="form-control huge" type="text" ng-model="clause[0]" />
141 <select class="form-control" ng-model="clause[1]">
142 <option value="ASC">ASC</option>
143 <option value="DESC">DESC</option>
144 </select>
145 <a href class="crm-hover-button" title="Clear" ng-click="clearParam('orderBy', $index)"><i class="crm-i fa-times" aria-hidden="true"></i></a>
146 </div>
147 </div>
148 <div class="api4-input form-inline">
149 <input class="collapsible-optgroups form-control huge" ng-model="controls.orderBy" crm-ui-select="{data: fieldsAndJoinsAndFunctionsWithSuffixes}" placeholder="Add orderBy" />
150 </div>
151 </fieldset>
152 <fieldset ng-if="::availableParams.limit && availableParams.offset">
153 <div class="api4-input form-inline">
154 <span ng-mouseenter="help('limit', availableParams.limit)" ng-mouseleave="help()">
155 <label for="api4-param-limit">limit<span class="crm-marker" ng-if="::availableParams.limit.required"> *</span></label>
156 <input class="form-control" type="number" min="0" id="api4-param-limit" ng-model="params.limit"/>
157 </span>
158 <span ng-mouseenter="help('offset', availableParams.offset)" ng-mouseleave="help()">
159 <label for="api4-param-offset">offset<span class="crm-marker" ng-if="::availableParams.offset.required"> *</span></label>
160 <input class="form-control" type="number" min="0" id="api4-param-offset" ng-model="params.offset"/>
161 </span>
162 <a href class="crm-hover-button" title="Clear" ng-click="clearParam('limit');clearParam('offset');" ng-show="!!params.limit || !!params.offset"><i class="crm-i fa-times" aria-hidden="true"></i></a>
163 </div>
164 </fieldset>
165 <fieldset ng-if="::availableParams.chain" ng-mouseenter="help('chain', availableParams.chain)" ng-mouseleave="help()">
166 <legend>chain</legend>
167 <div class="api4-input form-inline" ng-repeat="clause in params.chain" api4-exp-chain="clause" entities="::entities" main-entity="::entity" >
168 </div>
169 <div class="api4-input form-inline">
170 <input class="form-control" ng-model="controls.chain" crm-ui-select="::{data: entities}" placeholder="Add chain" />
171 </div>
172 </fieldset>
173 </div>
174 </form>
175 <div class="panel panel-info explorer-help-panel">
176 <div class="panel-heading">
177 <h3 class="panel-title" crm-icon="fa-info-circle">{{ helpTitle }}</h3>
178 </div>
179 <div class="panel-body">
180 <h4 ng-bind-html="helpContent.description"></h4>
181 <div ng-bind-html="helpContent.comment"></div>
182 <p ng-repeat="(key, item) in helpContent" ng-if="key !== 'description' && key !== 'comment' && key !== 'see'">
183 <strong>{{ key }}:</strong> {{ item }}
184 </p>
185 <div ng-if="helpContent.see">
186 <strong>See:</strong>
187 <ul>
188 <li ng-repeat="ref in helpContent.see" ng-bind-html="ref"> </li>
189 </ul>
190 </div>
191 </div>
192 </div>
193 </div>
194 <div class="api4-explorer-row">
195 <div class="panel panel-info explorer-code-panel">
196 <ul class="panel-heading nav nav-tabs">
197 <li role="presentation" ng-repeat="lang in ::langs" ng-class="{active: selectedTab.code === lang}">
198 <a href ng-click="selectLang(lang)">
199 {{:: lang }}
200 </a>
201 </li>
202 </ul>
203 <div class="panel-body">
204 <table>
205 <tr ng-repeat="style in code[selectedTab.code]">
206 <td>{{:: style.label }}</td>
207 <td><pre class="prettyprint" ng-bind-html="style.code"></pre></td>
208 </tr>
209 </table>
210 </div>
211 </div>
212 <div class="panel explorer-result-panel panel-{{ status }}" >
213 <ul class="panel-heading nav nav-tabs">
214 <li role="presentation" ng-class="{active: selectedTab.result === 'result'}">
215 <a href ng-click="selectedTab.result = 'result'">
216 <span ng-switch="status">
217 <i class="fa fa-fw fa-circle-o" ng-switch-when="default"></i>
218 <i class="fa fa-fw fa-check-circle" ng-switch-when="success"></i>
219 <i class="fa fa-fw fa-check-circle" ng-switch-when="warning"></i>
220 <i class="fa fa-fw fa-minus-circle" ng-switch-when="danger"></i>
221 <i class="fa fa-fw fa-spinner fa-pulse" ng-switch-when="info"></i>
222 </span>
223 <span>{{:: ts('Result') }}</span>
224 </a>
225 </li>
226 <li role="presentation" ng-if="::perm.accessDebugOutput" ng-class="{active: selectedTab.result === 'debug'}">
227 <a href ng-click="selectedTab.result = 'debug'">
228 <i class="fa fa-fw fa-{{ debug ? (status === 'warning' || status === 'danger' ? 'warning' : 'bug') : 'circle-o' }}"></i>
229 <span>{{:: ts('Debug') }}</span>
230 </a>
231 </li>
232 </ul>
233 <div class="panel-body">
234 <div ng-show="selectedTab.result === 'result'">
235 <pre class="prettyprint" ng-repeat="code in result" ng-bind-html="code"></pre>
236 </div>
237 <div ng-if="::perm.accessDebugOutput" ng-show="selectedTab.result === 'debug'">
238 <pre ng-if="debug" class="prettyprint" ng-bind-html="debug"></pre>
239 <div ng-if="!debug">
240 <p>
241 {{:: ts('To view debugging output, enable the debug param before executing.') }}
242 </p>
243 <p>
244 {{:: ts('Enable backtrace in system settings to see error backtraces.') }}
245 </p>
246 </div>
247 </div>
248 </div>
249 </div>
250 </div>
251 </div>