diff --git a/src/components/panels/edit/modals/SubjectEditor.vue b/src/components/panels/edit/modals/SubjectEditor.vue index bef1afc4..f62e6a53 100644 --- a/src/components/panels/edit/modals/SubjectEditor.vue +++ b/src/components/panels/edit/modals/SubjectEditor.vue @@ -86,9 +86,9 @@ - - - + + + @@ -98,7 +98,7 @@
{{activeSearch}}
- + Names
{{name.suggestLabel.substring(0,41)}}... {{name.suggestLabel}} @@ -107,15 +107,32 @@
+
+ Subjects (Complex)
{{subjectC.suggestLabel}}

+ Subjects (Simple)
{{subject.suggestLabel}}{{subject.label}} [Literal]
+ +
+
+ Geo SubDivisions +
{{subject.suggestLabel}} + {{subject.label}} [Literal]
+
+ @@ -861,7 +878,6 @@ export default { that.searchResults = await utilsNetwork.subjectSearch(searchString,searchStringFull,that.searchMode) - // if they clicked around while it was doing this lookup bail out // if (that.activeSearchInterrupted){ @@ -886,7 +902,6 @@ export default { s.label = s.label.replaceAll('-','‑') } - for (let s of that.searchResults.subjectsComplex){ s.labelOrginal = s.label s.complex=true @@ -934,6 +949,12 @@ export default { s.label = s.label.replaceAll('-','‑') } + for (let s of that.searchResults.hierarchicalGeographicAll){ + s.labelOrginal = s.label + s.hierarchicalGeographic=true + s.label = s.label.replaceAll('-','‑') + } + if (that.searchResults.hierarchicalGeographic.length>0 && that.searchResults.subjectsComplex.length==0){ that.searchResults.subjectsComplex = that.searchResults.hierarchicalGeographic @@ -957,7 +978,9 @@ export default { } - + for (let x in that.searchResults.hierarchicalGeographicAll){ + that.pickLookup[parseInt(x)+parseInt(that.searchResults.subjectsComplex.length)+parseInt(that.searchResults.subjectsSimple.length)] = that.searchResults.hierarchicalGeographicAll[x] + } @@ -1125,6 +1148,8 @@ export default { clearSelected: function(){ this.pickLookup[this.pickCurrent].picked = false this.pickCurrent = null + + this.$refs.subjectInput.focus() }, loadContext: async function(pickPostion){ @@ -1143,6 +1168,7 @@ export default { this.localContextCache[this.contextData.uri] = JSON.parse(JSON.stringify(this.contextData)) } + // this.$store.dispatch("fetchContext", { self: this, searchPayload: this.pickLookup[this.pickPostion].uri }).then(() => { // // keep a local copy of it for looking up subject type @@ -1161,12 +1187,20 @@ export default { this.getContext() } + // if (this.pickLookup[this.pickCurrent].picked = true){ + // return true + // } + + // lock in the selected position + this.pickCurrent = this.pickPostion + if (this.pickLookup[this.pickPostion].complex){ - // if it is a complex authorized heading then just replace the whole things with it - this.subjectString = this.pickLookup[this.pickPostion].label this.activeComponentIndex = 0 - this.componetLookup = {} + + // if it is a complex authorized heading and there's nothing else then just replace the whole things with it + this.subjectString = this.pickLookup[this.pickPostion].label + this.componetLookup[this.activeComponentIndex] = {} this.componetLookup[this.activeComponentIndex][this.pickLookup[this.pickPostion].label] = this.pickLookup[this.pickPostion] for (let k in this.pickLookup){ @@ -1196,17 +1230,36 @@ export default { let splitString = this.subjectString.split('--') // replace the string with what we selected - splitString[this.activeComponentIndex] = this.pickLookup[this.pickPostion].label.replaceAll('-','‑') + // if the incoming term is complex, pop the elements from splitstring that are part of it + /* + Without this searching `New York (State)--new yor` and selecting `New York (State)--New York` + will result in `New York (State)--New York (State)--New York` + */ + if (this.pickLookup[this.pickPostion].label.includes("‑‑")){ + // without this it's possible to keep selecting a term and delete parts of the heading that should remain + if (this.pickLookup[this.pickPostion].label.split("‑‑").length < splitString.length){ + let numPieces = this.pickLookup[this.pickPostion].label.split("‑‑").length-1 // how many things need to be removed minus the 1 to keep + let removalStart = splitString.length-1-numPieces + let updated = splitString.splice(removalStart, numPieces) + this.activeComponentIndex = this.activeComponentIndex - numPieces // update the activeComponentIndex + } else if (this.pickLookup[this.pickPostion].label.split("‑‑").length == splitString.length){ + //if the selection has as many pieces as the input, replace the whole thing + splitString = this.pickLookup[this.pickPostion].label + this.activeComponentIndex = 0 + } + } - this.subjectString = splitString.join('--') - + try{ + this.subjectString = splitString.join('--') + } catch(err){ + this.subjectString = splitString + } if (!this.componetLookup[this.activeComponentIndex]){ this.componetLookup[this.activeComponentIndex]= {} } - this.componetLookup[this.activeComponentIndex][this.pickLookup[this.pickPostion].label.replaceAll('-','‑')] = this.pickLookup[this.pickPostion] for (let k in this.pickLookup){ @@ -1221,10 +1274,10 @@ export default { if (update == true){ this.subjectStringChanged() } - - } + this.$refs.subjectInput.focus() + }, @@ -1235,7 +1288,10 @@ export default { if (parseInt(this.pickPostion) <= this.searchResults.names.length*-1){ return false } + + this.pickCurrent = null //allows keyboard selection this.loadContext(parseInt(this.pickPostion) - 1 ) + this.pickCurrent = parseInt(this.pickPostion) event.preventDefault() return false }else if (event.key == 'ArrowDown'){ @@ -1244,32 +1300,28 @@ export default { return false } - + this.pickCurrent = null //allows keyboard selection this.loadContext(parseInt(this.pickPostion) + 1 ) + this.pickCurrent = parseInt(this.pickPostion) event.preventDefault() return false }else if (event.key == 'Enter'){ - - - if (event.shiftKey){ this.add() return } - - this.selectContext() }else if (event.ctrlKey && event.key == "1"){ this.searchModeSwitch("LCSHNAF") - }else if (event.ctrlKey && event.key == "2"){ - - this.searchModeSwitch("GEO") - - }else if (event.ctrlKey && event.key == "3"){ + } + // else if (event.ctrlKey && event.key == "2"){ + // this.searchModeSwitch("GEO") + // } + else if (event.ctrlKey && event.key == "2"){ this.searchModeSwitch("WORKS") @@ -1293,7 +1345,6 @@ export default { } - let start = event.target.selectionStart let end = event.target.selectionEnd console.log(this.subjectString.substring(0,start),'|',this.subjectString.substring(end,this.subjectString.length)) @@ -1391,7 +1442,6 @@ export default { }, - //TODO: if it's a literal, there shouldn't be a thesaurus subjectStringChanged: async function(event){ this.validateOkayToAdd() @@ -1459,7 +1509,6 @@ export default { for (let ss of subjectStringSplit){ // check the lookup to see if we have the data for this label - let uri = null let type = null let literal = null @@ -1774,8 +1823,6 @@ export default { if (typeof userValue == "string"){ - - // they sometimes come in with '.' at the end of the authorized form if (userValue.slice(-1)=='.'){ userValue=userValue.slice(0,-1) diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index b173c245..d7352bc0 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -290,10 +290,10 @@ const utilsNetwork = { // console.log("searchPayload",searchPayload) - let returnUrls = useConfigStore().returnUrls let urlTemplate = searchPayload.url + let searchValue = searchPayload.searchValue console.log("######################################") console.log("url ", urlTemplate) @@ -337,8 +337,36 @@ const utilsNetwork = { url = url.replace('q=?','q=') } + //break up complex (contains "--") headings to search against the whole term, and the last -- section of it + // this is for headings like "New York (State)--New York" where the second "New York" doesn't exist + // as a heading by itself + let r = null + let partial = null + let all = null + try{ + if (searchValue.includes("--")) { + let pieces = searchValue.split("--") + if (pieces.length > 2){ + let last = pieces[pieces.length-1] + let pen = pieces[pieces.length-2] + let value = pen + "--" + last + partial = await this.fetchSimpleLookup(url.replace(searchValue, value)) + } + all = await this.fetchSimpleLookup(url) - let r = await this.fetchSimpleLookup(url) + if (partial != null){ + all.count += partial.count + all.hits = all.hits.concat(partial.hits) + } + r = all + + } else { + r = await this.fetchSimpleLookup(url) + } + } catch(error) { + console.log("error: ", error) + } + //r = await this.fetchSimpleLookup(url) //Config only allows 25 results, this will add something to the results // to let the user know there are more names. @@ -1444,7 +1472,6 @@ const utilsNetwork = { let resultsGenre=[] - // 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) @@ -1913,6 +1940,7 @@ const utilsNetwork = { console.log(useConfigStore().lookupConfig) let namesUrl = useConfigStore().lookupConfig['http://preprod.id.loc.gov/authorities/names'].modes[0]['NAF All'].url.replace('',searchVal).replace('&count=25','&count=4').replace("", "1") + let subjectUrlComplex = useConfigStore().lookupConfig['http://id.loc.gov/authorities/subjects'].modes[0]['LCSH All'].url.replace('',complexVal).replace('&count=25','&count=5').replace("", "1")+'&rdftype=ComplexType' let subjectUrlSimple = useConfigStore().lookupConfig['http://id.loc.gov/authorities/subjects'].modes[0]['LCSH All'].url.replace('',searchVal).replace('&count=25','&count=4').replace("", "1")+'&rdftype=SimpleType' @@ -1929,7 +1957,7 @@ const utilsNetwork = { let subjectUrlHierarchicalGeographic = useConfigStore().lookupConfig['HierarchicalGeographic'].modes[0]['All'].url.replace('',searchValHierarchicalGeographic).replace('&count=25','&count=4').replace("", "1") - + let HierarchicalGeographicAll = useConfigStore().lookupConfig['HierarchicalGeographicAll'].modes[0]['All'].url.replace('',complexVal).replace('&count=25','&count=4').replace("", "1") if (mode == 'GEO'){ subjectUrlHierarchicalGeographic = subjectUrlHierarchicalGeographic.replace('&count=4','&count=12').replace("", "1") @@ -1962,6 +1990,11 @@ const utilsNetwork = { searchValue: searchValHierarchicalGeographic } + let searchPayloadHierarchicalGeographicAll = { + processor: 'lcAuthorities', + url: [HierarchicalGeographicAll], + searchValue: complexVal + } let searchPayloadWorksAnchored = { processor: 'lcAuthorities', @@ -1993,17 +2026,19 @@ const utilsNetwork = { let resultsSubjectsSimple=[] let resultsSubjectsComplex=[] let resultsHierarchicalGeographic=[] + let resultsHierarchicalGeographicAll=[] let resultsWorksAnchored=[] let resultsWorksKeyword=[] let resultsHubsAnchored=[] let resultsHubsKeyword=[] if (mode == "LCSHNAF"){ - [resultsNames, resultsSubjectsSimple, resultsSubjectsComplex, resultsHierarchicalGeographic] = await Promise.all([ + [resultsNames, resultsSubjectsSimple, resultsSubjectsComplex, resultsHierarchicalGeographic, resultsHierarchicalGeographicAll] = await Promise.all([ this.searchComplex(searchPayloadNames), this.searchComplex(searchPayloadSubjectsSimple), this.searchComplex(searchPayloadSubjectsComplex), - this.searchComplex(searchPayloadHierarchicalGeographic) + this.searchComplex(searchPayloadHierarchicalGeographic), + this.searchComplex(searchPayloadHierarchicalGeographicAll) ]); }else if (mode == "GEO"){ @@ -2035,6 +2070,9 @@ const utilsNetwork = { if (resultsNames.length>0){ resultsNames.pop() } + if (resultsHierarchicalGeographicAll.length > 0){ + resultsHierarchicalGeographicAll.pop() + } if (resultsSubjectsComplex.length>0){ resultsSubjectsComplex.pop() } @@ -2079,14 +2117,24 @@ const utilsNetwork = { resultsSubjectsSimple = resultsHubsAnchored resultsSubjectsComplex = resultsHubsKeyword } + + // hierarchicalGeographicAll can sometimes have results found in subjectsComplex + // Remove the dupes + const hierarchicalGeographicURIs = resultsHierarchicalGeographic.map((item) => item.uri) + const subjectSimpleURIs = resultsSubjectsSimple.map((item) => item.uri) + const subjectComplexURIs = resultsSubjectsComplex.map((item) => item.uri) + + const subjectURIs = subjectComplexURIs.concat(subjectSimpleURIs).concat(hierarchicalGeographicURIs) + const resultsHierarchicalGeographicAllFiltered = resultsHierarchicalGeographicAll.filter((subj) => !subjectURIs.includes(subj.uri)) + let results = { 'subjectsSimple': resultsSubjectsSimple, 'subjectsComplex': resultsSubjectsComplex, 'names':resultsNames, - 'hierarchicalGeographic': resultsHierarchicalGeographic + 'hierarchicalGeographic': resultsHierarchicalGeographic, + 'hierarchicalGeographicAll': resultsHierarchicalGeographicAllFiltered } - return results }, diff --git a/src/stores/profile.js b/src/stores/profile.js index 908e8bfa..30984b5c 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -1399,7 +1399,7 @@ export const useProfileStore = defineStore('profile', { // console.log(JSON.stringify(pt,null,2)) // let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid) - + if (blankNode === false){ // create the path to the blank node let buildBlankNodeResult @@ -2981,7 +2981,11 @@ export const useProfileStore = defineStore('profile', { this.activeProfile.rt[pt.parentId].pt[pt.id].deleted = true }else{ - + console.info("this.activeProfile: ", this.activeProfile) + console.info("this.activeProfile.rt: ", this.activeProfile.rt) + console.info("this.activeProfile.rt[pt.parentId]: ", this.activeProfile.rt[pt.parentId]) + console.info("pt.id: ", pt.id) + console.info("Trying to delete: ", this.activeProfile.rt[pt.parentId].pt[pt.id].userValue) for (let key in this.activeProfile.rt[pt.parentId].pt[pt.id].userValue){ if (!key.startsWith('@')){ delete this.activeProfile.rt[pt.parentId].pt[pt.id].userValue[key]