-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tip label is used for on-hover+click info
This generally better reflects the intention of changing the tip label key, which was previously only reflected in text drawn to the RHS of tree nodes at certain zoom levels. The motivating use case is the proliferation of datasets using an accession for `node.name` but who wish to see node names of another piece of metadata. This is possible by adding the desired name as a node_attr and (optionally) setting this as the default tip label. Note that the order of items in the node-clicked modal has been slightly altered and is now more consistent across internal branches, terminal branches & tips
- Loading branch information
1 parent
3eb6ea8
commit 962a2e2
Showing
5 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getTraitFromNode } from "../../../util/treeMiscHelpers"; | ||
import { numericToCalendar } from "../../../util/dateHelpers"; | ||
|
||
|
||
/** | ||
* Attempt to display the best name we can for a node, depending on how we are looking at a node. | ||
* The returned string will be rendered on a line of its own, so an empty string will look ok | ||
* Future enhancement: we could examine the coloring metadata (if available) and format the value accordingly | ||
*/ | ||
export function nodeDisplayName(t, node, tipLabelKey, branch) { | ||
let tipLabel = getTraitFromNode(node, tipLabelKey) | ||
if (tipLabelKey==='num_date' && tipLabel) tipLabel = numericToCalendar(tipLabel) | ||
const terminal = !node.hasChildren; | ||
|
||
if (branch) { | ||
if (terminal) { | ||
return tipLabel ? t("Branch leading to {{tipLabel}}", {tipLabel}) : t("Terminal branch") // hover + click | ||
} | ||
return t("Internal branch") // branch click only | ||
} | ||
/* TIP */ | ||
return tipLabel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters