diff --git a/src/components/panels/edit/fields/LookupSimple.vue b/src/components/panels/edit/fields/LookupSimple.vue index 19010a3e..409178b1 100644 --- a/src/components/panels/edit/fields/LookupSimple.vue +++ b/src/components/panels/edit/fields/LookupSimple.vue @@ -459,7 +459,7 @@ export default { }, - focused: function(){ + focused: async function(){ // set the state active field this.activeField = this.myGuid @@ -473,14 +473,17 @@ export default { } this.uri = this.structure.valueConstraint.useValuesFrom[0] - utilsNetwork.loadSimpleLookup(this.uri) - - + if (!this.uri.includes("suggest2")){ + utilsNetwork.loadSimpleLookup(this.uri) + } else { + let uriParts = this.uri.split("/suggest2?q=") + let results = await utilsNetwork.loadSimpleLookupKeyword(uriParts[0], uriParts[1]) + utilsNetwork.lookupLibrary[this.uri] = results + } }, actionButtonCommand: function(cmd){ this.$refs.input.focus() - }, // Takes the list of values from this lookup uri and filters it based on the input @@ -538,7 +541,6 @@ export default { } Object.keys(utilsNetwork.lookupLibrary[this.uri+addKeyword]).forEach((v)=>{ - // the list has a special key metdata that contains more info if (v==='metadata'){return false} // no filter yet show first 25 @@ -594,9 +596,6 @@ export default { if (!recursive){ - - - if (this.uri.includes('id.loc.gov/vocabulary/')){ if (this.activeFilter.length>2){ @@ -712,8 +711,6 @@ export default { }, keyDownEvent: function(event, reposLeft){ - - if (event && event.keyCode == 220 && event.ctrlKey == true){ let id = `action-button-${event.target.dataset.guid}` document.getElementById(id).click() @@ -727,25 +724,15 @@ export default { if (reposLeft){ - this.findSelectListTime = window.setInterval(()=>{ - if (this.$refs.selectlist && this.$refs.selectlist.style){ window.clearTimeout(this.findSelectListTime) var rect = event.target.getBoundingClientRect(); this.$refs.selectlist.style.left = rect.left + 'px' - } - - - - },100) - - } - this.activeValue = event.target.value if (event && event.key && this.displayAutocomplete == true && (event.key==='ArrowUp' || event.key==='ArrowDown')){ @@ -876,19 +863,13 @@ export default { event.preventDefault() - }else if (event.target.value == ''){ - - + } else if (event.target.value == '') { this.activeFilter = '' this.activeValue = '' this.activeSelect = '' this.displayAutocomplete=false - - - } - if (this.displayAutocomplete){ // this.$store.dispatch("disableMacroNav") }else{ diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index 430adb4d..2f1ab89c 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -56,7 +56,7 @@ const utilsNetwork = { let url = uri // TODO more checks here - if (!uri.includes('.json')){ + if (!uri.includes('.json') && !uri.includes("suggest2")){ url = url + '.json' } @@ -83,7 +83,6 @@ const utilsNetwork = { */ simpleLookupProcess: function(data,parentURI){ - let dataProcessed = { // all the URIs will live here but also the metadata obj about the uris @@ -100,7 +99,6 @@ const utilsNetwork = { // something that has the parent URI data.forEach((d)=>{ - let label = null let labelData = null // it has a URI and that URI is not the parent uri // assume it is one of the values we want @@ -128,6 +126,28 @@ const utilsNetwork = { label = labelWithCode } }) + } else if (parentURI.includes("suggest2") && d.uri && d.aLabel) { + this.possibleLabelURIs.forEach((result)=>{ + // if it has this label URI and does not yet have a label + if ( !dataProcessed[result.uri] ){ + + label = d.aLabel + + let labelWithCode = [] + // build the metadata for each item that will go along it with structured fields + let metadata = {uri:d.uri, label: [], code: [], displayLabel: [] } + label.forEach((l)=>{ + labelWithCode.push(`${l} (${d.uri.split('/').pop()})`) + metadata.displayLabel.push(`${l.trim()} (${d.uri.split('/').pop()})`) + + metadata.label.push(l.trim()) + metadata.code.push(d.uri.split('/').pop()) + + }) + labelData = metadata + label = labelWithCode + } + }) }else if (d['http://id.loc.gov/ontologies/RecordInfo#recordStatus']){ // this is just a record info blank node, skip it return false @@ -190,7 +210,6 @@ const utilsNetwork = { if (r.hits && r.hits.length==0){ url = `${uri}/suggest2/?q=${keyword}&count=25&searchtype=keyword` r = await this.fetchSimpleLookup(url) - } @@ -252,7 +271,6 @@ const utilsNetwork = { }catch(err){ //alert("There was an error retriving the record from:",url) console.error("There was an error retriving the record from ", url, ". Likely from the search being aborted because the user was typing."); - return false // Handle errors here } diff --git a/src/stores/config.js b/src/stores/config.js index 3e9b17ab..d9385bac 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -7,8 +7,7 @@ export const useConfigStore = defineStore('config', { versionMajor: 0, versionMinor: 17, - versionPatch: 0, - + versionPatch: 1, regionUrls: {