From 65b8c1db20430852a30886b0fca9ff861569f521 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 7 Mar 2015 13:27:47 -0500 Subject: [PATCH] API Explorer - Disable operator selection when not appropriate --- templates/CRM/Admin/Page/APIExplorer.js | 5 ++++- templates/CRM/Admin/Page/APIExplorer.tpl | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 72d8999d86..6167b913d4 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -20,6 +20,9 @@ // These types of entityRef don't require any input to open OPEN_IMMEDIATELY = ['RelationshipType', 'Event', 'Group', 'Tag'], + // Actions that don't support fancy operators + NO_OPERATORS = ['create', 'update', 'delete', 'setvalue', 'getoptions', 'getactions', 'getfields'], + // Operators with special properties BOOL = ['IS NULL', 'IS NOT NULL'], TEXT = ['LIKE', 'NOT LIKE'], @@ -46,7 +49,7 @@ * @param name */ function addField(name) { - $('#api-params').append($(fieldTpl({name: name || ''}))); + $('#api-params').append($(fieldTpl({name: name || '', noOps: _.includes(NO_OPERATORS, action)}))); var $row = $('tr:last-child', '#api-params'); $('input.api-param-name', $row).crmSelect2({ data: fields.concat({id: '-', text: ts('Other') + '...', description: ts('Choose a field not in this list')}), diff --git a/templates/CRM/Admin/Page/APIExplorer.tpl b/templates/CRM/Admin/Page/APIExplorer.tpl index 5ff402c142..0d4936a418 100644 --- a/templates/CRM/Admin/Page/APIExplorer.tpl +++ b/templates/CRM/Admin/Page/APIExplorer.tpl @@ -257,11 +257,19 @@ - + {literal} + <% if (noOps) { %> + + <% } else { %> + {/literal} + + {literal} + <% } %> + {/literal} -- 2.25.1