Skip to content

Commit

Permalink
Merge pull request #112 from lcnetdev/bfp-255-6xx-multiple-auth-label…
Browse files Browse the repository at this point in the history
…-values

update subjects to support multiple 2.8 multiple auth labels and marc…
  • Loading branch information
thisismattmiller authored Nov 1, 2024
2 parents cda6786 + d660743 commit 97612a0
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 49 deletions.
11 changes: 5 additions & 6 deletions src/components/panels/edit/modals/NonLatinAgentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@
window.setTimeout(()=>{
console.log(this.profileStore)
console.log(this.profileStore.returnAllNonLatinLiterals())
this.nonLatinAgents = this.profileStore.returnAllNonLatinAgentOptions()
console.log(this.nonLatinAgents)
for (let key in this.nonLatinAgents){
console.log(key)
if (this.nonLatinScriptAgents[key]){
this.localMap[key] = this.nonLatinScriptAgents[key]
}else{
Expand All @@ -164,7 +162,7 @@
}
},1000)
},100)
Expand Down Expand Up @@ -212,6 +210,7 @@
<div v-if="Object.keys(nonLatinAgents).length == 0">No Non-Latin Agents/Headings Found.</div>

<div v-for="nlA in nonLatinAgents" class="non-latin-access-point">
<div style="color: #636363;">{{ nlA.propertyURI.replace("http://id.loc.gov/ontologies/bibframe/",'bf:') }}</div>
<div>{{ nlA.nonLatin }}</div>
Use script to build access points:<select @change="scriptChange" :data-key="nlA['@guid']" v-model="localMap[nlA['@guid']]">
<option v-for="s in nlA.scripts">{{s}}</option>
Expand Down
110 changes: 78 additions & 32 deletions src/components/panels/edit/modals/SubjectEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@
<h3><span class="modal-context-icon simptip-position-top" :data-tooltip="'Type: ' + contextData.type"><AuthTypeIcon v-if="contextData.type" :type="contextData.type"></AuthTypeIcon></span>{{contextData.title}}</h3>
<div class="modal-context-data-title">{{contextData.type}}</div>
<a style="color:#2c3e50" :href="contextData.uri" target="_blank" v-if="contextData.literal != true">view on id.loc.gov</a>

<div v-if="contextData.nonLatinTitle && contextData.nonLatinTitle.length>0">
<div class="modal-context-data-title">Non-Latin Auth Label:</div>
<ul>
<li class="modal-context-data-li" v-for="(v,idx) in contextData.nonLatinTitle" v-bind:key="'var' + idx">{{v['@value']}}{{ v['@language'] }}</li>
</ul>
</div>

<div v-if="contextData.variant && contextData.variant.length>0">
<div class="modal-context-data-title">Variants:</div>
<ul>
Expand Down Expand Up @@ -899,20 +907,25 @@ methods: {
let uri = null
let type = null
let literal = null
let marcKey = null
let marcKey = null
let nonLatinLabel = null
let nonLatinMarkKey = null
if (this.componetLookup[id] && this.componetLookup[id][ss]){
// Zero out for geographic, because the terms won't be linked when reopengin
// TODO: revisit this
if (this.componetLookup[id][ss]["type"] == "madsrdf:Geographic"){
// Zero out for geographic, because the terms won't be linked when reopengin
// TODO: revisit this
if (this.componetLookup[id][ss]["type"] == "madsrdf:Geographic"){
literal = this.componetLookup[id][ss].literal = false
uri = this.componetLookup[id][ss].uri = null
}
literal = this.componetLookup[id][ss].literal
uri = this.componetLookup[id][ss].uri
marcKey = this.componetLookup[id][ss].marcKey
marcKey = this.componetLookup[id][ss].marcKey
nonLatinLabel = this.componetLookup[id][ss].nonLatinTitle
nonLatinMarkKey = this.componetLookup[id][ss].nonLatinMarcKey
}
if (this.typeLookup[id]){
Expand All @@ -928,7 +941,9 @@ methods: {
literal:literal,
posStart: activePosStart,
posEnd: activePosStart + ss.length,
marcKey: marcKey
marcKey: marcKey,
nonLatinLabel:nonLatinLabel,
nonLatinMarkKey:nonLatinMarkKey,
})
// increase the start length by the length of the string and also add 2 for the "--"
Expand Down Expand Up @@ -1435,12 +1450,40 @@ methods: {
this.contextRequestInProgress = true
this.contextData = await utilsNetwork.returnContext(this.pickLookup[this.pickPostion].uri)
//save the marcKey
if (this.contextData.nodeMap.marcKey){
this.pickLookup[this.pickPostion].marcKey = this.contextData.nodeMap.marcKey[0]
}
this.contextRequestInProgress = false
},
// for backwards compability
if (this.contextData.nodeMap.marcKey && this.contextData.nodeMap.marcKey[0]){
this.pickLookup[this.pickPostion].marcKey = this.contextData.nodeMap.marcKey[0]
}
// we will modify our local context data here to make things easier
if (Array.isArray(this.contextData.title)){
// first grab the non-latin auth labels
this.contextData.nonLatinTitle = JSON.parse(JSON.stringify(this.contextData.title.filter((v)=>{ return (v['@language']) })))
this.pickLookup[this.pickPostion].nonLatinTitle = this.contextData.nonLatinTitle
// return the first label with no language tag
this.contextData.title = this.contextData.title.filter((v)=>{ return (!v['@language']) })[0]
if (this.contextData.title && this.contextData.title['@value']){
this.contextData.title = this.contextData.title['@value']
}
}
//save the marcKey
if (Array.isArray(this.contextData.marcKey)){
// first grab the non-latin auth labels
this.contextData.nonLatinMarcKey = JSON.parse(JSON.stringify(this.contextData.marcKey.filter((v)=>{ return (v['@language']) })))
this.pickLookup[this.pickPostion].nonLatinMarcKey = this.contextData.nonLatinMarcKey
// return the first label with no language tag
this.contextData.marcKey = this.contextData.marcKey.filter((v)=>{ return (!v['@language']) })[0]
if (this.contextData.marcKey && this.contextData.marcKey['@value']){
this.contextData.marcKey = this.contextData.marcKey['@value']
this.pickLookup[this.pickPostion].marcKey = this.contextData.marcKey
}
}
this.contextRequestInProgress = false
},
/** Clear the current selection so that hovering will update the preview again */
clearSelected: function(){
Expand Down Expand Up @@ -1529,7 +1572,7 @@ methods: {
}
}else{
console.log('1',JSON.parse(JSON.stringify(this.componetLookup)))
// console.log('1',JSON.parse(JSON.stringify(this.componetLookup)))
// take the subject string and split
let splitString = this.subjectString.split('--')
Expand All @@ -1555,7 +1598,7 @@ methods: {
this.pickLookup[this.pickPostion].picked=true
console.log('2',JSON.parse(JSON.stringify(this.componetLookup)))
// console.log('2',JSON.parse(JSON.stringify(this.componetLookup)))
//Need something to prevent recursion
if (update == true){
this.subjectStringChanged()
Expand Down Expand Up @@ -1619,7 +1662,7 @@ methods: {
}else if (this.searchMode == 'GEO' && event.key == "-"){
if (this.components.length>0){
let lastC = this.components[this.components.length-1]
console.log(lastC)
// if the last component has a URI then it was just selected
// so we are not in the middle of a indirect heading, we are about to type it
// so let them put in normal --
Expand All @@ -1637,14 +1680,14 @@ methods: {
let start = event.target.selectionStart
let end = event.target.selectionEnd
console.log(this.subjectString.substring(0,start),'|',this.subjectString.substring(end,this.subjectString.length))
// console.log(this.subjectString.substring(0,start),'|',this.subjectString.substring(end,this.subjectString.length))
this.subjectString = this.subjectString.substring(0,start) + '' + this.subjectString.substring(end,this.subjectString.length)
this.subjectString=this.subjectString.trim()
this.$nextTick(() => {
console.log(start,end)
// console.log(start,end)
event.target.setSelectionRange(start+1,end+1)
})
Expand Down Expand Up @@ -1900,7 +1943,7 @@ methods: {
let sendResults = []
console.log(this.linkModeResults)
// console.log(this.linkModeResults)
if (this.linkModeResults){
Expand Down Expand Up @@ -1938,7 +1981,7 @@ methods: {
}
console.log("sendResults",sendResults)
// console.log("sendResults",sendResults)
this.$emit('subjectAdded', sendResults)
Expand All @@ -1959,7 +2002,7 @@ methods: {
// -----------
console.log("ADDDD")
// console.log("ADDDD")
// complex: false
// id: 2
// label: "20th century"
Expand Down Expand Up @@ -1996,7 +2039,7 @@ methods: {
//remove any existing thesaurus label, so it has the most current
//this.profileStore.removeValueSimple(componentGuid, fieldGuid)
console.log('this.components',this.components)
// console.log('this.components',JSON.parse(JSON.stringify(this.components)))
// remove our werid hyphens before we send it back
for (let c of this.components){
c.label = c.label.replaceAll('','-')
Expand All @@ -2013,20 +2056,21 @@ methods: {
let match = false
const componentCount = this.components.length
const componentCheck = this.components.length > 0 ? this.components.map((component) => component.label).join("--") : false
let componentTypes
try {
componentTypes = this.components.length > 0 ? this.components.map((component) => component.marcKey.slice(5)).join("") : false
} catch {
componentTypes = false
}
let componentTypes
try {
componentTypes = this.components.length > 0 ? this.components.map((component) => component.marcKey.slice(5)).join("") : false
} catch {
componentTypes = false
}
for (let el in this.searchResults["subjectsComplex"]){
for (let el in this.searchResults["subjectsComplex"]){
let target = this.searchResults["subjectsComplex"][el]
if (target.label.replaceAll("", "-") == componentCheck && target.depreciated == false){
// we need to check the types of each element to make sure they really are the same terms
let targetContext = await utilsNetwork.returnContext(target.uri)
let marcKey = targetContext.nodeMap.marcKey[0].slice(5)
if (marcKey == componentTypes){
Expand All @@ -2049,6 +2093,7 @@ methods: {
let newComponents = []
const frozenComponents = JSON.parse(JSON.stringify(this.components))
//remove unused components
if (match){
Array(componentCount).fill(0).map((i) => this.components.shift())
Expand Down Expand Up @@ -2170,7 +2215,8 @@ methods: {
if (newComponents.length > 0){
this.components = newComponents
}
this.$emit('subjectAdded', this.components)
},
Expand Down Expand Up @@ -2288,7 +2334,7 @@ methods: {
let id = 0
let activePosStart = 0
console.log("userValue['http://www.loc.gov/mads/rdf/v1#componentList']",userValue['http://www.loc.gov/mads/rdf/v1#componentList'])
for (let component of userValue['http://www.loc.gov/mads/rdf/v1#componentList']){
let label = ''
Expand Down Expand Up @@ -2416,7 +2462,7 @@ methods: {
console.log("linkModeValue",linkModeValue)
// console.log("linkModeValue",linkModeValue)
this.linkModeString=linkModeValue
Expand Down
5 changes: 3 additions & 2 deletions src/lib/utils_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ const utilsExport = {
// multiple auth labels one with no @lang tag and ones that do have it
// check specific properties for now? (10/2024)
if ([
'http://id.loc.gov/ontologies/bibframe/contribution'
'http://id.loc.gov/ontologies/bibframe/contribution',
'http://id.loc.gov/ontologies/bibframe/subject'
].indexOf(ptObj.propertyURI)>-1){

// recusrive function to go through each key in the userValue and keep going till we find labels or marckeys
Expand All @@ -605,7 +606,7 @@ const utilsExport = {
for (let k in obj){
if (Array.isArray(obj[k])){
// we only care about these properties
if (k == 'http://www.w3.org/2000/01/rdf-schema#label' || k == 'http://id.loc.gov/ontologies/bflc/marcKey'){
if (k == 'http://www.w3.org/2000/01/rdf-schema#label' || k == 'http://id.loc.gov/ontologies/bflc/marcKey' || k == 'http://www.loc.gov/mads/rdf/v1#authoritativeLabel'){
func(k,obj[k])
}else{
process(obj[k], func);
Expand Down
10 changes: 3 additions & 7 deletions src/lib/utils_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ const utilsNetwork = {
total: r.count
}



if (hitAdd.label=='' && hitAdd.suggestLabel.includes('DEPRECATED')){
hitAdd.label = hitAdd.suggestLabel.split('(DEPRECATED')[0] + ' DEPRECATED'
hitAdd.depreciated = true
Expand Down Expand Up @@ -834,7 +836,6 @@ const utilsNetwork = {
genreForm: null,
nodeMap:{},
};
console.log('data.uri',data.uri,data)
if (data.uri.includes('wikidata.org')){
if (data.entities){
let qid = Object.keys(data.entities)[0]
Expand Down Expand Up @@ -909,16 +910,14 @@ const utilsNetwork = {
}
// console.log(uriIdPart)
}else{
console.log("data",data)
// if it is in jsonld format
if (data['@graph']){
data = data['@graph'];
}

var nodeMap = {};

data.forEach(function(n){
console.log(n)
data.forEach(function(n){
if (n['http://www.loc.gov/mads/rdf/v1#birthDate']){
nodeMap['Birth Date'] = n['http://www.loc.gov/mads/rdf/v1#birthDate'].map(function(d){ return d['@value']})
}
Expand Down Expand Up @@ -976,7 +975,6 @@ const utilsNetwork = {
}

})
console.log(nodeMap)

// pull out the labels
data.forEach(function(n){
Expand Down Expand Up @@ -1154,8 +1152,6 @@ const utilsNetwork = {
}
})

console.log('results',results)

return results;
},

Expand Down
2 changes: 1 addition & 1 deletion src/stores/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useConfigStore = defineStore('config', {

versionMajor: 0,
versionMinor: 16,
versionPatch: 0,
versionPatch: 1,



Expand Down
Loading

0 comments on commit 97612a0

Please sign in to comment.