44e3dc026187c8f73c1f93316dd9ee5cbd829c8c braney Fri Mar 9 13:48:01 2018 -0800 add times to collection names to make them more unique diff --git src/hg/js/hgCollection.js src/hg/js/hgCollection.js index a93e803..3a7ada2 100644 --- src/hg/js/hgCollection.js +++ src/hg/js/hgCollection.js @@ -188,31 +188,31 @@ $( "#customName" ).select(); $('#collectionDialogHelp').show(); $('#trackDialogHelp').hide(); $( "#newCollectionDialog" ).dialog( 'option', 'title', 'Create New Collection'); $( "#newCollectionDialog" ).dialog("open"); } function newCollection() { var newName = $("#customName").val().trim(); if (!validateLabel(newName)) return; var newDescription = $("#customDescription").val().trim(); if (!validateLabel(newDescription)) return; - var ourCollectionName = getUniqueName("coll"); + var ourCollectionName = getUniqueName(); var parent = $(selectedTree).find("li").first(); $( "#newCollectionDialog" ).dialog("close"); var newId = $(selectedTree).jstree("create_node", "#", newName + " (" + newDescription + ")"); var newId2 = $(selectedTree).jstree("create_node", newId, emptyCollectionText); var newNode = $(selectedTree).jstree("get_node", newId); isDirty = true; newNode.li_attr.class = "folder empty"; newNode.li_attr.name = ourCollectionName; newNode.li_attr.shortlabel = newName; newNode.li_attr.longlabel = newDescription; newNode.li_attr.visibility = $("#customVis").val(); newNode.li_attr.color = $("#customColorInput").val(); newNode.li_attr.missingmethod = $("input:radio[name ='missingData']:checked").val(); newNode.li_attr.viewfunc = $("#viewFunc").val(); @@ -507,32 +507,34 @@ function updatePage(responseJson) { // called after AJAX call isDirty = false; if (!responseJson) { return; } if (goTracks) { // we go straight to hgTracks after save $form = $('#redirectForm'); $form.submit(); } } - function getUniqueName(root) { + function getUniqueName() { // make sure name is unique in track hub + var seconds = Math.floor( Date.now() / 1000 ) - 1520631071; + var root = "coll" + seconds; if (!collectionNames[root]) { collectionNames[root] = 1; return root; } else { var counter = 1; for(; ; counter++) { var name = root + counter; if (!collectionNames[name]) { collectionNames[name] = 1; return name; } } } }