Skip to content

Commit

Permalink
Merge pull request #293 from skohub-io/281-notes
Browse files Browse the repository at this point in the history
281 notes
  • Loading branch information
sroertgen authored Apr 18, 2024
2 parents b7d07de + 828155f commit cb9c670
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 24 deletions.
57 changes: 45 additions & 12 deletions src/components/Concept.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,55 @@ const Concept = ({
</Markdown>
</div>
)}
{concept.scopeNote && (
{concept.note && i18n(language)(concept.note) !== "" && (
<div className="markdown">
<h3>Scope Note</h3>
<Markdown>
{i18n(language)(concept.scopeNote) ||
`*No scope note in language "${language}" provided.*`}
</Markdown>
<h3 id="note">Note</h3>
<ul aria-labelledby="note">
{i18n(language)(concept.note).map((note, i) => (
<li key={i}>{note}</li>
))}
</ul>
</div>
)}
{concept.note && (
{concept.changeNote && i18n(language)(concept.changeNote) !== "" && (
<div className="markdown">
<h3>Note</h3>
<Markdown>
{i18n(language)(concept.note) ||
`*No note in language "${language}" provided.*`}
</Markdown>
<h3 id="changenote">ChangeNote</h3>
<ul aria-labelledby="changenote">
{i18n(language)(concept.changeNote).map((changeNote, i) => (
<li key={i}>{changeNote}</li>
))}
</ul>
</div>
)}
{concept.editorialNote &&
i18n(language)(concept.editorialNote) !== "" && (
<div className="markdown">
<h3 id="editorialnote">EditorialNote</h3>
<ul aria-labelledby="editorialnote">
{i18n(language)(concept.editorialNote).map((editorialNote, i) => (
<li key={i}>{editorialNote}</li>
))}
</ul>
</div>
)}
{concept.historyNote && i18n(language)(concept.historyNote) !== "" && (
<div className="markdown">
<h3 id="historynote">HistoryNote</h3>
<ul aria-labelledby="historynote">
{i18n(language)(concept.historyNote).map((historyNote, i) => (
<li key={i}>{historyNote}</li>
))}
</ul>
</div>
)}
{concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && (
<div className="markdown">
<h3 id="scopenote">ScopeNote</h3>
<ul aria-labelledby="scopenote">
{i18n(language)(concept.scopeNote).map((scopeNote, i) => (
<li key={i}>{scopeNote}</li>
))}
</ul>
</div>
)}
{concept.altLabel && i18n(language)(concept.altLabel) !== "" && (
Expand Down
17 changes: 13 additions & 4 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ const jsonld = {
definition: {
"@container": "@language",
},
scopeNote: {
"@container": "@language",
},
note: {
"@container": "@language",
"@container": ["@language", "@set"],
},
changeNote: {
"@container": ["@language", "@set"],
},
editorialNote: {
"@container": ["@language", "@set"],
},
historyNote: {
"@container": ["@language", "@set"],
},
scopeNote: {
"@container": ["@language", "@set"],
},
notation: {
"@container": "@set",
Expand Down
13 changes: 11 additions & 2 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ module.exports.allConcept = (inScheme, languages) => `
definition {
${[...languages].join(" ")}
}
scopeNote {
note {
${[...languages].join(" ")}
}
note {
changeNote {
${[...languages].join(" ")}
}
editorialNote {
${[...languages].join(" ")}
}
historyNote {
${[...languages].join(" ")}
}
scopeNote {
${[...languages].join(" ")}
}
notation
Expand Down
7 changes: 5 additions & 2 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ module.exports = (languages) => `
altLabel: LanguageMapArray,
hiddenLabel: LanguageMapArray,
definition: LanguageMap,
scopeNote: LanguageMap,
note: LanguageMap,
note: LanguageMapArray,
changeNote: LanguageMapArray,
editorialNote: LanguageMapArray,
historyNote: LanguageMapArray,
scopeNote: LanguageMapArray,
notation: [String],
example: LanguageMap,
topConceptOf: [ConceptScheme] @link(from: "topConceptOf___NODE"),
Expand Down
65 changes: 65 additions & 0 deletions test/concept.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,71 @@ describe.concurrent("Concept", () => {
).toBeInTheDocument()
})

it("renders notes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Anmerkung/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: "Note",
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders changeNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Change Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /changenote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders editorialNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Editorial Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /editorialnote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders historyNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine History Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /historynote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders scopeNotes", () => {
render(<Concept pageContext={ConceptPC} />)

expect(screen.getByText(/Meine Scope Note/i)).toBeInTheDocument()

const list = screen.getByRole("list", {
name: /scopenote/i,
})
const { getAllByRole } = within(list)
const items = getAllByRole("listitem")
expect(items.length).toBe(2)
})

it("renders related Concepts", () => {
render(<Concept pageContext={ConceptPC} />)
expect(
Expand Down
17 changes: 13 additions & 4 deletions test/data/pageContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,20 @@ export const topConcept = {
example: {
de: "Ein Beispiel",
},
scopeNote: {
de: "Meine Scope Note",
},
note: {
de: "Meine Anmerkung",
de: ["Meine Anmerkung", "Noch eine Anmerkung"],
},
changeNote: {
de: ["Meine Change Note", "Noch eine Change Note"],
},
editorialNote: {
de: ["Meine Editorial Note", "Noch eine Editorial Note"],
},
historyNote: {
de: ["Meine History Note", "Noch eine History Note"],
},
scopeNote: {
de: ["Meine Scope Note", "Noch eine Scope Note"],
},
notation: ["1"],
narrower: [concept2],
Expand Down

0 comments on commit cb9c670

Please sign in to comment.