Skip to content

Commit

Permalink
Merge pull request #108 from lcnetdev/bfp-260-populated-properites
Browse files Browse the repository at this point in the history
[BFP 260] Indicator for populated properites
  • Loading branch information
f-osorio authored Oct 30, 2024
2 parents 8cfb0d4 + bde9dcd commit 6e35781
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
42 changes: 38 additions & 4 deletions src/components/panels/sidebar_property/Properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
...mapStores(useProfileStore,usePreferenceStore),
// // gives read access to this.count and this.double
...mapState(useProfileStore, ['profilesLoaded','activeProfile', 'dataChanged','rtLookup', 'activeComponent']),
...mapState(usePreferenceStore, ['styleDefault']),
...mapState(usePreferenceStore, ['styleDefault', 'isEmptyComponent']),
...mapWritableState(useProfileStore, ['activeComponent']),
Expand Down Expand Up @@ -100,7 +100,28 @@
change: function(){
// A property was moved. Make the current state savable and update the xml
this.dataChanged()
}
},
// if the component has data, and from where
hasData: function(component){
let userValue = component.userValue
let emptyArray = new Array("@root")
let dataLoaded = component.dataLoaded
// console.info(component.propertyLabel, "[", dataLoaded,"]", ": ", component)
//console.info(JSON.stringify(Object.keys(component.userValue)), "--" ,JSON.stringify(emptyArray))
if (this.profileStore.isEmptyComponent(component)){
return false
} else if (component.userModified){
return "user"
} else if (dataLoaded){
return "system"
} else {
return false
}
},
},
}
Expand Down Expand Up @@ -162,13 +183,15 @@
item-key="id">
<template #item="{element}">
<template v-if="!activeProfile.rt[profileName].pt[element].deleted && !hideProps.includes(activeProfile.rt[profileName].pt[element].propertyURI)">
<li @click.stop="activeComponent = activeProfile.rt[profileName].pt[element]" class="sidebar-property-li sidebar-property-li-empty">
<li @click.stop="activeComponent = activeProfile.rt[profileName].pt[element]" :class="['sidebar-property-li sidebar-property-li-empty', {'user-populated': (hasData(activeProfile.rt[profileName].pt[element]) == 'user')} , {'system-populated': (hasData(activeProfile.rt[profileName].pt[element])) == 'system'}]">
<a href="#" @click.stop="activeComponent = activeProfile.rt[profileName].pt[element]" class="sidebar-property-ul-alink">
<template v-if="preferenceStore.returnValue('--b-edit-main-splitpane-properties-number-labels')">{{activeProfile.rt[profileName].ptOrder.indexOf(element)}}</template>
<span v-if="activeProfile.rt[profileName].pt[element].propertyURI == 'http://id.loc.gov/ontologies/bibframe/subject'">
[SH]: {{ returnSubjectHeadingLabel(activeProfile.rt[profileName].pt[element]) }}
</span>
<span v-else>{{activeProfile.rt[profileName].pt[element].propertyLabel}}</span>
<span v-else>
{{activeProfile.rt[profileName].pt[element].propertyLabel}}
</span>



Expand Down Expand Up @@ -481,7 +504,18 @@
stroke:rgb(0,0,0)
}
li.system-populated:before {
font-family: 'Material Icons';
content: 'radio_button_unchecked';
color: white !important;
}
li.user-populated:before {
font-family: 'Material Icons';
content: 'task_alt';
//content: '';
color: white !important;
}
</style>
2 changes: 1 addition & 1 deletion src/lib/utils_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ const utilsExport = {
// console.log(strXmlFormatted)
// console.log("------")
// console.log(strXmlBasic)

return {
xmlDom: rdf,
xmlStringFormatted: strXmlFormatted,
Expand Down
39 changes: 36 additions & 3 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ export const useProfileStore = defineStore('profile', {
if (pt !== false){

pt.hasData = true
pt.userModified = true
pt.dataLoaded = false

// find the correct blank node to edit if possible, if we don't find it then we need to create it
let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
Expand Down Expand Up @@ -1444,6 +1446,8 @@ export const useProfileStore = defineStore('profile', {
// console.log(componentGuid, fieldGuid, propertyPath, value, lang, repeatedLiteral)
if (pt !== false){
pt.hasData = true
pt.userModified = true
pt.dataLoaded = false

// find the correct blank node to edit if possible, if we don't find it then we need to create it
let blankNode
Expand Down Expand Up @@ -1934,6 +1938,8 @@ export const useProfileStore = defineStore('profile', {
if (pt !== false){

pt.hasData = true
pt.userModified = true
pt.dataLoaded = false

// find the correct blank node to edit if possible, if we don't find it then we need to create it
let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
Expand Down Expand Up @@ -2096,6 +2102,8 @@ export const useProfileStore = defineStore('profile', {
}

pt.hasData = true
pt.userModified = true
pt.dataLoaded = false

if (pt.userValue["http://id.loc.gov/ontologies/bibframe/subject"] &&
pt.userValue["http://id.loc.gov/ontologies/bibframe/subject"][0] &&
Expand Down Expand Up @@ -3745,11 +3753,36 @@ export const useProfileStore = defineStore('profile', {
}

return ['report','No Link']

},



//Check if the component's userValue is empty
isEmptyComponent: function(component){



let emptyArray = new Array("@root")
let userValue = component.userValue

// if there is only a @root
if (JSON.stringify(Object.keys(userValue)) == JSON.stringify(emptyArray)){
return true
} else {
// if the children only have "@..." properties
for (let key in userValue){
if (!key.startsWith("@")){
let result = false
try{
result = Object.keys(userValue[key][0]).every((childKey) => childKey.startsWith("@"))
} catch(err) {
console.info("error: ", err)
}
return result

}
}
}

return false
},


Expand Down

0 comments on commit 6e35781

Please sign in to comment.