var $row = $('tr:last-child', '#api-params');
$('.api-chain-entity', $row).crmSelect2({
formatSelection: function(item) {
- return '<span class="icon ui-icon-link"></span> API ' + item.text;
+ return '<span class="icon ui-icon-link"></span> API ' +
+ ($(item.element).hasClass('strikethrough') ? '<span class="strikethrough">' + item.text + '</span>' : item.text);
},
placeholder: '<span class="icon ui-icon-link"></span> ' + ts('Entity'),
escapeMarkup: function(m) {return m}
});
}
+ /**
+ * Fetch available actions for selected chained entity
+ */
+ function getChainedAction() {
+ var
+ $selector = $(this),
+ entity = $selector.val(),
+ $row = $selector.closest('tr');
+ if (entity) {
+ $selector.prop('disabled', true);
+ CRM.api3(entity, 'getactions')
+ .done(function(actions) {
+ $selector.prop('disabled', false);
+ CRM.utils.setOptions($('.api-chain-action', $row), _.transform(actions.values, function(ret, item) {ret.push({value: item, key: item})}));
+ });
+ }
+ }
+
/**
* Fetch fields for entity+action
*/
e.preventDefault();
$(this).closest('tr').remove();
buildParams();
- });
+ })
+ .on('change', 'select.api-chain-entity', getChainedAction);
$('#api-params-add').on('click', function(e) {
e.preventDefault();
addField();
<select style="width: 100%;" class="crm-form-select api-chain-entity">
<option value=""></option>
{foreach from=$entities.values item=entity}
- <option value="{$entity}">{$entity}</option>
+ <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
+ {$entity}
+ </option>
{/foreach}
</select>
</td>
<td>
<select class="crm-form-select api-chain-action">
<option value="get">get</option>
- <option value="getsingle">getsingle</option>
- <option value="getcount">getcount</option>
- <option value="create">create</option>
- <option value="delete">delete</option>
- </select>
+ </select>
</td>
<td>
<input style="width: 85%;" class="crm-form-text api-param-value api-input" value="{ldelim}{rdelim}" placeholder="{ts}Api Params{/ts}"/>