Commit a699ed17 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Study View: Add @ID to IDs list and deduplicate list.

parent 26d97037
......@@ -142,21 +142,6 @@ export function getCodeBookElementsList(
return Array.isArray(node) ? node : [node]
}
export function getCodeBookID(codeBook: CodeBook): string | undefined {
let ids: string | IDNoElement | (string | IDNoElement)[] =
codeBook.stdyDscr.citation.titlStmt.IDNo
if (!Array.isArray(ids)) {
ids = [ids]
}
for (const id of ids) {
const idText = extractCodeBookText(id)
if (idText !== undefined) {
return idText
}
}
return undefined
}
export function getCodeBookProductionYear(
codeBook: CodeBook,
): string | undefined {
......@@ -369,6 +354,24 @@ export function* iterCodeBookFilesDescription(
}
}
export function* iterCodeBookIds(
codeBook: CodeBook,
): Generator<string, void, void> {
let ids: string | IDNoElement | (string | IDNoElement)[] =
codeBook.stdyDscr.citation.titlStmt.IDNo
ids = [
...new Set(
Array.isArray(ids) ? [codeBook["@ID"], ...ids] : [codeBook["@ID"], ids],
),
]
for (const id of ids) {
const idText = extractCodeBookText(id)
if (idText !== undefined) {
yield idText
}
}
}
export function* iterCodeBookKeywords(
codeBook: CodeBook,
): Generator<string, void, void> {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment