From 628d2be2b2236826daa13d0e1cbb51939ed0b550 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Mon, 2 Dec 2024 14:24:28 -0500 Subject: [PATCH 1/4] Add CYAK to inline MARC subject creation --- .../panels/edit/fields/LookupComplex.vue | 24 ++--- src/lib/utils_network.js | 96 ++++++++++++++++--- 2 files changed, 94 insertions(+), 26 deletions(-) diff --git a/src/components/panels/edit/fields/LookupComplex.vue b/src/components/panels/edit/fields/LookupComplex.vue index de8b7460..41048811 100644 --- a/src/components/panels/edit/fields/LookupComplex.vue +++ b/src/components/panels/edit/fields/LookupComplex.vue @@ -606,8 +606,12 @@ export default { this.marcDeliminatedLCSHMode = true + //Get the type of search + let selection = document.getElementById(this.guid) + let selected = selection.options[selection.selectedIndex].value + this.searchType = selected - this.marcDeliminatedLCSHModeResults = await utilsNetwork.subjectLinkModeResolveLCSH(this.searchValue) + this.marcDeliminatedLCSHModeResults = await utilsNetwork.subjectLinkModeResolveLCSH(this.searchValue, this.searchType) this.marcDeliminatedLCSHModeSearching = false let sendResults = [] if (this.marcDeliminatedLCSHModeResults.resultType != 'ERROR'){ @@ -659,14 +663,14 @@ export default { }else{ - // we're opening the subject builder, turn this off - this.marcDeliminatedLCSHMode = false - this.marcDeliminatedLCSHModeSearching = false - this.marcDeliminatedLCSHModeTimeout = null - this.marcDeliminatedLCSHModeResults = [] - - this.authorityLookup = this.searchValue.trim() - this.searchValue = this.searchValue.trim() + // we're opening the subject builder, turn this off + this.marcDeliminatedLCSHMode = false + this.marcDeliminatedLCSHModeSearching = false + this.marcDeliminatedLCSHModeTimeout = null + this.marcDeliminatedLCSHModeResults = [] + + this.authorityLookup = this.searchValue.trim() + this.searchValue = this.searchValue.trim() let selection = document.getElementById(this.guid) let selected = selection.options[selection.selectedIndex].value this.searchType = selected @@ -674,8 +678,6 @@ export default { this.$nextTick(() => { this.$refs.subjectEditorModal.focusInput() }) - - } diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index bd25e7e1..d88845c3 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -36,6 +36,7 @@ const utilsNetwork = { "controllerHierarchicalGeographicLCSH": new AbortController(), "controllerGeographicLCSH": new AbortController(), "controllerGeographicLCNAF": new AbortController(), + "controllerCyak": new AbortController(), }, subjectSearchActive: false, @@ -1250,7 +1251,7 @@ const utilsNetwork = { * @return {subjectLinkModeResolveLCSHResult} - A {@link subjectLinkModeResolveLCSHResult} result */ - subjectLinkModeResolveLCSH: async function(lcsh){ + subjectLinkModeResolveLCSH: async function(lcsh, searchType=null){ if (this.subjectSearchActive){ for (let controller in this.controllers){ this.controllers[controller].abort() @@ -1421,6 +1422,7 @@ const utilsNetwork = { searchValue: complexHeading } + for (let heading of headings){ let foundHeading = false @@ -1454,6 +1456,10 @@ const utilsNetwork = { let subjectUrlGeographicLCSH = useConfigStore().lookupConfig['http://id.loc.gov/authorities/subjects'].modes[0]['LCSH All'].url.replace('',searchVal).replace('&count=25','&count=5').replace("", "1")+'&rdftype=Geographic&memberOf=http://id.loc.gov/authorities/subjects/collection_Subdivisions' let subjectUrlGeographicLCNAF = useConfigStore().lookupConfig['http://preprod.id.loc.gov/authorities/names'].modes[0]['NAF All'].url.replace('',searchVal).replace('&count=25','&count=5').replace("", "1")+'&rdftype=Geographic&memberOf=http://id.loc.gov/authorities/subjects/collection_Subdivisions' + let subjectChildren = useConfigStore().lookupConfig['http://id.loc.gov/authorities/childrensSubjects'].modes[0]['LCSHAC All'].url.replace('',searchVal).replace('&count=25','&count=5').replace("", "1") + let childrenSubjectSubdivision = useConfigStore().lookupConfig['http://id.loc.gov/authorities/childrensSubjects'].modes[0]['LCSHAC All'].url.replace('',searchVal).replace('&count=25','&count=4').replace("", "1")+'&memberOf=http://id.loc.gov/authorities/subjects/collection_Subdivisions' + + searchVal = decodeURIComponent(searchVal) // console.log('subjectUrlSimpleSubdivison',subjectUrlSimpleSubdivison) @@ -1536,6 +1542,20 @@ const utilsNetwork = { signal: this.controllers.controllerHubsAnchored.signal } + let searchPayloadChildren = { + processor: 'lcAuthorities', + url: [subjectChildren], + searchValue: searchVal, + signal: this.controllers.controllerCyak.signal + } + + let searchPayloadChildrenSub = { + processor: 'lcAuthorities', + url: [childrenSubjectSubdivision], + searchValue: searchVal, + signal: this.controllers.controllerCyak.signal + } + let resultsNames =[] let resultsNamesSubdivision =[] @@ -1552,6 +1572,9 @@ const utilsNetwork = { let resultsGeographicLCNAF =[] let resultsGeographicLCSH =[] + let resultsChildren = [] + let resultsChildrenSubDiv = [] + let resultsGenre=[] @@ -1559,7 +1582,7 @@ const utilsNetwork = { // if it is a primary heading then we need to search LCNAF, HUBS, WORKS, and simple subjects, and do the whole thing with complex subjects if (heading.primary){ // resultsNames = await this.searchComplex(searchPayloadNames) - [resultsNames, resultsNamesSubdivision, resultsSubjectsSimple, resultsPayloadSubjectsSimpleSubdivision, resultsSubjectsComplex, resultsHierarchicalGeographic,resultsHierarchicalGeographicLCSH, resultsWorksAnchored, resultsHubsAnchored] = await Promise.all([ + [resultsNames, resultsNamesSubdivision, resultsSubjectsSimple, resultsPayloadSubjectsSimpleSubdivision, resultsSubjectsComplex, resultsHierarchicalGeographic,resultsHierarchicalGeographicLCSH, resultsWorksAnchored, resultsHubsAnchored, resultsChildren, resultsChildrenSubDiv] = await Promise.all([ this.searchComplex(searchPayloadNames), this.searchComplex(searchPayloadNamesSubdivision), this.searchComplex(searchPayloadSubjectsSimple), @@ -1568,9 +1591,14 @@ const utilsNetwork = { this.searchComplex(searchPayloadHierarchicalGeographic), this.searchComplex(searchPayloadHierarchicalGeographicLCSH), this.searchComplex(searchPayloadWorksAnchored), - this.searchComplex(searchPayloadHubsAnchored) + this.searchComplex(searchPayloadHubsAnchored), + this.searchComplex(searchPayloadChildren), + this.searchComplex(searchPayloadChildrenSub), ]); + console.info("searchPayloadChildren: ", searchPayloadChildren) + console.info("resultsChildren: ", resultsChildren) + // console.log("searchPayloadSubjectsSimpleSubdivision",searchPayloadSubjectsSimpleSubdivision) // console.log("resultsPayloadSubjectsSimpleSubdivision",resultsPayloadSubjectsSimpleSubdivision) @@ -1584,6 +1612,8 @@ const utilsNetwork = { resultsWorksAnchored = resultsWorksAnchored.filter((r)=>{ return (!r.literal) }) resultsHubsAnchored = resultsHubsAnchored.filter((r)=>{ return (!r.literal) }) resultsPayloadSubjectsSimpleSubdivision = resultsPayloadSubjectsSimpleSubdivision.filter((r)=>{ return (!r.literal) }) + resultsChildren = resultsChildren.filter((r)=>{ return (!r.literal) }) + resultsChildrenSubDiv = resultsChildrenSubDiv.filter((r)=>{ return (!r.literal) }) // console.log("Yeeth") // console.log("resultsNames",resultsNames) @@ -1635,20 +1665,38 @@ const utilsNetwork = { // console.log("resultsSubjectsSimple",resultsSubjectsSimple) - // if not see if we matched a simple subject that is not a subdivison - if (resultsSubjectsSimple.length>0){ - for (let r of resultsSubjectsSimple){ - // lower case, remove end space, make double whitespace into one and remove any punctuation - if (heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.label.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '') || heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.vlabel.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '')){ - result.resultType = 'PRECOORD-LCSH' - if (!result.hit){ result.hit = [] } - r.heading = heading - result.hit.push(r) - foundHeading = true - break + // see if there is a match for CYAK + if (searchType.includes(":Topic:Childrens:")){ + if (resultsChildren.length>0){ + for (let r of resultsChildren){ + // lower case, remove end space, make double whitespace into one and remove any punctuation + if (heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.label.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '') || heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.vlabel.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '')){ + result.resultType = 'PRECOORD-LCSH' + if (!result.hit){ result.hit = [] } + r.heading = heading + result.hit.push(r) + foundHeading = true + break + } } + if (foundHeading){ continue } + } + } else { + // if not see if we matched a simple subject that is not a subdivison + if (resultsSubjectsSimple.length>0){ + for (let r of resultsSubjectsSimple){ + // lower case, remove end space, make double whitespace into one and remove any punctuation + if (heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.label.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '') || heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.vlabel.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '')){ + result.resultType = 'PRECOORD-LCSH' + if (!result.hit){ result.hit = [] } + r.heading = heading + result.hit.push(r) + foundHeading = true + break + } + } + if (foundHeading){ continue } } - if (foundHeading){ continue } } // see if we matched a LCNAF name as primary compontant @@ -1830,6 +1878,21 @@ const utilsNetwork = { if (foundHeading){ continue } } + //CYAK subdivisions + if (resultsPayloadSubjectsSimpleSubdivision.length>0 && searchType.includes(":Topic:Childrens:")){ + for (let r of resultsChildrenSubDiv){ + // lower case, remove end space, make double whitespace into one and remove any punctuation + if (heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.label.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '')){ + r.heading = heading + result.hit.push(r) + + + foundHeading = true + } + } + if (foundHeading){ continue } + + if (!foundHeading){ // wasn't found, we need to make it a literal result.hit.push( { @@ -1958,6 +2021,9 @@ const utilsNetwork = { // console.log("result",result) this.subjectSearchActive = false + + console.info("result: ", result) + return result }, From aeace28c74b01f48422b008c074e3e32d296ae54 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Tue, 3 Dec 2024 08:08:20 -0500 Subject: [PATCH 2/4] Add CYAK subdivisions --- src/components/panels/edit/modals/SubjectEditor.vue | 2 ++ src/lib/utils_network.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/panels/edit/modals/SubjectEditor.vue b/src/components/panels/edit/modals/SubjectEditor.vue index 6b9937f6..1a9cf690 100644 --- a/src/components/panels/edit/modals/SubjectEditor.vue +++ b/src/components/panels/edit/modals/SubjectEditor.vue @@ -2599,6 +2599,8 @@ updated: function() { // preselect the search type, if a children's subject if (this.searchType.includes("Childrens")){ this.searchMode = "CHILD" + } else { + this.searchMode = "LCSHNAF" } // this was opened from an existing subject let profileData = this.profileData diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index d88845c3..a7a12fbf 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -1879,7 +1879,7 @@ const utilsNetwork = { } //CYAK subdivisions - if (resultsPayloadSubjectsSimpleSubdivision.length>0 && searchType.includes(":Topic:Childrens:")){ + if (resultsChildrenSubDiv.length>0 && searchType.includes(":Topic:Childrens:")){ for (let r of resultsChildrenSubDiv){ // lower case, remove end space, make double whitespace into one and remove any punctuation if (heading.label.toLowerCase().trim().replace(/\s+/g,' ').replace(/[\p{P}$+<=>^`|~]/gu, '') == r.label.toLowerCase().trim().replace(/[\p{P}$+<=>^`|~]/gu, '')){ @@ -1891,6 +1891,7 @@ const utilsNetwork = { } } if (foundHeading){ continue } + } if (!foundHeading){ From 4ab047176d75c556f7efcb33eb367efdedd83618 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Tue, 3 Dec 2024 08:12:15 -0500 Subject: [PATCH 3/4] version++ --- src/stores/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/config.js b/src/stores/config.js index 313601a1..d2887e72 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -7,7 +7,7 @@ export const useConfigStore = defineStore('config', { versionMajor: 0, versionMinor: 16, - versionPatch: 23, + versionPatch: 24, regionUrls: { From d589e3a83618be7f1985ab25f1e9be6761c096ce Mon Sep 17 00:00:00 2001 From: f-osorio Date: Tue, 3 Dec 2024 09:35:05 -0500 Subject: [PATCH 4/4] Clean console --- src/lib/utils_network.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index a7a12fbf..d750f771 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -1596,9 +1596,6 @@ const utilsNetwork = { this.searchComplex(searchPayloadChildrenSub), ]); - console.info("searchPayloadChildren: ", searchPayloadChildren) - console.info("resultsChildren: ", resultsChildren) - // console.log("searchPayloadSubjectsSimpleSubdivision",searchPayloadSubjectsSimpleSubdivision) // console.log("resultsPayloadSubjectsSimpleSubdivision",resultsPayloadSubjectsSimpleSubdivision) @@ -2023,8 +2020,6 @@ const utilsNetwork = { this.subjectSearchActive = false - console.info("result: ", result) - return result },