diff --git a/src/components/panels/edit/fields/LookupComplex.vue b/src/components/panels/edit/fields/LookupComplex.vue index 4826c7eb..32b0e3b1 100644 --- a/src/components/panels/edit/fields/LookupComplex.vue +++ b/src/components/panels/edit/fields/LookupComplex.vue @@ -328,10 +328,15 @@ export default { complexLookupValues(){ - - - let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) - return values + + try{ + let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) + return values + } catch(err) { + // this can run into an error when populating an empty complexValue field + // It mostly doesn't seem to matter, but might as well catch + return [] + } }, diff --git a/src/components/panels/edit/fields/Ref.vue b/src/components/panels/edit/fields/Ref.vue index a73ec325..e4e44fd8 100644 --- a/src/components/panels/edit/fields/Ref.vue +++ b/src/components/panels/edit/fields/Ref.vue @@ -284,11 +284,11 @@ export default { let template = this.structure.valueConstraint.valueTemplateRefs[idx] if (parentUserValue && parentUserValue["@root"] == "http://id.loc.gov/ontologies/bibframe/contribution" && parentUserValue["http://id.loc.gov/ontologies/bibframe/contribution"]){ let target = parentUserValue["http://id.loc.gov/ontologies/bibframe/contribution"][0]["http://id.loc.gov/ontologies/bibframe/agent"] - if (target){ - let type = target[0]["@type"] - if (type && this.rtLookup[template].resourceURI === type){ - useId = template - } + if (target){ + let type = target[0]["@type"] + if (type && this.rtLookup[template].resourceURI === type){ + useId = template + } } } } diff --git a/src/stores/config.js b/src/stores/config.js index b6d113ca..bf0ef786 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: 6, + versionPatch: 7, diff --git a/src/stores/profile.js b/src/stores/profile.js index 6d78830f..97c40ea1 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -1839,104 +1839,103 @@ export const useProfileStore = defineStore('profile', { // console.log("propertyPath=",propertyPath) - let pt = utilsProfile.returnPt(this.activeProfile,componentGuid) let valueLocation = utilsProfile.returnValueFromPropertyPath(pt,propertyPath) let deepestLevelURI = propertyPath[propertyPath.length-1].propertyURI + if (valueLocation){ let values = [] - + for (let v of valueLocation){ - let URI = null - let label = null - - - if (v['@id']){ - URI = v['@id'] - } + let URI = null + let label = null + if (v['@id']){ + URI = v['@id'] + } - for (let lP of LABEL_PREDICATES){ - if (v[lP] && v[lP][0][lP]){ - label = v[lP][0][lP] - break - } - } + for (let lP of LABEL_PREDICATES){ + if (v[lP] && v[lP][0][lP]){ + label = v[lP][0][lP] + break + } + } - // look for bf:title -> bf:mainTitle - if (!label){ - for (let lP1 of LABEL_PREDICATES){ - for (let lP2 of LABEL_PREDICATES){ - if (v[lP1] && v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ - label = v[lP1][0][lP2][0][lP2] - break + // look for bf:title -> bf:mainTitle + if (!label){ + for (let lP1 of LABEL_PREDICATES){ + for (let lP2 of LABEL_PREDICATES){ + if (v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ + label = v[lP1][0][lP2][0][lP2] + break + } + } } } - } - } - - let source = null - if (URI && URI.indexOf('/fast/') >1){ - source = 'FAST' - } - let uneditable = false - - // if we don't have a URI for a work don't let them edit it - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Work'){ - uneditable = true - } - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bflc/Uncontrolled'){ - uneditable = true - } - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Uncontrolled'){ - uneditable = true - } - // if it is deepHierarchy then then we are copy pasting what came into the system and they cann change it anyway. - if (pt.deepHierarchy){uneditable=true} + let source = null + if (URI && URI.indexOf('/fast/') >1){ + source = 'FAST' + } + let uneditable = false - if (URI && label){ - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: false, - isLiteral: false, - uneditable: uneditable, - type:v['@type'] - }) - }else if (URI && !label){ - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: true, - isLiteral: false, - uneditable: uneditable, - type:v['@type'] - }) - }else if (!URI && label){ + // if we don't have a URI for a work don't let them edit it + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Work'){ + uneditable = true + } + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bflc/Uncontrolled'){ + uneditable = true + } + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Uncontrolled'){ + uneditable = true + } - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: false, - uneditable: uneditable, - isLiteral: true, - type:v['@type'] - }) - } + // if it is deepHierarchy then then we are copy pasting what came into the system and they cann change it anyway. + if (pt.deepHierarchy){uneditable=true} + + if (URI && label){ + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: false, + isLiteral: false, + uneditable: uneditable, + type:v['@type'] + }) + }else if (URI && !label){ + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: true, + isLiteral: false, + uneditable: uneditable, + type:v['@type'] + }) + }else if (!URI && label){ + + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: false, + uneditable: uneditable, + isLiteral: true, + type:v['@type'] + }) + } + } + + return values } - return values - } // if valueLocation is false then it did not find anytihng meaning its empty, return empty array return [] @@ -1959,6 +1958,7 @@ export const useProfileStore = defineStore('profile', { * @return {void} */ setValueComplex: async function(componentGuid, fieldGuid, propertyPath, URI, label, type, nodeMap=null, marcKey=null ){ + // TODO: reconcile this to how the profiles are built, or dont.. // remove the sameAs from this property path, which will be the last one, we don't need it propertyPath = propertyPath.filter((v)=> { return (v.propertyURI!=='http://www.w3.org/2002/07/owl#sameAs') }) @@ -1967,6 +1967,7 @@ export const useProfileStore = defineStore('profile', { let lastProperty = propertyPath.at(-1).propertyURI // locate the correct pt to work on in the activeProfile let pt = utilsProfile.returnPt(this.activeProfile,componentGuid) + if (!type && URI && !lastProperty.includes("intendedAudience")){ // I regretfully inform you we will need to look this up @@ -1993,12 +1994,15 @@ export const useProfileStore = defineStore('profile', { if (blankNode === false){ // create the path to the blank node let buildBlankNodeResult = await utilsProfile.buildBlanknode(pt,propertyPath) - console.log('buildBlankNodeResult',buildBlankNodeResult) - pt = buildBlankNodeResult[0] // now we can make a link to the parent of where the literal value should live blankNode = utilsProfile.returnGuidLocation(pt.userValue,buildBlankNodeResult[1]) + + //empty out the blankNode's existing data so it only has the new data + for (let key of Object.keys(blankNode).filter((k) => !k.startsWith("@"))){ + blankNode[key] = [] + } // set the URI // if its null then we are adding a literal @@ -2043,9 +2047,6 @@ export const useProfileStore = defineStore('profile', { } } - - - //Add gacs code to user data if (nodeMap["GAC(s)"]){ blankNode["http://www.loc.gov/mads/rdf/v1#code"] = [ @@ -2057,8 +2058,6 @@ export const useProfileStore = defineStore('profile', { ] } - - if (!Array.isArray(marcKey)){ marcKey = [marcKey] } @@ -2074,7 +2073,7 @@ export const useProfileStore = defineStore('profile', { 'http://id.loc.gov/ontologies/bflc/marcKey' : aMarcKeyNode } ) - }else if (aMarcKeyNode['@value']){ + }else if (aMarcKeyNode && aMarcKeyNode['@value']){ let aNode = { '@guid': short.generate(), 'http://id.loc.gov/ontologies/bflc/marcKey' : aMarcKeyNode['@value'] @@ -2133,7 +2132,6 @@ export const useProfileStore = defineStore('profile', { console.error('setValueComplex: Cannot locate the component by guid', componentGuid, this.activeProfile) } - console.log("pt is ",pt) },