From ff13455b56647b9aefcac6f389929a4856c6ee2d Mon Sep 17 00:00:00 2001 From: "@s.roertgen" Date: Tue, 26 Mar 2024 16:33:14 +0100 Subject: [PATCH 1/2] WIP: Allow multiple entries for `note` and `scopeNote` #281 --- src/components/Concept.jsx | 24 +++++++++++++----------- src/context.js | 4 ++-- src/types.js | 4 ++-- test/data/pageContext.js | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/components/Concept.jsx b/src/components/Concept.jsx index 58702c9..f570293 100644 --- a/src/components/Concept.jsx +++ b/src/components/Concept.jsx @@ -52,22 +52,24 @@ const Concept = ({ )} - {concept.scopeNote && ( + {concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && (
-

Scope Note

- - {i18n(language)(concept.scopeNote) || - `*No scope note in language "${language}" provided.*`} - +

ScopeNote

+
)} - {concept.note && ( + {concept.note && i18n(language)(concept.note) !== "" && (

Note

- - {i18n(language)(concept.note) || - `*No note in language "${language}" provided.*`} - +
)} {concept.altLabel && i18n(language)(concept.altLabel) !== "" && ( diff --git a/src/context.js b/src/context.js index 0ae32b3..92eddf8 100644 --- a/src/context.js +++ b/src/context.js @@ -49,10 +49,10 @@ const jsonld = { "@container": "@language", }, scopeNote: { - "@container": "@language", + "@container": ["@language", "@set"], }, note: { - "@container": "@language", + "@container": ["@language", "@set"], }, notation: { "@container": "@set", diff --git a/src/types.js b/src/types.js index 911dc60..223dee9 100644 --- a/src/types.js +++ b/src/types.js @@ -20,8 +20,8 @@ module.exports = (languages) => ` altLabel: LanguageMapArray, hiddenLabel: LanguageMapArray, definition: LanguageMap, - scopeNote: LanguageMap, - note: LanguageMap, + scopeNote: LanguageMapArray, + note: LanguageMapArray, notation: [String], example: LanguageMap, topConceptOf: [ConceptScheme] @link(from: "topConceptOf___NODE"), diff --git a/test/data/pageContext.js b/test/data/pageContext.js index 116a23f..b54ad52 100644 --- a/test/data/pageContext.js +++ b/test/data/pageContext.js @@ -50,10 +50,10 @@ export const topConcept = { de: "Ein Beispiel", }, scopeNote: { - de: "Meine Scope Note", + de: ["Meine Scope Note"], }, note: { - de: "Meine Anmerkung", + de: ["Meine Anmerkung"], }, notation: ["1"], narrower: [concept2], From 828155f97c2c7862f9bcd293a59cb37e5a0423b3 Mon Sep 17 00:00:00 2001 From: "@s.roertgen" Date: Wed, 27 Mar 2024 09:13:25 +0100 Subject: [PATCH 2/2] Add changeNote, editorialNote, historyNote, add tests for notes #281 --- src/components/Concept.jsx | 51 ++++++++++++++++++++++++------ src/context.js | 13 ++++++-- src/queries.js | 13 ++++++-- src/types.js | 5 ++- test/concept.test.jsx | 65 ++++++++++++++++++++++++++++++++++++++ test/data/pageContext.js | 17 +++++++--- 6 files changed, 145 insertions(+), 19 deletions(-) diff --git a/src/components/Concept.jsx b/src/components/Concept.jsx index f570293..2834973 100644 --- a/src/components/Concept.jsx +++ b/src/components/Concept.jsx @@ -52,22 +52,53 @@ const Concept = ({ )} - {concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && ( + {concept.note && i18n(language)(concept.note) !== "" && (
-

ScopeNote

-
    - {i18n(language)(concept.scopeNote).map((scopeNote, i) => ( -
  • {scopeNote}
  • +

    Note

    +
      + {i18n(language)(concept.note).map((note, i) => ( +
    • {note}
    • ))}
)} - {concept.note && i18n(language)(concept.note) !== "" && ( + {concept.changeNote && i18n(language)(concept.changeNote) !== "" && (
-

Note

-
    - {i18n(language)(concept.note).map((note, i) => ( -
  • {note}
  • +

    ChangeNote

    +
      + {i18n(language)(concept.changeNote).map((changeNote, i) => ( +
    • {changeNote}
    • + ))} +
    +
+ )} + {concept.editorialNote && + i18n(language)(concept.editorialNote) !== "" && ( +
+

EditorialNote

+
    + {i18n(language)(concept.editorialNote).map((editorialNote, i) => ( +
  • {editorialNote}
  • + ))} +
+
+ )} + {concept.historyNote && i18n(language)(concept.historyNote) !== "" && ( +
+

HistoryNote

+
    + {i18n(language)(concept.historyNote).map((historyNote, i) => ( +
  • {historyNote}
  • + ))} +
+
+ )} + {concept.scopeNote && i18n(language)(concept.scopeNote) !== "" && ( +
+

ScopeNote

+
    + {i18n(language)(concept.scopeNote).map((scopeNote, i) => ( +
  • {scopeNote}
  • ))}
diff --git a/src/context.js b/src/context.js index 92eddf8..127ced6 100644 --- a/src/context.js +++ b/src/context.js @@ -48,10 +48,19 @@ const jsonld = { definition: { "@container": "@language", }, - scopeNote: { + note: { "@container": ["@language", "@set"], }, - note: { + changeNote: { + "@container": ["@language", "@set"], + }, + editorialNote: { + "@container": ["@language", "@set"], + }, + historyNote: { + "@container": ["@language", "@set"], + }, + scopeNote: { "@container": ["@language", "@set"], }, notation: { diff --git a/src/queries.js b/src/queries.js index da97cb4..d14c8ca 100644 --- a/src/queries.js +++ b/src/queries.js @@ -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 diff --git a/src/types.js b/src/types.js index 223dee9..e189dc4 100644 --- a/src/types.js +++ b/src/types.js @@ -20,8 +20,11 @@ module.exports = (languages) => ` altLabel: LanguageMapArray, hiddenLabel: LanguageMapArray, definition: LanguageMap, - scopeNote: LanguageMapArray, note: LanguageMapArray, + changeNote: LanguageMapArray, + editorialNote: LanguageMapArray, + historyNote: LanguageMapArray, + scopeNote: LanguageMapArray, notation: [String], example: LanguageMap, topConceptOf: [ConceptScheme] @link(from: "topConceptOf___NODE"), diff --git a/test/concept.test.jsx b/test/concept.test.jsx index 4272965..3667f8d 100644 --- a/test/concept.test.jsx +++ b/test/concept.test.jsx @@ -125,6 +125,71 @@ describe.concurrent("Concept", () => { ).toBeInTheDocument() }) + it("renders notes", () => { + render() + + 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() + + 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() + + 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() + + 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() + + 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() expect( diff --git a/test/data/pageContext.js b/test/data/pageContext.js index b54ad52..c593355 100644 --- a/test/data/pageContext.js +++ b/test/data/pageContext.js @@ -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],