From: Coleman Watts Date: Sun, 15 Mar 2015 04:57:40 +0000 (-0400) Subject: API Explorer - fix getvalue action return field X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3a721dfc8a9c8619806921df3adffe03eb873d64;p=civicrm-core.git API Explorer - fix getvalue action return field --- diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 8c7a666a31..eaec241ac8 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -158,18 +158,34 @@ CRM.alert(data.deprecated, entity + ' Deprecated'); } showFields(required); - if (action === 'get' || action === 'getsingle' || action === 'getstat') { - showReturn(action === 'getstat' ? ts('Group by') : ts('Fields to return')); + if (action === 'get' || action === 'getsingle' || action == 'getvalue' || action === 'getstat') { + showReturn(); } }); } /** * For "get" actions show the "return" options + * + * TODO: Too many hard-coded actions here. Need a way to fetch this from metadata */ - function showReturn(title) { + function showReturn() { + var title = ts('Fields to return'), + params = { + data: fields, + multiple: true, + placeholder: ts('Leave blank for default') + }; + if (action == 'getstat') { + title = ts('Group by'); + } + if (action == 'getvalue') { + title = ts('Return Value'); + params.placeholder = ts('Select field'); + params.multiple = false; + } $('#api-params').prepend($(returnTpl({title: title}))); - $('#api-return-value').crmSelect2({data: fields, multiple: true}); + $('#api-return-value').crmSelect2(params); } /** diff --git a/templates/CRM/Admin/Page/APIExplorer.tpl b/templates/CRM/Admin/Page/APIExplorer.tpl index 0d4936a418..a891ac5d4d 100644 --- a/templates/CRM/Admin/Page/APIExplorer.tpl +++ b/templates/CRM/Admin/Page/APIExplorer.tpl @@ -283,7 +283,7 @@   - +