Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/panels/edit/EditPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

<template v-if="!activeProfile.rt[profileName].pt[profileCompoent].deleted && !hideAdminField(activeProfile.rt[profileName].pt[profileCompoent], profileName)">
<!-- if createLayoutMode is active, and there is an active layout, show everything -->
<div v-if="(!preferenceStore.returnValue('--c-general-ad-hoc') || (createLayoutMode && !layoutActive)) || (layoutActive || (preferenceStore.returnValue('--c-general-ad-hoc') && !profileStore.emptyComponents[profileName].includes(profileCompoent)))" :class="{ 'inline-mode' : (preferenceStore.returnValue('--b-edit-main-splitpane-edit-inline-mode')), 'edit-panel-scroll-x-child': preferenceStore.returnValue('--b-edit-main-splitpane-edit-scroll-x'), 'read-only': isReadOnly(activeProfile.rt[profileName].pt[profileCompoent]), 'hide-component': preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[profileCompoent].hideSubject}">
<div v-if="(!preferenceStore.returnValue('--c-general-ad-hoc') || (createLayoutMode && !layoutActive)) || (layoutActive || (preferenceStore.returnValue('--c-general-ad-hoc') && !profileStore.emptyComponents[profileName].includes(profileCompoent)))" :class="{ 'inline-mode' : (preferenceStore.returnValue('--b-edit-main-splitpane-edit-inline-mode')), 'edit-panel-scroll-x-child': preferenceStore.returnValue('--b-edit-main-splitpane-edit-scroll-x'), 'read-only': isReadOnly(activeProfile.rt[profileName].pt[profileCompoent]), 'hide-component': ((preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[profileCompoent].hideSubject) || (preferenceStore.returnValue('--b-edit-main-hide-non-lc-class-numbers') && activeProfile.rt[profileName].pt[profileCompoent].hideClassNum))}">
<template v-if="this.dualEdit == false">
<template v-if="preferenceStore.returnValue('--b-edit-main-splitpane-edit-shortcode-display-mode') == false && preferenceStore.returnValue('--b-edit-main-splitpane-edit-inline-mode') == false">
<div class="component-label 2" :class="{'label-bold': preferenceStore.returnValue('--b-edit-main-splitpane-edit-show-field-labels-bold')}">
Expand Down Expand Up @@ -162,8 +162,8 @@
</div>

<!-- There's a hidden subject -->
<template v-if="preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[profileCompoent].hideSubject">
<div v-if="numberHiddenShown(activeProfile).hidden > 0"></div>
<template v-if="(preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[profileCompoent].hideSubject) || (preferenceStore.returnValue('--b-edit-main-hide-non-lc-class-numbers') && activeProfile.rt[profileName].pt[profileCompoent].hideClassNum)">
<div v-if="numberHiddenShown(activeProfile).hiddenSubject > 0 || numberHiddenShown(activeProfile).hiddenClassNumbers > 0"></div>
</template>

</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/panels/sidebar_property/Properties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
item-key="id">
<template #item="{element}">
<template v-if="!hideAdminField(activeProfile.rt[profileName].pt[element], profileName) && !activeProfile.rt[profileName].pt[element].deleted && !hideProps.includes(activeProfile.rt[profileName].pt[element].propertyURI) && ( (layoutActive && layoutActiveFilter['properties'][profileName] && includeInLayout(activeProfile.rt[profileName].pt[element].id, layoutActiveFilter['properties'][profileName])) || !layoutActive || (createLayoutMode && layoutActive))">
<li @click.stop="jumpToElement(profileName, 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'} , {'not-populated-hide': (preferenceStore.returnValue('--c-general-ad-hoc') && emptyComponents[profileName] && emptyComponents[profileName].includes(element) && !layoutActive ), 'hide-component': preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[element].hideSubject}]">
<li @click.stop="jumpToElement(profileName, 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'} , {'not-populated-hide': (preferenceStore.returnValue('--c-general-ad-hoc') && emptyComponents[profileName] && emptyComponents[profileName].includes(element) && !layoutActive ), 'hide-component': ((preferenceStore.returnValue('--b-edit-main-hide-non-lc') && activeProfile.rt[profileName].pt[element].hideSubject) || (preferenceStore.returnValue('--b-edit-main-hide-non-lc-class-numbers') && activeProfile.rt[profileName].pt[element].hideClassNum))}]">
<a href="#" @click.stop="jumpToElement(profileName, element)" :class="['sidebar-property-ul-alink', {'primary-component': isPrimaryComponent(profileName, activeProfile, activeProfile.rt[profileName].pt[element].id)}]">
<template v-if="preferenceStore.returnValue('--b-edit-main-splitpane-properties-number-labels')">{{activeProfile.rt[profileName].ptOrder.indexOf(element)}}</template>
<span v-if="replacePropertyWithValue(activeProfile.rt[profileName].pt[element].propertyURI)">
Expand Down
6 changes: 6 additions & 0 deletions src/lib/utils_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,12 @@ const utilsParse = {
if (!display && comp.propertyURI == "http://id.loc.gov/ontologies/bibframe/subject"){
profile.rt[pkey].pt[key].hideSubject = true
}

// check if class number should display
display = useProfileStore().displayClassNumber(comp)
if (!display && comp.propertyURI == "http://id.loc.gov/ontologies/bibframe/classification"){
profile.rt[pkey].pt[key].hideClassNum = true
}
}else{
profile.rt[pkey].pt[key].dataLoaded=false
// if there is no data loaded, add it to the list for ad hoc
Expand Down
11 changes: 10 additions & 1 deletion src/stores/preference.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,23 @@ export const usePreferenceStore = defineStore('preference', {
range: null
},
'--b-edit-main-hide-non-lc' : {
desc: 'Do not display nonLC subjects.',
desc: 'Do not display non-LC subjects.',
descShort: 'Hide non-LC Subjects',
value: false,
type: 'boolean',
unit: null,
group: 'Edit Panel',
range: [true,false]
},
'--b-edit-main-hide-non-lc-class-numbers' : {
desc: 'Do not display non-LC class numbers.',
descShort: 'Hide non-LC class numbers',
value: false,
type: 'boolean',
unit: null,
group: 'Edit Panel',
range: [true,false]
},
// This doesn't have an input. It does show up in the preference modal.
// It's used to capture the quick view options
'--o-edit-main-splitpane-edit-panel-size-presets' : {
Expand Down
78 changes: 75 additions & 3 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const useProfileStore = defineStore('profile', {
// List of empty components for ad hoc mode
emptyComponents: {},
hiddenSubjects: false,
hiddenClassNumbers: false,

localMarva: false,
}),
Expand Down Expand Up @@ -4506,6 +4507,7 @@ export const useProfileStore = defineStore('profile', {
newPt.hasData = false
delete newPt.deleted
delete newPt.hideSubject
delete newPt.hideClassNum
delete newPt.hide

newPt.id = newPropertyId
Expand Down Expand Up @@ -7216,6 +7218,36 @@ export const useProfileStore = defineStore('profile', {
return true
},

displayClassNumber: function(comp){
console.info("Display Class Number?")
let pref = usePreferenceStore().returnValue("--b-edit-main-hide-non-lc-class-numbers")
if (!pref){ return true }

try {
if (comp.propertyURI == "http://id.loc.gov/ontologies/bibframe/classification"){
let userValue = comp.userValue
let data = userValue["http://id.loc.gov/ontologies/bibframe/classification"] ? userValue["http://id.loc.gov/ontologies/bibframe/classification"][0] : {}
console.info("data: ", data)
let assigner = data["http://id.loc.gov/ontologies/bibframe/assigner"][0]
let id = assigner['@id']
let label = assigner["http://www.w3.org/2000/01/rdf-schema#label"][0]["http://www.w3.org/2000/01/rdf-schema#label"]

console.info("id: ", id)
console.info("label: ", label)
if (!label.includes("Library of Congress") ){
return false
}


}

return true
} catch(err){
console.error("Error with displaySubject preference: ", err)
return true
}
},

displaySubject: function(comp){
// if the preference is set to only show LCSH terms, return true/false based on the source
// how to handle if everything is hidden??
Expand All @@ -7228,6 +7260,9 @@ export const useProfileStore = defineStore('profile', {
if (comp.propertyURI == "http://id.loc.gov/ontologies/bibframe/subject"){
let userValue = comp.userValue
let data = userValue["http://id.loc.gov/ontologies/bibframe/subject"] ? userValue["http://id.loc.gov/ontologies/bibframe/subject"][0] : {}
if (data['@id'] && data['@id'].includes('http://id.loc.gov/authorities/')){
return true
}
if (data["http://id.loc.gov/ontologies/bibframe/source"]){
let source = data["http://id.loc.gov/ontologies/bibframe/source"][0]
let code = source["http://id.loc.gov/ontologies/bibframe/code"] ? source["http://id.loc.gov/ontologies/bibframe/code"][0]["http://id.loc.gov/ontologies/bibframe/code"] : ""
Expand All @@ -7237,6 +7272,8 @@ export const useProfileStore = defineStore('profile', {
if (!label.includes("Library of Congress") ){
return false
}
} else if(Object.keys(data).length == 2) {
return false
}
}

Expand All @@ -7247,10 +7284,20 @@ export const useProfileStore = defineStore('profile', {
}
},

/**
* Track number of hidden components to make sure to create an empty one if needed
* @param {Object} profile - Profile loaded
* @returns
*/
numberHiddenShown: function(profile){
let subjectCount = 0
let subjectHidden = 0
let subjectLast = null

let classCount = 0
let classHidden = 0
let classLast = null

for (let rt in profile.rt){
for (let pt in profile.rt[rt].pt){
if (pt.includes("id_loc_gov_ontologies_bibframe_subject__subjects")){
Expand All @@ -7263,20 +7310,45 @@ export const useProfileStore = defineStore('profile', {
}
subjectLast = comp
}

if (pt.includes("id_loc_gov_ontologies_bibframe_classification__classification_numbers")){
let comp = profile.rt[rt].pt[pt]
if (comp.deleted === undefined || (Object.keys(comp).includes('deleted') && comp.deleted != true)){
classCount++
}
if (comp.hideClassNum){
classHidden++
}
classLast = comp
}
}
}

let showing = subjectCount - subjectHidden
if (showing == 0){
let showingSubjects = subjectCount - subjectHidden
if (showingSubjects == 0){
// add an empty subject component
// componentGuid, structure
this.duplicateComponent(subjectLast["@guid"], this.returnStructureByGUID(subjectLast["@guid"]))
}

let showingClassNumber = classCount - classHidden
if (showingClassNumber == 0){
// add an empty subject component
// componentGuid, structure
this.duplicateComponent(classLast["@guid"], this.returnStructureByGUID(classLast["@guid"]))
}

if (subjectHidden > 0){
this.hiddenSubjects = true
}
if (classHidden > 0){
this.hiddenClassNumbers = true
}

let results = {'subjects': subjectCount, 'hidden': subjectHidden, 'showing': showing}
let results = {
'subjects': subjectCount, 'hiddenSubject': subjectHidden, 'showingSubjects': showingSubjects,
'classNumbers': classCount, 'hiddenClassNumbers': classHidden, 'showingClassNumbers': showingClassNumber
}

return results
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,15 @@
"--c-edit-main-splitpane-edit-scroll-bar-track-color": {
"value": "#fafafa",
"desc": "The color of the scroll bar track (background).",
"descShort": "Scrollbard Track Color",
"descShort": "Scrollbar Track Color",
"type": "color",
"group": "Edit Panel",
"range": null
},
"--c-edit-main-splitpane-edit-scroll-bar-thumb-color": {
"value": "#c7c7c7",
"desc": "The color of the scroll bar thumb (the part you grab).",
"descShort": "Scrollbard Thumb Color",
"descShort": "Scrollbar Thumb Color",
"type": "color",
"group": "Edit Panel",
"range": null
Expand Down
4 changes: 2 additions & 2 deletions tests-playwright/configs/subjectBuilderConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,15 @@
"--c-edit-main-splitpane-edit-scroll-bar-track-color": {
"value": "#fafafa",
"desc": "The color of the scroll bar track (background).",
"descShort": "Scrollbard Track Color",
"descShort": "Scrollbar Track Color",
"type": "color",
"group": "Edit Panel",
"range": null
},
"--c-edit-main-splitpane-edit-scroll-bar-thumb-color": {
"value": "#c7c7c7",
"desc": "The color of the scroll bar thumb (the part you grab).",
"descShort": "Scrollbard Thumb Color",
"descShort": "Scrollbar Thumb Color",
"type": "color",
"group": "Edit Panel",
"range": null
Expand Down