-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ add data page metadata fields to admin (#3006)
* ✨ add data page metadata fields to admin --------- Co-authored-by: Daniel Bachler <daniel@danielbachler.de>
- Loading branch information
Showing
6 changed files
with
471 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from "react" | ||
import { observer } from "mobx-react" | ||
import { AdminAppContext, AdminAppContextType } from "./AdminAppContext.js" | ||
import { OwidOrigin } from "@ourworldindata/utils" | ||
import { BindString, FieldsRow } from "./Forms.js" | ||
|
||
@observer | ||
export class OriginList extends React.Component<{ | ||
origins: OwidOrigin[] | ||
}> { | ||
static contextType = AdminAppContext | ||
context!: AdminAppContextType | ||
|
||
render() { | ||
const { origins } = this.props | ||
const isDisabled = true | ||
|
||
return ( | ||
<div> | ||
{origins.map((origin, index) => ( | ||
<div key={index}> | ||
<h4>{origin.title}</h4> | ||
<FieldsRow> | ||
<BindString | ||
label="Title" | ||
field="title" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="Title Snapshot" | ||
field="titleSnapshot" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="Attribution" | ||
field="attribution" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="Attribution Short" | ||
field="attributionShort" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
</FieldsRow> | ||
<FieldsRow> | ||
<BindString | ||
label="Description" | ||
field="description" | ||
store={origin} | ||
disabled={isDisabled} | ||
textarea | ||
/> | ||
<BindString | ||
label="Description Snapshot" | ||
field="descriptionSnapshot" | ||
store={origin} | ||
disabled={isDisabled} | ||
textarea | ||
/> | ||
<BindString | ||
label="Citation Full" | ||
field="citationFull" | ||
store={origin} | ||
disabled={isDisabled} | ||
textarea | ||
/> | ||
<BindString | ||
label="Producer" | ||
field="producer" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
</FieldsRow> | ||
<FieldsRow> | ||
<BindString | ||
label="URL Main" | ||
field="urlMain" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="URL Download" | ||
field="urlDownload" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="Date Accessed" | ||
field="dateAccessed" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
<BindString | ||
label="Date Published" | ||
field="datePublished" | ||
store={origin} | ||
disabled={isDisabled} | ||
/> | ||
{/* Missing origin license... is it worth adding it? */} | ||
</FieldsRow> | ||
<hr /> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React from "react" | ||
import { observer } from "mobx-react" | ||
import { AdminAppContext, AdminAppContextType } from "./AdminAppContext.js" | ||
import { OwidSource } from "@ourworldindata/utils" | ||
import { BindString } from "./Forms.js" | ||
|
||
const MAX_SOURCES = 10 | ||
|
||
@observer | ||
export class SourceList extends React.Component<{ | ||
sources: OwidSource[] | ||
}> { | ||
static contextType = AdminAppContext | ||
context!: AdminAppContextType | ||
|
||
render() { | ||
const { sources } = this.props | ||
const isDisabled = true | ||
|
||
// limit sources to MAX_SOURCES, if there's over MAX_SOURCES, add a warning at the top | ||
const sourcesLength = sources.length | ||
if (sourcesLength > MAX_SOURCES) { | ||
sources.length = MAX_SOURCES | ||
} | ||
|
||
return ( | ||
<div> | ||
{sourcesLength > MAX_SOURCES && ( | ||
<div className="alert alert-warning"> | ||
<strong>Warning:</strong> There are {sourcesLength}{" "} | ||
sources for this dataset. Only the first {MAX_SOURCES}{" "} | ||
will be displayed. | ||
</div> | ||
)} | ||
{sources.map((source, index) => ( | ||
<div key={index}> | ||
<div className="row"> | ||
<div className="col"> | ||
<BindString | ||
field="name" | ||
store={source} | ||
label="Source name" | ||
secondaryLabel="DB field: sources.description ->> '$.name'" | ||
disabled={isDisabled} | ||
// helpText={`Short citation of the main sources, to be displayed on the charts. Additional sources (e.g. population denominator) should not be included. Use semi-colons to separate multiple sources e.g. "UN (2022); World Bank (2022)". For institutional datasets or reports, use "Institution, Project (year or vintage)" e.g. "IHME, Global Burden of Disease (2019)". For data we have modified extensively, use "Our World in Data based on X (year)" e.g. "Our World in Data based on Pew Research Center (2022)". For academic papers, use "Authors (year)" e.g. "Arroyo-Abad and Lindert (2016)".`} | ||
/> | ||
<BindString | ||
field="dataPublishedBy" | ||
store={source} | ||
label="Data published by" | ||
secondaryLabel="DB field: sources.description ->> '$.dataPublishedBy'" | ||
disabled={isDisabled} | ||
// helpText={`Full citation of main and additional sources. For academic papers, institutional datasets, and reports, use the complete citation recommended by the publisher. For data we have modified extensively, use "Our World in Data based on X (year) and Y (year)" e.g. "Our World in Data based on Pew Research Center (2022) and UN (2022)".`} | ||
/> | ||
<BindString | ||
field="dataPublisherSource" | ||
store={source} | ||
label="Data publisher's source" | ||
secondaryLabel="DB field: sources.description ->> '$.dataPublisherSource'" | ||
disabled={isDisabled} | ||
// helpText={`Optional field. Basic indication of how the publisher collected this data e.g. "Survey data". Anything longer than a line should go in the dataset description.`} | ||
/> | ||
<BindString | ||
field="link" | ||
store={source} | ||
label="Link" | ||
secondaryLabel="DB field: sources.description ->> '$.link'" | ||
disabled={isDisabled} | ||
// helpText="Link to the publication from which we retrieved this data" | ||
/> | ||
<BindString | ||
field="retrievedDate" | ||
store={source} | ||
label="Retrieved" | ||
secondaryLabel="DB field: sources.description ->> '$.retrievedDate'" | ||
disabled={isDisabled} | ||
// helpText="Date when this data was obtained by us. Date format should always be YYYY-MM-DD." | ||
/> | ||
</div> | ||
|
||
<div className="col"> | ||
<BindString | ||
field="additionalInfo" | ||
store={source} | ||
label="Additional info" | ||
secondaryLabel="DB field: sources.description ->> '$.additionalInfo'" | ||
textarea | ||
disabled={isDisabled} | ||
// helpText="Describe the dataset and the methodology used in its construction. This can be as long and detailed as you like." | ||
rows={15} | ||
/> | ||
</div> | ||
</div> | ||
<hr /> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
} |
Oops, something went wrong.