From 3a721dfc8a9c8619806921df3adffe03eb873d64 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 15 Mar 2015 00:57:40 -0400 Subject: [PATCH] API Explorer - fix getvalue action return field --- templates/CRM/Admin/Page/APIExplorer.js | 24 ++++++++++++++++++++---- templates/CRM/Admin/Page/APIExplorer.tpl | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) 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 @@   - + -- 2.25.1