Skip to content

Commit

Permalink
Merge branch 'master' into 1150-file-ds-notification
Browse files Browse the repository at this point in the history
  • Loading branch information
vfried authored Feb 18, 2021
2 parents 7db8cbe + 6153940 commit 618d865
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 17 deletions.
7 changes: 5 additions & 2 deletions client/src/dataset/Dataset.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ export default function DatasetView(props) {
const datasetPublished = dataset.published !== undefined && dataset.published.datePublished
!== undefined && dataset.published.datePublished !== null;

let datasetDate = datasetPublished ? dataset.published.datePublished : dataset.created;

return <Col>
<Row>
<Col md={8} sm={12}>
{ datasetPublished ?
{ datasetDate ?
<small style={{ display: "block", paddingBottom: "8px" }} className="font-weight-light font-italic">
Uploaded on {Time.getReadableDate(dataset.published.datePublished.replace(/ /g, "T"))}.
{datasetPublished ? "Published on " : "Created on "}
{Time.getReadableDate(datasetDate.replace(/ /g, "T"))}.
</small>
: null
}
Expand Down
6 changes: 4 additions & 2 deletions client/src/dataset/DatasetFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function mapDataset(dataset_core, dataset_kg, core_files) {
name: dataset_core.name,
title: dataset_core.title,
description: dataset_core.description,
created: dataset_core.created_at,
published: {
creator: dataset_core.creators,
datePublished: dataset_core.created_at
creator: dataset_core.creators
},
identifier: dataset_core.identifier,
keywords: dataset_core.keywords,
Expand All @@ -26,6 +26,8 @@ function mapDataset(dataset_core, dataset_kg, core_files) {
dataset.sameAs = dataset_kg.sameAs;
dataset.isPartOf = dataset_kg.isPartOf;
dataset.insideKg = true;
dataset.published.datePublished = dataset_kg.published && dataset_kg.published.datePublished ?
dataset_kg.published.datePublished : undefined;
}
else {
dataset.insideKg = false;
Expand Down
19 changes: 17 additions & 2 deletions client/src/dataset/Datasets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe("Dataset functions", () => {
"email": null,
"affiliation": "Some Affiliation"
}],
"datePublished": "01/01/2001",
},
"created": "01/01/2001",
"identifier": "79215657-4319-4fcf-82b9-58267f2a1db8",
"keywords": ["test1", "test2", "test3"],
"hasPart": [
Expand Down Expand Up @@ -131,8 +131,8 @@ describe("Dataset functions", () => {
"email": null,
"affiliation": "Some Affiliation"
}],
"datePublished": "01/01/2001",
},
"created": "01/01/2001",
"identifier": "79215657-4319-4fcf-82b9-58267f2a1db8",
"keywords": ["test1", "test2", "test3"],
"hasPart": [
Expand All @@ -147,6 +147,17 @@ describe("Dataset functions", () => {
"insideKg": true
};

const core_dataset_import = { ...core_dataset };
delete core_dataset_import.created_at;

const kg_dataset_import = { ...kg_dataset };

const result_dataset_import = {
...result_dataset_in_kg
};
delete result_dataset_import.created;
result_dataset_import.published.datePublished = "01/01/2001";


const core_files = [
{ "name": "Data file 2.xls", "atLocation": "data/test_dataset/Data file 2.xls" },
Expand All @@ -165,4 +176,8 @@ describe("Dataset functions", () => {
expect(mapDataset(undefined, kg_dataset, undefined)).toEqual(result_dataset_only_kg);
});

it("maps core dataset into kg dataset in a project for imported dataset", () => {
expect(mapDataset(core_dataset_import, kg_dataset_import, core_files)).toEqual(result_dataset_import);
});

});
4 changes: 2 additions & 2 deletions client/src/dataset/list/DatasetList.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class List extends Component {
switch (this.model.get("orderBy")) {
case orderByValuesMap.TITLE:
return "title";
case orderByValuesMap.DATE_PUBLISHED:
return "date published";
case orderByValuesMap.DATE:
return "date";
case orderByValuesMap.PROJECTSCOUNT:
return "projects count";
default:
Expand Down
12 changes: 7 additions & 5 deletions client/src/dataset/list/DatasetList.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class DatasetListRow extends Component {
: null
}
{
dataset.published !== undefined && dataset.published.datePublished !== undefined ?
dataset.date ?
<small className="font-italic">
{"Date published: " + new Date(dataset.published.datePublished).toLocaleDateString()}
{dataset.published && dataset.published.datePublished ?
"Published on: " : "Created on: "}
{new Date(dataset.date).toLocaleDateString()}
</small>
: null
}
Expand Down Expand Up @@ -100,10 +102,10 @@ class DatasetSearchForm extends Component {
{this.props.orderBy === this.props.orderByValuesMap.TITLE ?
<FontAwesomeIcon icon={faCheck} /> : null} Title
</DropdownItem>
<DropdownItem value={this.props.orderByValuesMap.DATE_PUBLISHED}
<DropdownItem value={this.props.orderByValuesMap.DATE}
onClick={this.props.handlers.changeSearchDropdownOrder}>
{this.props.orderBy === this.props.orderByValuesMap.DATE_PUBLISHED ?
<FontAwesomeIcon icon={faCheck} /> : null} Date Published
{this.props.orderBy === this.props.orderByValuesMap.DATE ?
<FontAwesomeIcon icon={faCheck} /> : null} Date
</DropdownItem>
<DropdownItem value={this.props.orderByValuesMap.PROJECTSCOUNT}
onClick={this.props.handlers.changeSearchDropdownOrder}>
Expand Down
6 changes: 3 additions & 3 deletions client/src/dataset/list/DatasetList.state.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Schema, StateKind, StateModel } from "../../model/Model";

const orderByValuesMap = {
TITLE: "title",
DATE_PUBLISHED: "datePublished",
DATE: "date",
PROJECTSCOUNT: "projectsCount"
};

Expand Down Expand Up @@ -104,8 +104,8 @@ class DatasetListModel extends StateModel {
switch (this.get("orderBy")) {
case orderByValuesMap.TITLE:
return "title:" + searchOrder;
case orderByValuesMap.DATE_PUBLISHED:
return "datePublished:" + searchOrder;
case orderByValuesMap.DATE:
return "date:" + searchOrder;
case orderByValuesMap.PROJECTSCOUNT:
return "projectsCount:" + searchOrder;
default:
Expand Down
2 changes: 1 addition & 1 deletion client/src/project/datasets/DatasetsListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function DatasetListRow(props) {
{
dataset.created_at !== undefined && dataset.created_at !== null ?
<small className="font-italic">
{"Published: " + new Date(dataset.created_at.replace(/ /g, "T")).toLocaleDateString()}
{"Created: " + new Date(dataset.created_at.replace(/ /g, "T")).toLocaleDateString()}
</small>
: null
}
Expand Down

0 comments on commit 618d865

Please sign in to comment.