Commit d589a348 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Dataset editor: Rescan accessionRefs for matching accessions

added clear list action button
parent 4018d974
......@@ -692,7 +692,9 @@
"excel": "Copy and paste the table from Excel into the text field \"List of accessions described in the dataset\".",
"listDescribed": "List of accessions described in the dataset",
"rowCount": "{{count, number}} accession",
"placeholder": "Paste accessions data here (comma separated)"
"placeholder": "Paste accessions data here (comma separated)",
"rematch": "Rematch accessions",
"clearList": "Clear list"
},
"pastingTraits": {
"title": "Select descriptors in batch",
......
......@@ -103,6 +103,18 @@ export { rejectDataset, approveDataset, publishDataset, deleteDataset };
// Accession identifiers step
function clearAccessionRefList(dataset: Dataset) {
return (dispatch, getState) => {
return DatasetService.upsertAccessions(dataset.uuid, dataset.version, [])
.then((saved) => {
dispatch(receiveDataset(saved));
dispatch(loadMoreAccessions(saved.uuid));
}).catch((error) => {
log('Publish error', error);
});
};
}
function updateDatasetAccessionRefs(dataset: Dataset, accessionRefs: AccessionRef[]) {
return (dispatch, getState) => {
......@@ -116,8 +128,20 @@ function updateDatasetAccessionRefs(dataset: Dataset, accessionRefs: AccessionRe
};
}
function rematchDatasetAccessions(dataset: Dataset) {
return (dispatch, getState) => {
return DatasetService.rematchDatasetAccessions(dataset.uuid, dataset.version)
.then((saved) => {
dispatch(receiveDataset(saved));
dispatch(loadMoreAccessions(saved.uuid));
}).catch((error) => {
log('Publish error', error);
});
};
}
// Accession identifiers step exports
export { updateDatasetAccessionRefs };
export { updateDatasetAccessionRefs, rematchDatasetAccessions, clearAccessionRefList };
// Descriptors step
......
......@@ -115,7 +115,9 @@
"excel": "Copy and paste the table from Excel into the text field \"List of accessions described in the dataset\".",
"listDescribed": "List of accessions described in the dataset",
"rowCount": "{{count, number}} accession",
"placeholder": "Paste accessions data here (comma separated)"
"placeholder": "Paste accessions data here (comma separated)",
"rematch": "Rematch accessions",
"clearList": "Clear list"
},
"pastingTraits": {
"title": "Select descriptors in batch",
......
......@@ -9,9 +9,12 @@ import { log } from 'utilities/debug';
import { AccessionRef } from 'model/accession/AccessionRef';
import Page from 'model/Page';
import Dataset from 'model/catalog/Dataset';
import AccessionRefsTable from 'ui/catalog/accession/AccessionRefsTable';
import { CSV, ICsvConfiguration } from 'utilities/CSV';
import CSVConfiguration, { CSVConfig } from 'ui/common/csv-configuration/CSVConfiguration';
import ActionButton from 'ui/common/buttons/ActionButton';
import ButtonBar from 'ui/common/buttons/ButtonBar';
interface IListOfAccession extends React.ClassAttributes<any> {
classes: any;
......@@ -19,6 +22,9 @@ interface IListOfAccession extends React.ClassAttributes<any> {
accessionRefs: Page<AccessionRef>;
loadAccessions: (uuid: string, page?: number, pageSize?: number) => any;
t: any;
dataset: Dataset;
rematchDatasetAccessions: (dataset: Dataset) => void;
clearAccessionRefList: (dataset: Dataset) => void;
}
const styleSheet = {
......@@ -49,6 +55,14 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
private onUpdateCsvConfig = (value: CSVConfig) => {
this.setState({ ...this.state, csvConfig: value });
}
private rematchAccessions = () => {
const {dataset, rematchDatasetAccessions} = this.props;
rematchDatasetAccessions(dataset);
}
private clearList = () => {
const {dataset, clearAccessionRefList} = this.props;
clearAccessionRefList(dataset);
}
public constructor(props: any) {
super(props);
......@@ -99,7 +113,15 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
</div>
<h3>{ t('datasets.dashboard.p.stepper.listOfAccessions.rowCount', { count: accessionRefs ? accessionRefs.totalElements : 0 }) }</h3>
<h3>
{ t('datasets.dashboard.p.stepper.listOfAccessions.rowCount', { count: accessionRefs ? accessionRefs.totalElements : 0 }) }
<span className="float-right">
<ButtonBar>
<ActionButton title={ t('datasets.dashboard.p.stepper.listOfAccessions.rematch') } action={ this.rematchAccessions }/>
<ActionButton title={ t('datasets.dashboard.p.stepper.listOfAccessions.clearList') } action={ this.clearList }/>
</ButtonBar>
</span>
</h3>
<AccessionRefsTable
loadNextPage={ loadAccessions }
paged={ accessionRefs }
......
......@@ -2,7 +2,7 @@ import * as React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
// actions
import { updateDatasetAccessionRefs } from 'datasets/actions/editor';
import { rematchDatasetAccessions, updateDatasetAccessionRefs, clearAccessionRefList } from 'datasets/actions/editor';
import {loadMoreAccessions} from 'datasets/actions/dashboard';
// models
......@@ -27,6 +27,8 @@ interface IAccessionsListStep extends React.ClassAttributes<any> {
onGotoStep: (id: number) => () => void;
location: any;
uuid: string;
clearAccessionRefList: (dataset: Dataset) => void;
rematchDatasetAccessions: (dataset: Dataset) => void;
}
class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
......@@ -41,13 +43,16 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
}
protected renderContent = () => {
const { accessionRefs, item } = this.props;
const { accessionRefs, item, rematchDatasetAccessions, clearAccessionRefList} = this.props;
return !item ? <Loading/> : (
<ListOfAccessions
dataset={ item }
accessionRefs={ accessionRefs }
onAccessionsUpdated={ this.updateAccessionsRefs }
loadAccessions={ this.loadMoreAccessions }
rematchDatasetAccessions={ rematchDatasetAccessions }
clearAccessionRefList={ clearAccessionRefList }
/>
);
}
......@@ -78,6 +83,8 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
updateDatasetAccessionRefs,
clearAccessionRefList,
rematchDatasetAccessions,
loadMore: loadMoreAccessions,
}, dispatch);
......
import * as UrlTemplate from 'url-template';
import * as QueryString from 'query-string';
import { axiosBackend } from 'utilities/requestUtils';
......@@ -19,6 +18,7 @@ const URL_CREATE_DATASET = `/api/v1/dataset/create`;
const URL_REVIEW_DATASET = `/api/v1/dataset/for-review`;
const URL_DATASET_LIST = `/api/v1/dataset/list`;
const URL_MY_DATASETS = `/api/v1/dataset/list-mine`;
const URL_REMATCH_DATASET_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/rematchAccessions/{uuid},{version}`);
const URL_REJECT_DATASET = `/api/v1/dataset/reject`;
const URL_REMOVE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/remove-descriptors/{uuid},{version}`);
const URL_UPDATE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/set-descriptors/{uuid},{version}`);
......@@ -583,6 +583,25 @@ class DatasetService {
}).then(({ data }) => data as DatasetLocation);
}
/**
* rematchDatasetAccessions at /api/v1/dataset/rematchAccessions/{uuid},{version}
*
* @param uuid uuid
* @param version version
*/
public static rematchDatasetAccessions(uuid: string, version: number): Promise<Dataset> {
const apiUrl = URL_REMATCH_DATASET_ACCESSIONS.expand({ uuid, version });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
return axiosBackend.request({
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as Dataset);
}
/**
* listLocation at /api/v1/dataset/{uuid}/location/list
*
......
......@@ -88,9 +88,9 @@ class AccessionRefsTable extends React.Component<IAccessionRefsTableProps, any>
<TableRow key={ acce.acceNumb }>
<TableCell style={ { width: widths[0] } }>{ acce.instCode }</TableCell>
<TableCell style={ { width: widths[1] } }>{ acce.accession ? <AccessionLink to={ acce.accession } /> : acce.acceNumb }</TableCell>
<TableCell style={ { width: widths[2] } }>{ acce.accession.taxonomy.genus || acce.genus }</TableCell>
<TableCell style={ { width: widths[3] } }>{ acce.accession.taxonomy.species || acce.species }</TableCell>
<TableCell style={ { width: widths[4] } }><DOI noPrefix value={ acce.accession.doi || acce.doi } /></TableCell>
<TableCell style={ { width: widths[2] } }>{ acce.accession && acce.accession.taxonomy.genus || acce.genus }</TableCell>
<TableCell style={ { width: widths[3] } }>{ acce.accession && acce.accession.taxonomy.species || acce.species }</TableCell>
<TableCell style={ { width: widths[4] } }><DOI noPrefix value={ acce.accession && acce.accession.doi || acce.doi } /></TableCell>
</TableRow>
);
......
Markdown is supported
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