a375b8f8c4c56f9932180441032b45a2316c856b chmalee Fri May 1 14:30:01 2026 -0700 Oops forgot to omit the create item button from the highlight menu when the hg.conf variable is off diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 7a1393b7525..c77dfa87a06 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -2060,39 +2060,36 @@ var e = Math.min(end, w.virtEnd); var cs = s - w.virtStart + w.winStart; var ce = e - w.virtStart + w.winStart; str2 += "<li>" + w.chromName + ":" + (cs+1) + "-" + ce + "</li>\n"; selectedRegions += 1; } } str2 += "</ul>\n"; if (!(hgTracks.virtualSingleChrom && (selectedRegions === 1))) { str += str2; } $("#dragSelectPosition").html(str); } else { $("#dragSelectPosition").html(newPosition); } - $(dragSelectDialog).dialog({ - modal: true, - title: "Drag-and-select", - closeOnEscape: true, - resizable: false, - autoOpen: false, - revertToOriginalPos: true, - minWidth: 650, - buttons: { + // Build the button set in two passes so that "Create Item" only + // appears when myVariants is enabled in hg.conf. doMyVariants is + // emitted by the server only inside the gated hg.conf block, so on + // a server with the feature off the variable is undefined and the + // button is omitted entirely. + let dragSelectButtons = { "Zoom In": function() { // Zoom to selection $(this).dialog("option", "revertToOriginalPos", false); if ($("#disableDragHighlight").prop('checked')) hgTracks.enableHighlightingDialog = false; if (imageV2.inPlaceUpdate) { if (hgTracks.virtualSingleChrom && (newPosition.search("multi:")===0)) { newPosition = genomePos.disguisePosition(newPosition); // DISGUISE } var params = "db=" + getDb() + "&position=" + newPosition; if (!hgTracks.enableHighlightingDialog) params += "&enableHighlightingDialog=0"; imageV2.navigateInPlace(params, null, true); } else { $('body').css('cursor', 'wait'); @@ -2111,65 +2108,76 @@ dragSelect.highlightThisRegion(newPosition, false, hlColor); $(this).dialog("close"); }, "Add Highlight": function() { // Highlight selection if ($("#disableDragHighlight").prop('checked')) hgTracks.enableHighlightingDialog = false; var hlColor = $("#hlColorInput").val(); dragSelect.highlightThisRegion(newPosition, true, hlColor); $(this).dialog("close"); }, "Save Color": function() { var hlColor = $("#hlColorInput").val(); dragSelect.saveHlColor( hlColor ); $(this).dialog("close"); - }, - "Create Item": function() { + } + }; + if (typeof doMyVariants !== 'undefined' && doMyVariants) { + dragSelectButtons["Create Item"] = function() { let data = {}; let pos = parsePosition(newPosition); data.chrom = pos.chrom; data.start = data.thickStart = pos.start.toString(); data.end = data.thickEnd = pos.end.toString(); data.score = "0"; data.strand = "."; data.color = $("#hlColorInput").val(); data.name = ""; data.description = ""; data.ref = ""; data.alt = ""; data.trackName = "myVariants"; $(this).dialog("close"); let req = encodeURIComponent(`myVariants myVariants ${JSON.stringify(data)}`); jQuery('body').css('cursor', 'wait'); $.ajax({ type: "POST", url: "../cgi-bin/hgTracks", data: cart.addUpdatesToUrl(`hgt_doJsCommand=${req}&trackName=myVariants`), dataType: "html", trueSuccess: imageV2.updateImgAndMap, success: catchErrorOrDispatch, error: errorHandler, cmd: 'wholeImage', loadingId: showLoadingImage("imgTbl"), cache: false }); - }, - "Cancel": function() { - $(this).dialog("close"); + }; } - }, + dragSelectButtons.Cancel = function() { + $(this).dialog("close"); + }; + $(dragSelectDialog).dialog({ + modal: true, + title: "Drag-and-select", + closeOnEscape: true, + resizable: false, + autoOpen: false, + revertToOriginalPos: true, + minWidth: 650, + buttons: dragSelectButtons, open: function () { // Make zoom the focus/default action $(this).parents('.ui-dialog-buttonpane button:eq(0)').trigger("focus"); }, close: function() { // All exits to dialog should go through this $(imageV2.imgTbl).imgAreaSelect({hide:true}); if ($(this).dialog("option", "revertToOriginalPos")) genomePos.revertToOriginalPos(); if ($("#disableDragHighlight").prop('checked')) $(this).remove(); else $(this).hide(); $('body').css('cursor', ''); // Occasionally wait cursor got left behind