Skip to content

Commit b08187f

Browse files
Added button to export sample list to clipboard
1 parent 2bd1efc commit b08187f

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/flapjack-bytes.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ export default function GenotypeRenderer() {
617617
const exportViewText = document.createTextNode('Export view');
618618
exportViewButton.style.marginRight = '10px';
619619
exportViewButton.appendChild(exportViewText);
620-
621620
exportViewButton.addEventListener('click', function(e) {
622621
const dataURL = genotypeCanvas.toDataURL('image/png');
623622
if (dataURL){ // Export succeeded
@@ -633,8 +632,8 @@ export default function GenotypeRenderer() {
633632

634633
const exportOverviewButton = document.createElement('button');
635634
const exportOverviewText = document.createTextNode('Export overview');
635+
exportOverviewButton.style.marginRight = '10px';
636636
exportOverviewButton.appendChild(exportOverviewText);
637-
638637
exportOverviewButton.addEventListener('click', function(e) {
639638
const dataURL = overviewCanvas.toDataURL('image/png');
640639
if (dataURL){ // Export succeeded
@@ -647,9 +646,26 @@ export default function GenotypeRenderer() {
647646
document.body.removeChild(element);
648647
}
649648
});
649+
650+
const exportSampleButton = document.createElement('button');
651+
const exportSampleText = document.createTextNode('Export sample list');
652+
exportSampleButton.appendChild(exportSampleText);
653+
exportSampleButton.addEventListener('click', function(e) {
654+
const names = genotypeCanvas.dataSet?.germplasmListFiltered?.map(g => g.name);
655+
if (!names || !names.length)
656+
return;
657+
658+
navigator.clipboard.writeText(names.join('\n')).then(() => {
659+
alert(names.length + ' sample names copied to clipboard!');
660+
}).catch(err => {
661+
console.error('Clipboard error:', err);
662+
alert('Clipboard write failed');
663+
});
664+
});
650665

651666
tab.appendChild(exportViewButton);
652667
tab.appendChild(exportOverviewButton);
668+
tab.appendChild(exportSampleButton);
653669

654670
return tab;
655671
}

0 commit comments

Comments
 (0)