106e8022559428926af59dde22e697ca3d96ddce braney Sat Jan 27 09:41:18 2018 -0800 ongoing work on hgCollection diff --git src/hg/hgCollection/hgCollection.c src/hg/hgCollection/hgCollection.c index a347254..795160a 100644 --- src/hg/hgCollection/hgCollection.c +++ src/hg/hgCollection/hgCollection.c @@ -272,31 +272,31 @@ static void addVisibleTracks(struct cart *cart, struct trackDb *trackList) // add the visible tracks table rows. { struct trackDb *tdb; struct trackDbRef *tdbRefList = NULL, *tdbRef; //checkForVisible(fullTrackList); for(tdb = trackList; tdb; tdb = tdb->next) { checkForVisible(cart, &tdbRefList, tdb); } slSort(&tdbRefList, tdbRefCompare); jsInlineF("<ul>"); -jsInlineF("<li data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop' name='%s'>%s", "visibile", "Visible Tracks"); +jsInlineF("<li data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop folder' name='%s'>%s", "visibile", "Visible Tracks"); jsInlineF("<ul>"); for(tdbRef = tdbRefList; tdbRef; tdbRef = tdbRef->next) printGroup("visible", tdbRef->tdb, FALSE, FALSE); jsInlineF("</ul>"); jsInlineF("</li>"); jsInlineF("</ul>"); } static void doTable(struct cart *cart, char *db, struct grp *groupList, struct trackDb *trackList) // output the tree table { char *hubName = hubNameFromUrl(getHubName(cart, db)); struct grp *curGroup; for(curGroup = groupList; curGroup; curGroup = curGroup->next) @@ -319,31 +319,31 @@ printGroup("collections", tdb, TRUE, TRUE); jsInlineF("</ul>"); } } } jsInlineF("</div>"); jsInlineF("\");\n"); jsInlineF("$('#tracks').append(\""); addVisibleTracks(cart, trackList); for(curGroup = groupList; curGroup; curGroup = curGroup->next) { if ((hubName != NULL) && sameString(curGroup->name, hubName)) continue; jsInlineF("<ul>"); - jsInlineF("<li data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop' name='%s'>%s", curGroup->name, curGroup->label ); + jsInlineF("<li data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop folder' name='%s'>%s", curGroup->name, curGroup->label ); struct trackDb *tdb; jsInlineF("<ul>"); for(tdb = trackList; tdb; tdb = tdb->next) { if ( sameString(tdb->grp, curGroup->name)) { printGroup(curGroup->name, tdb, FALSE, FALSE); } } jsInlineF("</ul>"); jsInlineF("</li>"); jsInlineF("</ul>"); } jsInlineF("\");\n"); @@ -631,66 +631,69 @@ struct jsonParseData *jpd = (struct jsonParseData *)context; struct track **collectionList = jpd->collectionList; struct hash *trackHash = jpd->trackHash; struct track *track; if ((name == NULL) && (ele->type == jsonObject)) { struct hash *objHash = jsonObjectVal(ele, "name"); struct jsonElement *parentEle = hashFindVal(objHash, "id"); char *parentId = jsonStringEscape(parentEle->val.jeString); parentEle = hashFindVal(objHash, "parent"); char *parentName = jsonStringEscape(parentEle->val.jeString); AllocVar(track); - if (sameString(parentName, "#")) - slAddHead(collectionList, track); - else - { - struct track *parent = hashMustFindVal(trackHash, parentName); - slAddTail(&parent->trackList, track); - } - struct jsonElement *attEle = hashFindVal(objHash, "li_attr"); if (attEle) { struct hash *attrHash = jsonObjectVal(attEle, "name"); - struct jsonElement *strEle = (struct jsonElement *)hashMustFindVal(attrHash, "name"); + struct jsonElement *strEle = (struct jsonElement *)hashFindVal(attrHash, "name"); + if (strEle == NULL) + return; track->name = jsonStringEscape(strEle->val.jeString); hashAdd(trackHash, parentId, track); strEle = (struct jsonElement *)hashMustFindVal(attrHash, "shortlabel"); track->shortLabel = jsonStringEscape(strEle->val.jeString); strEle = (struct jsonElement *)hashMustFindVal(attrHash, "longlabel"); track->longLabel = jsonStringEscape(strEle->val.jeString); track->visibility = "pack"; strEle = (struct jsonElement *)hashMustFindVal(attrHash, "color"); track->color = hexStringToLong(jsonStringEscape(strEle->val.jeString)); /* strEle = (struct jsonElement *)hashMustFindVal(attrHash, "visibility"); track->visibility = jsonStringEscape(strEle->val.jeString); strEle = (struct jsonElement *)hashMustFindVal(attrHash, "color"); track->color = hexStringToLong(jsonStringEscape(strEle->val.jeString)); strEle = (struct jsonElement *)hashFindVal(attrHash, "viewfunc"); if (strEle) track->viewFunc = jsonStringEscape(strEle->val.jeString); strEle = (struct jsonElement *)hashFindVal(attrHash, "missingmethod"); if (strEle) track->missingMethod = jsonStringEscape(strEle->val.jeString); */ } + + if (sameString(parentName, "#")) + slAddHead(collectionList, track); + else + { + struct track *parent = hashMustFindVal(trackHash, parentName); + slAddTail(&parent->trackList, track); + } + } } static struct track *parseJsonElements( struct jsonElement *collectionElements) // parse the JSON returned from the ap { struct track *collectionList = NULL; struct hash *trackHash = hashNew(5); struct jsonParseData jpd = {&collectionList, trackHash}; jsonElementRecurse(collectionElements, NULL, FALSE, jsonObjStart, NULL, &jpd); slReverse(&collectionList); return collectionList; }