From: Coleman Watts Date: Sun, 15 Mar 2015 02:49:19 +0000 (-0400) Subject: Api explorer - render boolean fields as yes-no select X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4aed36b29b588d16bd2ee9ee0150dd3f84b54025;p=civicrm-core.git Api explorer - render boolean fields as yes-no select --- diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 6167b913d4..4f311128b3 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -243,6 +243,10 @@ } } + function isYesNo(fieldName) { + return getFieldData[fieldName] && getFieldData[fieldName].type === 16; + } + /** * Should we render a select or textfield? * @@ -251,7 +255,7 @@ * @returns boolean */ function isSelect(fieldName, operator) { - return (options[fieldName] || (getFieldData[fieldName] && getFieldData[fieldName].FKApiName)) && !_.includes(TEXT, operator); + return (isYesNo(fieldName) || options[fieldName] || (getFieldData[fieldName] && getFieldData[fieldName].FKApiName)) && !_.includes(TEXT, operator); } /** @@ -262,6 +266,9 @@ * @returns boolean */ function isMultiSelect(fieldName, operator) { + if (isYesNo(fieldName)) { + return false; + } if (_.includes(MULTI, operator)) { return true; } @@ -309,8 +316,14 @@ else if (!multiSelect && _.includes(currentVal, ',')) { $valField.val(currentVal.split(',')[0]); } + // Yes-No options + if (isYesNo(name)) { + $valField.select2({ + data: [{id: 1, text: ts('Yes')}, {id: 0, text: ts('No')}] + }); + } // Select options - if (options[name]) { + else if (options[name]) { $valField.select2({ multiple: multiSelect, data: _.map(options[name], function (value, key) {