Commit a5a22d25 authored by Matija Obreza's avatar Matija Obreza
Browse files

Use Clipboard when importing Descriptors and Accession identifiers

parent ac9e4e0c
......@@ -55,8 +55,18 @@ class DescriptorUpload extends React.Component<IDescriptorUpload, any> {
return terms;
}
public parseCsvDescriptor = (e) => {
const csvText: string = e.target.value;
public dataPasted = (e) => {
e.preventDefault();
console.log('Pasted', e.clipboardData);
// console.log(e.clipboardData.getData('text/plain'));
this.parseCsv(e.clipboardData.getData('text/plain'));
}
public textBlurred = (e) => {
this.parseCsv(e.target.value);
}
private parseCsv(csvText: string) {
// log('CSV text', csvText);
const config: ICsvConfiguration = CSV.detectConfiguration(csvText);
......@@ -115,7 +125,7 @@ class DescriptorUpload extends React.Component<IDescriptorUpload, any> {
<Paper className={ `${this.props.className} p-20 mb-20` }>
<FormControl fullWidth>
<InputLabel>Descriptor definitions</InputLabel>
<Input multiline placeholder="Paste descriptor data here (tab separated)" onBlur={ this.parseCsvDescriptor }/>
<Input onPaste={ this.dataPasted } placeholder="Paste descriptor data here (tab separated)" onBlur={ this.textBlurred }/>
</FormControl>
</Paper>
......
......@@ -41,10 +41,19 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
super(props);
}
protected saveCsvText = (e) => {
// parse it
const csvText: string = e.target.value;
log('CSV text', csvText);
public dataPasted = (e) => {
e.preventDefault();
console.log('Pasted', e.clipboardData);
// console.log(e.clipboardData.getData('text/plain'));
this.parseCsv(e.clipboardData.getData('text/plain'));
}
public textBlurred = (e) => {
this.parseCsv(e.target.value);
}
private parseCsv(csvText: string) {
// log('CSV text', csvText);
const config: ICsvConfiguration = CSV.detectConfiguration(csvText);
......@@ -63,10 +72,6 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
});
}
protected saveFile(e) {
log(e.target.files.item(0));
}
public render() {
const {classes, accessionIdentifiers} = this.props;
......@@ -87,7 +92,7 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
<form>
<FormControl fullWidth>
<InputLabel>List of accessions described in the dataset</InputLabel>
<Input multiline placeholder="Paste accessions data here (comma separated)" onBlur={ this.saveCsvText }/>
<Input multiline placeholder="Paste accessions data here (comma separated)" onPaste={ this.dataPasted } onBlur={ this.textBlurred }/>
</FormControl>
</form>
......
......@@ -22,7 +22,7 @@ import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import Grid from 'material-ui/Grid';
import Paper from 'material-ui/Paper';
import Button from 'material-ui/Button';
import DescriptorUpload from './c/DescriptorUpload';
import DescriptorUpload from 'ui/catalog/descriptor/DescriptorUpload';
interface IDescriptorListEditPageProps extends React.ClassAttributes<any> {
classes: any;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment