Commit a5a2c52b authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

Several fixes

- fixed padding/margin
- fixed descriptor display page route
- fixed CSV paste for dataset/descriptorList steppers
- fix related to migrate to DataProvider
- fix PartnerSelector width
- replaced catalog excel template
- i18n fix
- fix dashboard publish/approve/reject actions for dataset
- fixed dashboard onSortChange
- fixed descriptorList select step
- fixed partners BrowsePage sort
- fixed incorrect v0 api url-s
- fixed SSR sort at dashboard pages
- fixed sort at vocabulary BrowsePage
- fixed sort at partner BrowsePage
parent ebd829ac
{
"action": {
"add": "Add {{what, lowercase}}",
"apply": "Apply",
"applyFilters": "Apply filters",
"approve": "Approve and publish",
"back": "Back",
"approve": "Approve",
"backTo": "Back to {{where, lowercase}}",
"backToList": "Back to list",
"backToDashboard": "Back to dashboard",
"cancel": "Cancel",
"close": "Close",
"create": "Create",
"collapse": "Collapse",
"delete": "Delete",
"deleteData": "Delete data",
"download": "Download",
"edit": "Edit",
"login": "Login",
"logout": "Logout",
"publish": "Publish",
"saveChanges": "Save changes",
"search": "Search",
"un-publish": "Un-publish",
"viewDetails": "View details",
"applyFilters": "Apply filters",
"back": "Back",
"backToList": "Back to list",
"create": "Create",
"deleteData": "Delete data",
"manage": "Manage",
"nextStep": "Next step",
"openSidebar": "Open sidebar",
"read": "Read",
"reject": "Reject",
"remove": "Remove",
"reset": "Reset",
"return": "Return",
"save": "Save",
"saveChanges": "Save changes",
"search": "Search",
"show": "Show",
"sendToReview": "Send to review",
"unpublish": "Unpublish",
"view": "View",
"write": "Write"
"write": "Write",
"acceptAndPublish": "ACCEPT AND PUBLISH"
},
"csv": {
"autoDetect": "Auto-detect ",
......@@ -50,7 +58,8 @@
"dateSearch": "Date search",
"fromIncluding": "From including",
"lastModifiedDate": "Last modified date",
"textSearch": "Text search"
"textSearch": "Text search",
"keyword": "Keyword search"
},
"fileUploader": {
"chooseFiles": "Choose files to upload",
......@@ -58,11 +67,17 @@
"release": "Release to upload"
},
"label": {
"item": "Item",
"item_plural": "Items",
"list": "List",
"list_plural": "Lists",
"created": "Created",
"dateNotProvided": "Date not provided",
"description": "Description",
"either": "Either",
"false": "False",
"filters": "Filters",
"from": "From",
"itemEditorWarn": "Don't use the ItemsEditor for more than 100 items!",
"lastModified": "Last modified",
"lastUpdated": "Last updated",
......@@ -71,11 +86,16 @@
"newVersionAvailable": "New version available",
"no": "No",
"prettyNumber": "{{value, number}}",
"registered": "Registered",
"sortBy": "Sort By",
"status": "Status",
"stepsForDataPublication": "Steps for data publication completion",
"title": "Title",
"true": "True",
"to": "To",
"untitled": "Untitled",
"UUID": "UUID",
"version": "Version {{version, numeric}}",
"yes": "Yes",
"basicMarkdown": "Basic markdown supported",
"fullMarkdown": "Full markdown supported",
......
......@@ -291,8 +291,8 @@
}
},
"status": {
"inReview": "Draft",
"inProgress": "In review",
"inReview": "In review",
"inProgress": "Draft",
"published": "Published"
}
,"accessions": {
......
......@@ -88,7 +88,7 @@ export const loadDataset = (uuid: string) => (dispatch) => {
function publishDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return dataset.state === PublishState.DRAFT &&
DatasetService.reviewDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
......@@ -100,7 +100,7 @@ function publishDataset(datasetUuid: string) {
function unpublishDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return dataset.state !== PublishState.DRAFT &&
DatasetService.rejectDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
......@@ -112,7 +112,7 @@ function unpublishDataset(datasetUuid: string) {
function approveDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return dataset.state === PublishState.REVIEWING &&
DatasetService.approveDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
......@@ -124,7 +124,7 @@ function approveDataset(datasetUuid: string) {
function deleteDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return DatasetService.deleteDataset(dataset.uuid, dataset.version)
.then((deleted) => {
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import withStyles from '@material-ui/core/styles/withStyles';
import { parse } from 'query-string';
......@@ -24,6 +25,10 @@ import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
import { translate } from 'react-i18next';
const style = (theme) => ({
container: theme.container.spacingHorizontal,
});
class BrowsePage extends BrowsePageTemplate<Dataset> {
public static needs = [
......@@ -33,10 +38,10 @@ class BrowsePage extends BrowsePageTemplate<Dataset> {
},
];
protected renderDataset = (d: Dataset) => <DatasetCard className="m-20" dataset={ d } key={ d.uuid }/>;
protected renderDataset = (d: Dataset) => <DatasetCard dataset={ d } key={ d.uuid }/>;
public render() {
const { paged, t, loadMoreData } = this.props;
const { paged, t, loadMoreData, classes } = this.props;
const stillLoading: boolean = (!paged || !paged.content);
......@@ -58,7 +63,7 @@ class BrowsePage extends BrowsePageTemplate<Dataset> {
filterObj={ paged && paged.filter || {} }
onSubmit={ this.myApplyFilters }
/>
<PageContents>
<PageContents className={ classes.container }>
{ stillLoading ? <Loading/> :
<PagedLoader
paged={ paged }
......@@ -86,4 +91,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
updateRoute,
}, dispatch);
export default translate()(connect(mapStateToProps, mapDispatchToProps)(BrowsePage));
export default withStyles(style)(translate()(connect(mapStateToProps, mapDispatchToProps)(BrowsePage)));
......@@ -369,7 +369,7 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
</Button>
</a>
}>
<p>{ e.title || t('datasets.public.c.datasetDisplay.datasetFile') } }</p>
<p>{ e.title || t('datasets.public.c.datasetDisplay.datasetFile') }</p>
<p>{ e.originalFilename }</p>
</PropertiesItem>
))
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { approveDataset, deleteDataset, loadMoreDatasets, unpublishDataset, publishDataset } from 'datasets/actions/dashboard';
......@@ -13,7 +14,8 @@ const renderDataLink = ({ row, children }) => (<DatasetLink to={ row } edit={ ro
class DashboardPage extends BaseMyDataPage<Dataset> {
protected static needs = [
() => loadMoreDatasets(),
({ search , params: { filterCode } }) => loadMoreDatasets({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
......
......@@ -7,6 +7,7 @@ import { translate } from 'react-i18next';
import { log } from 'utilities/debug';
import Dataset from 'model/catalog/Dataset';
import { AccessionRef } from 'model/accession/AccessionRef';
import AccessionRefsTable from 'ui/catalog/accession/AccessionRefsTable';
import { CSV, ICsvConfiguration } from 'utilities/CSV';
......@@ -15,7 +16,7 @@ import CSVConfiguration, { CSVConfig } from 'ui/common/csv-configuration/CSVConf
interface IListOfAccession extends React.ClassAttributes<any> {
classes: any;
onAccessionsUpdated: (accessionRefs: AccessionRef[]) => void;
accessionRefs: AccessionRef[];
dataset: Dataset;
t: any;
}
......@@ -63,7 +64,7 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
public render() {
const { classes, accessionRefs, t } = this.props;
const { classes, dataset, t } = this.props;
return (
<div className={ `${ classes.root } m-20 p-20 even-row` }>
......@@ -97,8 +98,8 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
</div>
<h3>Accession list: { accessionRefs ? accessionRefs.length : 0 } rows</h3>
<AccessionRefsTable accessionRefs={ accessionRefs }/>
<h3>Accession list: { dataset.accessionRefs ? dataset.accessionRefs.length : 0 } rows</h3>
<AccessionRefsTable accessionRefs={ dataset.accessionRefs }/>
</div>
);
}
......@@ -117,12 +118,13 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
const newIdentifiers: AccessionRef[] = [];
CSV.parse(csvText, config, { headers: ['instCode', 'acceNumb', 'genus', 'species', 'doi'] })
.on('json', (jsonObj) => {
const aid: AccessionRef = jsonObj as AccessionRef;
.subscribe((jsonObj) => {
const aid: AccessionRef = new AccessionRef(jsonObj);
newIdentifiers.push(aid);
log(aid);
}).on('end', () => {
// log(aid);
}).then(() => {
log('All CSV parsed');
this.setState({ ...this.state, uploading: true, uploadText: 'Uploading to server' });
this.props.onAccessionsUpdated(newIdentifiers);
});
}
......
......@@ -2,6 +2,7 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
import withStyles from '@material-ui/core/styles/withStyles';
import { parse } from 'query-string';
......@@ -25,6 +26,10 @@ import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
const style = (theme) => ({
container: theme.container.spacingHorizontal,
});
// Page to browse and filter descriptor lists
class BrowsePage extends BrowsePageTemplate<DescriptorList> {
......@@ -36,11 +41,11 @@ class BrowsePage extends BrowsePageTemplate<DescriptorList> {
];
protected renderDescriptorList = (d: DescriptorList) => (
<DescriptorListCard className="m-20" descriptorList={ d } key={ d.uuid }/>
<DescriptorListCard descriptorList={ d } key={ d.uuid }/>
)
public render() {
const { paged, t, loadMoreData } = this.props;
const { paged, t, loadMoreData, classes } = this.props;
const stillLoading: boolean = (!paged || !paged.content);
......@@ -65,7 +70,7 @@ class BrowsePage extends BrowsePageTemplate<DescriptorList> {
filterObj={ paged && paged.filter || {} }
onSubmit={ this.myApplyFilters }
/>
<PageContents>
<PageContents className={ classes.container }>
{ stillLoading ? <Loading/> :
<PagedLoader
paged={ paged }
......@@ -93,4 +98,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
updateRoute,
}, dispatch);
export default translate()(connect(mapStateToProps, mapDispatchToProps)(BrowsePage));
export default withStyles(style)(translate()(connect(mapStateToProps, mapDispatchToProps)(BrowsePage)));
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { loadMoreDescriptorLists, approveDescriptorList, deleteDescriptorList, unpublishDescriptorList, publishDescriptorList } from 'descriptorlists/actions/dashboard';
......@@ -12,7 +13,7 @@ const renderDataLink = ({ row, children }) => (<DescriptorListLink to={ row } ed
class DashboardPage extends BaseMyDataPage<any> {
protected static needs = [
() => loadMoreDescriptorLists(),
({ search , params: { filterCode } }) => loadMoreDescriptorLists({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
......
......@@ -5,13 +5,13 @@ import { addFilterCode } from 'actions/filterCode';
import navigateTo from 'actions/navigation';
// Constants
import { DASHBOARD_RECEIVE_DESCRIPTOR_PAGE, DASHBOARD_REMOVE_DESCRIPTOR, DASHBOARD_LIST_DESCRIPTORS, CREATE_DESCRIPTOR, DASHBOARD_APPEND_DESCRIPTOR_PAGE, RECEIVE_DESCRIPTOR } from 'descriptors/constants';
import { DASHBOARD_RECEIVE_DESCRIPTOR_PAGE, DASHBOARD_REMOVE_DESCRIPTOR, CREATE_DESCRIPTOR, DASHBOARD_APPEND_DESCRIPTOR_PAGE, RECEIVE_DESCRIPTOR } from 'descriptors/constants';
// Model
import Descriptor from 'model/catalog/Descriptor';
import DescriptorFilter from 'model/catalog/DescriptorFilter';
import { PublishState } from 'model/common.model';
import Page from 'model/Page';
import Page, { IPageRequest } from 'model/Page';
import FilteredPage from 'model/FilteredPage';
import Partner from 'model/genesys/Partner';
......@@ -41,10 +41,10 @@ const receiveDescriptor = (descriptor: Descriptor) => ({
payload: descriptor,
});
const loadingDescriptors = (page, results, sortBy, filter, order) => ({
type: DASHBOARD_LIST_DESCRIPTORS,
payload: { page, results, sortBy, filter, order },
});
// const loadingDescriptors = (page, results, sortBy, filter, order) => ({
// type: DASHBOARD_LIST_DESCRIPTORS,
// payload: { page, results, sortBy, filter, order },
// });
// Create a new descriptor
export const createDescriptor = () => (dispatch) => {
......@@ -52,12 +52,12 @@ export const createDescriptor = () => (dispatch) => {
return dispatch(push(`/dashboard/descriptors/edit`));
};
export function listMyDescriptors(page?, results?, sortBy?: string[], filter?: string | DescriptorFilter, order?) {
export function listMyDescriptors(page?: IPageRequest, filter?: string | DescriptorFilter) {
return (dispatch, getState) => {
dispatch(loadingDescriptors(page, results, sortBy, filter, order));
// dispatch(loadingDescriptors(page.page, page.size, page.properties, filter, page.direction));
return DescriptorService.myDescriptors(filter, { page, size: results, properties: sortBy, direction: order })
return DescriptorService.myDescriptors(filter, page)
.then((paged) => {
dereferenceReferences(paged.content, 'owner', (o) => o as Partner);
if (paged.number === 0) {
......
......@@ -10,6 +10,7 @@ const publicRoutes = [
{
path: '/descriptors/:filterCode(v.+)?',
component: DescriptorBrowsePage,
exact: true,
extraProps: {
title: 'descriptors.common.title',
subtitle: 'descriptors.common.subtitle',
......
......@@ -26,6 +26,7 @@ import Page from 'model/Page';
const styles = (theme) => ({
leftPanel: theme.leftPanel.root,
container: theme.container.spacingHorizontal,
});
class BrowsePage extends BrowsePageTemplate<Descriptor> {
......@@ -38,12 +39,12 @@ class BrowsePage extends BrowsePageTemplate<Descriptor> {
];
public render() {
const { paged, t, loadMoreData } = this.props;
const { paged, t, loadMoreData, classes } = this.props;
const stillLoading: boolean = (!paged || !paged.content);
const renderDescriptor = (d: Descriptor) => (
<DescriptorCard key={ d.uuid } className="mb-20" descriptor={ d } complete dataType vocabulary/>
<DescriptorCard key={ d.uuid } descriptor={ d } complete dataType vocabulary/>
);
return (
......@@ -66,7 +67,7 @@ class BrowsePage extends BrowsePageTemplate<Descriptor> {
filterObj={ paged && paged.filter || {} }
onSubmit={ this.myApplyFilters }
/>
<PageContents>
<PageContents className={ classes.container }>
{ stillLoading ? <Loading/> :
<PagedLoader
paged={ paged }
......
......@@ -119,7 +119,7 @@ class DescriptorParser extends React.Component<IDescriptorParser, any> {
'published', 'columnName', 'uom', 'headingNumber'],
})
.on('json', (jsonObj) => {
.subscribe((jsonObj) => {
if (jsonObj.minValue) {
jsonObj.minValue = +jsonObj.minValue;
......@@ -149,7 +149,7 @@ class DescriptorParser extends React.Component<IDescriptorParser, any> {
newDescriptors.push(d);
// log(d);
}).on('end', () => {
}).then(() => {
log('All CSV parsed');
this.props.onHandleDescriptors(newDescriptors);
});
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { parse } from 'query-string';
import BaseMyDataPage from 'ui/catalog/dashboard/MyDataPage';
import { approveDescriptor, deleteDescriptor, unpublishDescriptor, publishDescriptor, loadMoreDescriptors } from 'descriptors/actions/dashboard';
......@@ -14,7 +15,7 @@ const renderDataLink = ({ row, children }) => (<DescriptorLink to={ row } edit={
class DashboardPage extends BaseMyDataPage<Descriptor> {
protected static needs = [
() => loadMoreDescriptors(),
({ search , params: { filterCode } }) => loadMoreDescriptors({ sort: [{ property: parse(search || '').s, direction: parse(search || '').d }], filterCode }),
];
}
......
......@@ -22,7 +22,6 @@ class Partner implements IUserPermissions {
public urls: string[];
public uuid: string;
public version: number;
public wiewsCodes: string[];
public static DEFAULT_SORT = {
property: 'title',
......
......@@ -14,6 +14,7 @@ import Page from 'model/Page';
import Partner from 'model/genesys/Partner';
import PartnerFilter from 'model/genesys/PartnerFilter';
import FilteredPage, { IPageRequest } from 'model/FilteredPage';
import Vocabulary from 'model/vocabulary/Vocabulary';
// Service
import PartnerService from 'service/catalog/PartnerService';
......@@ -71,8 +72,26 @@ const loadPartners = (page: IPageRequest) => (dispatch, getState) => {
});
};
const loadMorePartners = (paged: FilteredPage<Vocabulary>) => (dispatch, getState) => {
return PartnerService.listPartners(paged ? paged.filterCode : '', Page.nextPage(paged))
.then((paged) => {
if (paged.number === 0) {
dispatch(receivePartnerPage(paged));
} else {
dispatch(appendPartnerPage(paged));
}
dispatch(loadPartnerNames(paged.content));
dispatch(updateRoute(paged));
return dispatch(addFilterCode(paged.filterCode, paged.filter));
})
.catch((error) => {
log('Error', error);
});
};
export {
loadPartners, receivePartner,
loadPartners, receivePartner, loadMorePartners,
};
export const updateRoute = (paged: FilteredPage<Partner>) => (dispatch) => {
......
......@@ -7,7 +7,7 @@ import { parse } from 'query-string';
import { filterCodeToUrl } from 'actions/filterCode';
import Partner from 'model/genesys/Partner';
import { applyFilters, loadPartners, updateRoute } from 'partners/actions/public';
import { applyFilters, loadMorePartners, updateRoute } from 'partners/actions/public';
import PagedLoader from 'ui/common/PagedLoader';
import Loading from 'ui/common/Loading';
......@@ -21,6 +21,11 @@ import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
import ContentHeader from 'ui/common/heading/ContentHeader';
import BrowsePageTemplate from 'ui/pages/_base/BrowsePage';
import Page from 'model/Page';
import withStyles from '@material-ui/core/styles/withStyles';
const style = (theme) => ({
container: theme.container.spacingHorizontal,
});
class PartnerListPage extends BrowsePageTemplate<Partner> {
......@@ -37,7 +42,7 @@ class PartnerListPage extends BrowsePageTemplate<Partner> {
public render() {
const { paged, t, loadMoreData } = this.props;
const { paged, t, loadMoreData, classes } = this.props;
const stillLoading: boolean = (!paged || !paged.content);
return (
......@@ -58,7 +63,7 @@ class PartnerListPage extends BrowsePageTemplate<Partner> {
filterObj={ paged && paged.filter || {} }
onSubmit={ this.myApplyFilters }
/>
<PageContents>
<PageContents className={ classes.container }>
{ stillLoading ? <Loading/> :
<PagedLoader
paged={ paged }
......@@ -80,9 +85,9 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
applyFilters,
loadData: loadPartners,
loadMoreData: loadMorePartners,
filterCodeToUrl,
updateRoute,
}, dispatch);
export default translate()(connect(mapStateToProps, mapDispatchToProps)(PartnerListPage));
export default translate()(withStyles(style)((connect(mapStateToProps, mapDispatchToProps)(PartnerListPage))));
......@@ -19,6 +19,7 @@ import Card, { CardHeader, CardContent, CardActions } from 'ui/common/Card';
import Button from '@material-ui/core/Button';
import Permissions from 'ui/common/permission/Permissions';
import PageLayout from 'ui/layout/PageLayout';
import PartnerService from 'service/catalog/PartnerService';
interface IPartnerPageProps extends React.ClassAttributes<any> {
classes: any;
......@@ -38,6 +39,11 @@ class PartnerPage extends React.Component<IPartnerPageProps, any> {
protected static needs = [
({ params: { uuid } }) => loadPartner(uuid),
];
public state = {
partnerInstitutes: null,
};
private onEditPartner = (e) => {
const { partner, editPartner } = this.props;
editPartner(partner.uuid);
......@@ -62,6 +68,8 @@ class PartnerPage extends React.Component<IPartnerPageProps, any> {
if (uuid && (!partner || partner.uuid !== uuid)) {
console.log(`cwm: Loading partner ${uuid}`, partner);
loadPartner(uuid);
// TODO temporary solution
PartnerService.listInstitutes(uuid).then((partnerInstitutes) => this.setState({partnerInstitutes}));
}
}
......@@ -72,12 +80,15 @@ class PartnerPage extends React.Component<IPartnerPageProps, any> {
if (!loading || loading.uuid !== uuid) {
console.log(`cwrp: Loading partner ${uuid}`, partner, loading);
loadPartner(uuid);
// TODO temporary solution
PartnerService.listInstitutes(uuid).then((partnerInstitutes) => this.setState({partnerInstitutes}));
}
}
}
public render() {
const { t, uuid, partner } = this.props;