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/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 bd25e7e1..d750f771 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,7 +1591,9 @@ const utilsNetwork = { this.searchComplex(searchPayloadHierarchicalGeographic), this.searchComplex(searchPayloadHierarchicalGeographicLCSH), this.searchComplex(searchPayloadWorksAnchored), - this.searchComplex(searchPayloadHubsAnchored) + this.searchComplex(searchPayloadHubsAnchored), + this.searchComplex(searchPayloadChildren), + this.searchComplex(searchPayloadChildrenSub), ]); // console.log("searchPayloadSubjectsSimpleSubdivision",searchPayloadSubjectsSimpleSubdivision) @@ -1584,6 +1609,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 +1662,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 +1875,22 @@ const utilsNetwork = { if (foundHeading){ continue } } + //CYAK subdivisions + 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, '')){ + 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 +2019,7 @@ const utilsNetwork = { // console.log("result",result) this.subjectSearchActive = false + return result }, 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: {