cf924d2aa402c655a84131bbcb689bfc3d5307aa
angie
  Fri Nov 20 16:21:13 2015 -0800
Data Integrator UI for adding related SQL tables and fields for SQL-based
tracks using all.joiner.  This is only the UI -- the implementation will be
in a subsequent commit.  Main changes:
- cartJson interface between hgIntegrator.c and hgIntegratorModel.js:
- new command getRelatedTables
- the getFields command used to expect a simple comma-sep list of tracks.
Now it expects a list of ';'-sep track blobs, each of which may include
multiple comma-sep tables (track plus related tables).
- UI state interface between hgIntegrator.jsx and hgIntegratorModel.js:
- fieldSelect now supports multiple tables per track
- js/react/hgIntegrator/hgIntegrator.jsx: new subsections of 'Choose fields...'
dialog (FieldSelect) for adding related tables and showing their available
fields w/checkboxes; corresponding new UI state and events.
- js/model/hgIntegrator/hgIntegratorModel.js:
- new handlers for UI events and cartJson data for related tables/fields
- hgIntegrator.c: new code to return information about what tables (if any)
are related to each selected track, and what fields are in selected related
tables.

Other changes:
- hgIntegratorModel.js:
- split monolithic handleCartVar into separate handlers
- add new 'hgi_uiChoices' cart var to remember things that may not pertain
to the current query, such as a user's related tables/fields selections
for a table that is not included in the current query.
- convert between hgi_querySpec and internal UI state representation
(querySpecUpdateUiChoices, toQuerySpecJS)
- cart.js: added uiChoices convenience functions, stringifying of cartSet val
- cartJson interface between hgIntegrator.c and hgIntegratorModel.js:
- new command getQueryState: bundle querySpec and uiChoices from the cart
since they need to be processed together
- UI state interface between hgIntegrator.jsx and hgIntegratorModel.js:
- split UI state's querySpec object into separate dataSources and
outFileOptions objects (no point in bundling those in the UI)

Thanks to Kate and Matt for helpful suggestions about the UI.

refs #15544

diff --git src/hg/lib/cartJson.c src/hg/lib/cartJson.c
index cee8715..7c9bf04 100644
--- src/hg/lib/cartJson.c
+++ src/hg/lib/cartJson.c
@@ -16,30 +16,40 @@
 #include "suggest.h"
 #include "trackDb.h"
 #include "trackHub.h"
 #include "web.h"
 
 char *cartJsonOptionalParam(struct hash *paramHash, char *name)
 /* Convenience function for a CartJsonHandler function: Look up name in paramHash.
  * Return the string contained in its jsonElement value, or NULL if not found. */
 {
 struct jsonElement *jel = hashFindVal(paramHash, name);
 if (jel)
     return jsonStringVal(jel, name);
 return NULL;
 }
 
+char *cartJsonParamDefault(struct hash *paramHash, char *name, char *defaultVal)
+/* Convenience function for a CartJsonHandler function: Look up name in paramHash.
+ * Return the string contained in its jsonElement value, or defaultVal if not found. */
+{
+struct jsonElement *jel = hashFindVal(paramHash, name);
+if (jel)
+    return jsonStringVal(jel, name);
+return defaultVal;
+}
+
 char *cartJsonRequiredParam(struct hash *paramHash, char *name, struct jsonWrite *jw, char *context)
 /* Convenience function for a CartJsonHandler function: Look up name in paramHash.
  * If found, return the string contained in its jsonElement value.
  * If not, write an error message (using context) and return NULL. */
 {
 char *param = cartJsonOptionalParam(paramHash, name);
 if (param == NULL)
     jsonWriteStringf(jw, "error",
 		     "%s: required param %s is missing", context, name);
 return param;
 }
 
 static char *stripAnchor(char *textIn)
 /* If textIn contains an HTML anchor tag, strip it out (and its end tag). */
 {