From f78ce9c36940b557476dc24f6d31f804417b3be5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 20 Apr 2014 10:23:25 -0700 Subject: [PATCH] Api Explorer - cleanup & fixes --- templates/CRM/Admin/Page/APIExplorer.js | 25 +++-- templates/CRM/Admin/Page/APIExplorer.tpl | 111 +++++++++++------------ 2 files changed, 72 insertions(+), 64 deletions(-) diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 88f890e2ab..cf04eb6f4b 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -35,7 +35,7 @@ CRM.$(function($) { function generateQuery () { var params = {}; - $('#explorer input:checkbox:checked, #explorer select, #extra input').each(function() { + $('#api-explorer input:checkbox:checked, #api-explorer select, #extra input').each(function() { var val = $(this).val(); if (val) { params[$(this).data('id')] = val; @@ -53,7 +53,7 @@ CRM.$(function($) { } } - function runQuery(query) { + function runQuery() { var vars = [], hash, smarty = '', @@ -96,7 +96,7 @@ CRM.$(function($) { } if (!entity) { - $('#query').val(ts('Choose an entity.{/ts}')); + $('#query').val(ts('Choose an entity.')); $('#entity').val(''); window.location.hash = 'explorer'; return; @@ -132,15 +132,24 @@ CRM.$(function($) { } var query = window.location.hash; - var t = "#/civicrm/ajax/rest"; - if (query.substring(0, t.length) === t) { + if (query.substring(1, restURL.length + 1) === restURL) { $('#query').val (query.substring(1)).focus(); + runQuery(); } else { window.location.hash="explorer"; //to be sure to display the result under the generated code in the viewport } - $('#entity, #action').change (function() { $("#selector, #extra").empty(); generateQuery(); runQuery(); }); - $('#explorer input:checkbox').change(function() {generateQuery(); runQuery(); }); - $('#explorer').submit(function() {runQuery(); return false;}); + $('#entity, #action').change (function() { + $("#selector, #extra").empty(); + generateQuery(); + runQuery(); + }); + $('#api-explorer input:checkbox').change(function() { + generateQuery(); runQuery(); + }); + $('#api-explorer').submit(function(e) { + e.preventDefault(); + runQuery(); + }); $('#extra').on('keyup', 'input', generateQuery); $('#extra').on('click', 'a.remove-extra', function() { $(this).parent().remove(); diff --git a/templates/CRM/Admin/Page/APIExplorer.tpl b/templates/CRM/Admin/Page/APIExplorer.tpl index ab53cf0606..846a2a8aa3 100644 --- a/templates/CRM/Admin/Page/APIExplorer.tpl +++ b/templates/CRM/Admin/Page/APIExplorer.tpl @@ -1,68 +1,66 @@ - -
- - - |  + + + +  |  - - - |  + + +  |  - - |  + +  |  - - |  + +  |  - + -
-
- - - - - - - - - +
+
+ + + + + + + + +
 You can choose an entity and an action (eg Tag Get to retrieve a list of the tags)
 Or your can directly modify the url in the field above and press enter.
@@ -72,3 +70,4 @@ click on the name of the fields you want to populate, fill the value(s) and pres
 
 The result of the ajax calls are displayed in this grey area.
 
+
-- 2.25.1