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/inc/cartJson.h src/hg/inc/cartJson.h
index a13fd35..61f3b91 100644
--- src/hg/inc/cartJson.h
+++ src/hg/inc/cartJson.h
@@ -5,37 +5,41 @@
 
 #include "cart.h"
 #include "hash.h"
 #include "jsonWrite.h"
 
 #define CARTJSON_COMMAND "cjCmd"
 
 struct cartJson
     // Use the cart to perform commands dispatched from handlerHash; print results with jsonWrite.
     {
     struct cart *cart;
     struct hash *handlerHash;
     struct jsonWrite *jw;
     };
 
+typedef void CartJsonHandler(struct cartJson *cj, struct hash *paramHash);
+/* Implementation of some command; paramHash associates parameter names with
+ * jsonElement values.  For use with cartJsonRegisterHandler. */
+
 struct cartJson *cartJsonNew(struct cart *cart);
 /* Allocate and return a cartJson object with default handlers.
  * cart must have "db" set already. */
 
-typedef void CartJsonHandler(struct cartJson *cj, struct hash *paramHash);
-/* Implementation of some command; paramHash associates parameter names with
- * jsonElement values. */
+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. */
 
 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. */
 
 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. */
 
 void cartJsonRegisterHandler(struct cartJson *cj, char *command, CartJsonHandler *handler);
 /* Associate handler with command; when javascript sends command, handler will be executed. */
 
 void cartJsonExecute(struct cartJson *cj);