Skip to content

Commit

Permalink
shelf listing
Browse files Browse the repository at this point in the history
thisismattmiller committed Aug 6, 2024
1 parent 2e7f819 commit d0b1df3
Showing 11 changed files with 1,138 additions and 39 deletions.
8 changes: 6 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import LoadingModal from "@/components/general/LoadingModal.vue";
import PreferenceModal from "@/components/general/PreferenceModal.vue";
import LoginModal from "@/components/panels/nav/LoginModal.vue";
import ScriptshifterConfigModal from "@/components/panels/edit/modals/ScriptshifterConfigModal.vue";
import ShelfListingModal from "@/components/panels/edit/modals/ShelfListing.vue";
@@ -24,6 +25,7 @@ export default {
PreferenceModal,
LoginModal,
ScriptshifterConfigModal,
ShelfListingModal
},
data() {
return {
@@ -36,8 +38,7 @@ export default {
// gives access to this.counterStore and this.userStore
...mapStores(useConfigStore, useProfileStore, usePreferenceStore),
// // gives read access to this.count and this.double
...mapState(useProfileStore, ['profilesLoaded', 'showPostModal']),
...mapState(useProfileStore, ['profilesLoaded', 'showValidateModal']),
...mapState(useProfileStore, ['profilesLoaded', 'showValidateModal','profilesLoaded', 'showPostModal','showShelfListingModal']),
...mapState(usePreferenceStore, ['showPrefModal','catCode']),
...mapWritableState(usePreferenceStore, ['showLoginModal','showScriptshifterConfigModal']),
@@ -129,6 +130,9 @@ export default {
<ScriptshifterConfigModal v-model="showScriptshifterConfigModal" />
</template>

<template v-if="showShelfListingModal==true">
<ShelfListingModal v-model="showShelfListingModal" />
</template>



154 changes: 149 additions & 5 deletions src/components/panels/edit/fields/Literal.vue
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@

</div>
</div>



</template>
@@ -102,6 +103,72 @@
</Transition>
</div>
</div>

<div class="lcc-action-zone" v-if="lccFeatureData !== false">
<div v-if="structure.propertyURI=='http://id.loc.gov/ontologies/bibframe/classificationPortion'">

<a style="color:black" v-if="lccFeatureData.classNumber" :href="'https://classweb.org/min/minaret?app=Class&mod=Search&look=1&query=&index=id&cmd2=&auto=1&Fspan='+lccFeatureData.classNumber+'&Fcaption=&Fkeyword=&Fterm=&Fcap_term=&count=75&display=1&table=schedules&logic=0&style=0&cmd=Search'" target="_blank">ClassWeb Search: {{ lccFeatureData.classNumber }}</a><br/>
<a style="color:black" v-if="lccFeatureData.firstSubject" :href="'https://classweb.org/min/minaret?app=Corr&mod=Search&count=75&auto=1&close=1&display=1&menu=/Auto/&iname=sh2l&iterm='+lccFeatureData.firstSubject" target="_blank">ClassWeb Search: {{ lccFeatureData.firstSubject }}</a>


</div>
<div v-if="structure.propertyURI=='http://id.loc.gov/ontologies/bibframe/itemPortion'">
<!-- { "title": "knitter's handy book of patterns", "classNumber": "TT820", "cutterNumber": ".B877 2002", "titleNonSort": 4, "contributors": [ { "type": "PrimaryContribution", "label": "Budd, Ann, 1956-" } ], "firstSubject": "Knitting--Patterns" } -->
<div style="display: flex;">
<div style="flex:1">
<fieldset v-if="(lccFeatureData.contributors && lccFeatureData.contributors.length>0) || lccFeatureData.title" >
<legend>Cutter Calculator</legend>

<template v-if="lccFeatureData.contributors">

<template v-if="lccFeatureData.contributors[0]">
<div>
<span style="font-weight: bold;">{{lccFeatureData.contributors[0].label.substring(0,parseInt(cutterCalcLength))}}</span>
<span>{{lccFeatureData.contributors[0].label.substring(parseInt(cutterCalcLength))}}</span>
<input type="text" :value="'.' + calculateCutter(lccFeatureData.contributors[0].label,cutterCalcLength).substring(0,cutterCalcLength)">
<a style="font-size: 0.85em; padding-left: 0.5em;" @click.prevent="setLccInfo(lccFeatureData.cutterGuid,calculateCutter(lccFeatureData.contributors[0].label,cutterCalcLength).substring(0,cutterCalcLength))" href="#">Use</a>
</div>
</template>
<template v-if="lccFeatureData.contributors[1]">
<div>
<span style="font-weight: bold;">{{lccFeatureData.contributors[1].label.substring(0,cutterCalcLength)}}</span>
<span>{{lccFeatureData.contributors[1].label.substring(parseInt(cutterCalcLength))}}</span>
<input type="text" :value="'.' + calculateCutter(lccFeatureData.contributors[1].label,parseInt(cutterCalcLength)).substring(0,parseInt(cutterCalcLength))">
<a style="font-size: 0.85em; padding-left: 0.5em;" @click.prevent="setLccInfo(lccFeatureData.cutterGuid,calculateCutter(lccFeatureData.contributors[1].label,parseInt(cutterCalcLength)).substring(0,parseInt(cutterCalcLength)))" href="#">Use</a>
</div>
</template>
<template v-if="lccFeatureData.title">
<div>
<span style="font-weight: bold;">{{lccFeatureData.title.substring(0,parseInt(cutterCalcLength))}}</span>
<span>{{lccFeatureData.title.substring(parseInt(cutterCalcLength),parseInt(cutterCalcLength)+12)}}</span>
<input type="text" :value="'.' + calculateCutter(lccFeatureData.title,parseInt(cutterCalcLength)).substring(0,parseInt(cutterCalcLength))">
<a style="font-size: 0.85em; padding-left: 0.5em;" @click.prevent="setLccInfo(lccFeatureData.cutterGuid,calculateCutter(lccFeatureData.title,parseInt(cutterCalcLength)).substring(0,parseInt(cutterCalcLength)))" href="#">Use</a>
</div>
</template>


</template>

<div>
<input type="range" v-model="cutterCalcLength" name="cutterCalcLength" min="0" max="6" step="1" />
<label for="cutterCalcLength" style="font-size: 0.8em; vertical-align: text-top;">Calc Length ({{ cutterCalcLength }})</label>
</div>


</fieldset>
</div>
<div style="flex:1; display: flex;justify-content: center;align-items: center;">
<button @click="openShelfListSearch">Shelf List Search</button>
</div>

</div>

</div>


</div>


</template>


@@ -145,6 +212,40 @@ export default {
methods: {
openShelfListSearch(){
this.activeShelfListData = {
class: this.lccFeatureData.classNumber,
cutter:this.lccFeatureData.cutterNumber,
classGuid:this.lccFeatureData.classGuid,
cuterGuid: this.lccFeatureData.cutterGuid,
componentGuid: this.guid
}
this.showShelfListingModal = true
},
async setLccInfo(fieldGuid,lccVal){
this.lccFeatureDataCounter++
if (fieldGuid == null){
fieldGuid = short.generate()
}
lccVal = `.${lccVal}`
await this.profileStore.setValueLiteral(this.guid,fieldGuid,this.propertyPath,lccVal,null)
console.log(fieldGuid,lccVal)
},
calculateCutter(toCut,howLong){
return utilsMisc.calculateCutter(toCut,howLong)
},
inlineEmptyFocus: function(event){
if (event.target.innerText.trim() === ''){
event.target.innerText=''
@@ -314,9 +415,9 @@ export default {
...mapStores(useProfileStore),
...mapStores(usePreferenceStore),
...mapState(useConfigStore, ['scriptShifterLangCodes']),
...mapState(useConfigStore, ['scriptShifterLangCodes', 'lccFeatureProperties']),
...mapWritableState(useProfileStore, ['activeField','activeProfile', 'literalLangShow', 'literalLangInfo']),
...mapWritableState(useProfileStore, ['showShelfListingModal','activeField','activeProfile', 'literalLangShow', 'literalLangInfo','dataChangedTimestamp','activeShelfListData']),
myGuid(){
@@ -331,7 +432,7 @@ export default {
value: '',
'@lang': null,
'@guid': short.generate()
}]
}]
}
if (values.length == 0){
@@ -354,6 +455,15 @@ export default {
},
lccFeatureData(){
this.lccFeatureDataCounter
if (this.lccFeatureProperties.indexOf(this.propertyPath[this.propertyPath.length-1].propertyURI)>-1){
return this.profileStore.returnLccInfo(this.guid, this.structure)
}
return false
},
inlineModeShouldDisplay(){
@@ -381,18 +491,37 @@ export default {
watch: {
// literalValues(newliteralValues, oldliteralValues) {
// console.log(newliteralValues, this.guid, this.structure)
// if (this.lccFeatureProperties.indexOf(this.propertyPath[this.propertyPath.length-1].propertyURI)>-1){
// this.lccFeatureData = this.profileStore.returnLccInfo(this.guid, this.structure)
// }
// }
dataChangedTimestamp(newVal, oldVal) {
this.lccFeatureDataCounter++
}
},
data: function() {
return {
activeGuid: this.guid,
// used as toggle to show the button when field is focused
showActionButton: false,
lccFeatureDataCounter: 0,
hasNoData: false,
showField: true,
cutterCalcLength: 2,
}
},
@@ -401,13 +530,18 @@ export default {
this.$nextTick().then(() => {
this.expandHeightToContent()
})
if (this.lccFeatureProperties.indexOf(this.propertyPath[this.propertyPath.length-1].propertyURI)>-1){
this.lccFeatureData = this.profileStore.returnLccInfo(this.guid, this.structure)
}
},
created: function(){
this.$nextTick().then(() => {
this.expandHeightToContent()
})
console.log("activeGuid",this.activeGuid)
@@ -418,7 +552,17 @@ export default {

<style scoped>
fieldset{
border: solid 1px rgb(133, 133, 133);
}
.lcc-action-zone{
background-color: whitesmoke;
padding: 0.55em;
border-left: solid 1px rgb(133, 133, 133);
border-right: solid 1px rgb(133, 133, 133);
}
.lang-display{
background-color: aliceblue;
border-radius: 1em;
340 changes: 340 additions & 0 deletions src/components/panels/edit/modals/ShelfListing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
<script>
// import { usePreferenceStore } from '@/stores/preference'
import { useProfileStore } from '@/stores/profile'
import { useConfigStore } from '@/stores/config'
import { mapStores, mapState, mapWritableState } from 'pinia'
import { VueFinalModal } from 'vue-final-modal'
import VueDragResize from 'vue3-drag-resize'
import utilsNetwork from '@/lib/utils_network';
export default {
components: {
VueFinalModal,
VueDragResize,
},
data() {
return {
width: 0,
height: 0,
top: 100,
left: 0,
initalHeight: 550,
initalLeft: 500,
classNumber: null,
cutterNumber:null,
results: [],
}
},
computed: {
// other computed properties
// ...
// gives access to this.counterStore and this.userStore
// ...mapStores(usePreferenceStore),
...mapStores(useConfigStore),
...mapStores(useProfileStore),
// ...mapWritableState(usePreferenceStore, ['literalLangGuid']),
...mapWritableState(useProfileStore, ['showShelfListingModal','activeShelfListData']),
/**
* Returns the current scripts defined in th embdeded data
* @return {array} results - array of scripts
*/
xxxxx(){
},
},
watch: {
},
methods: {
dragResize: function(newRect){
this.width = newRect.width
this.height = newRect.height
this.top = newRect.top
this.left = newRect.left
this.$refs.shelfListingContent.style.height = newRect.height + 'px'
},
onSelectElement (event) {
const tagName = event.target.tagName
if (tagName === 'INPUT' || tagName === 'TD' || tagName === 'BUTTON' || tagName === 'TEXTAREA' || tagName === 'SELECT') {
event.stopPropagation()
}
},
async search(){
this.results = []
this.results = await utilsNetwork.searchShelfList(this.classNumber.trim() + ' ' + this.cutterNumber.trim())
console.log("this.results",this.results)
// altsubject
// :
// "Railroad trains"
// creator
// :
// ""
// frequency
// :
// ""
// lookup
// :
// "/lds/search.xqy?count=10&sort=score-desc&pg=1&precision=exact&qname=idx:lcclass&q=TF148%20C66%202016"
// pubdate
// :
// "2016"
// subject
// :
// "Railroad trains--Juvenile literature"
// term
// :
// "TF148 C66 2016"
// title
// :
// "Trains"
},
},
async created(){
},
async mounted() {
this.classNumber = this.activeShelfListData.class
this.cutterNumber = this.activeShelfListData.cutter
this.search()
}
}
</script>

<template>


<VueFinalModal
display-directive="show"
:hide-overlay="true"
:overlay-transition="'vfm-fade'"


>
<VueDragResize
:is-active="true"
:w="900"
:h="initalHeight"
:x="initalLeft"
class="shelf-listing-modal"
@resizing="dragResize"
@dragging="dragResize"
:sticks="['br']"
:stickSize="22"
>
<div id="shelf-listing-content" ref="shelfListingContent" @mousedown="onSelectElement($event)" @touchstart="onSelectElement($event)">

<div class="menu-buttons">
<button class="close-button" @pointerup="showShelfListingModal=false">X</button>
</div>

<div class="shelf-listing-work-area">
<input v-model="classNumber" @keyup="search" type="text" />
<input v-model="cutterNumber" @keyup="search" type="text" />
<button>Save</button>
<table>
<thead>
<tr>
<td>Number</td>
<td>Title</td>
<td>Date</td>
<td> </td>

</tr>
</thead>
<tbody>

<template v-for="r in results">
<template v-if="r.title != 'Would Appear Here'">
<tr>
<td>{{ r.term }}</td>
<td>{{ r.title }}</td>
<td>{{ r.pubdate }}</td>
<td><a style="color: inherit; text-decoration: none;" target="_blank" :href="r.lookup">view</a></td>
</tr>
</template>

<template v-if="r.title == 'Would Appear Here'">
<tr style="background-color: yellow;">
<td>{{ r.term }}</td>
<td>{{ r.title }}</td>
<td>{{ r.pubdate }}</td>
<td></td>
</tr>
</template>





</template>







</tbody>


</table>


</div>


</div>


</VueDragResize>
</VueFinalModal>




</template>
<style>
</style>

<style scoped>
iframe{
display: block;
}
.shelf-listing-work-area{
clear: both;
}
.shelf-listing-modal{
background-color: white;
}
select{
max-width: 50%;
}
.value-display-holder{
padding: 1em;
font-size: 1.25em;
}
.value-display{
background-color: whitesmoke;
padding: 0.5em 0.5em 0.5em 2em;
border:dashed 1px black;
}
th{
text-align: left;
font-weight: bold;
}
tr:hover{
background-color: aliceblue;
}
td{
border-bottom: solid 1px whitesmoke;
}
#shelf-listing-content{
background-color: white;
overflow-y: scroll;
}
.checkbox-option{
width: 20px;
height: 20px;
}
input[type=checkbox]{
width: 25px;
height: 25px;
}
.option{
display: flex;
}
.option-title{
flex:2;
}
.option-title-header{
font-weight: bold;
}
.option-title-desc{
font-size: 0.8em;
color:gray;
}
.menu-buttons{
position: relative;
z-index: 100;
}
.close-button{
position: absolute;
right: 5px;
top: 5px;
background-color: white;
border-radius: 5px;
border: solid 1px black;
cursor: pointer;
}
</style>
2 changes: 1 addition & 1 deletion src/components/panels/sidebar_preview_xml/Xml.vue
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
let exportResult = await this.profileStore.buildExportXML()
this.xml = exportResult.xlmStringBasic
console.log(this.xml)
if (this.firstLoad){
this.$nextTick(()=>{
for (let el of document.querySelectorAll('.element-name')){
4 changes: 2 additions & 2 deletions src/components/panels/sidebar_property/Properties.vue
Original file line number Diff line number Diff line change
@@ -101,8 +101,8 @@
<template v-if="activeProfile.rt[profileName]['@type'] && activeProfile.rt[profileName]['@type'] == 'http://id.loc.gov/ontologies/bflc/SecondaryInstance'">Secondary</template>
{{$t("message.wordInstance")}}
</span>
<span class="sidebar-header-text" v-if="profileName.split(':').slice(-1)[0] == 'Item'">{{$t("message.wordItem")}}</span>
<span class="sidebar-header-text" v-if="profileName.split(':').slice(-1)[0] == 'Hub'">{{$t("message.wordHub")}}</span>
<span class="sidebar-header-text" v-if="profileName.split(':').slice(-1)[0].indexOf('Item')>-1">{{$t("message.wordItem")}}</span>
<span class="sidebar-header-text" v-if="profileName.split(':').slice(-1)[0].indexOf('Hub')>-1">{{$t("message.wordHub")}}</span>
</div>

</template>
86 changes: 86 additions & 0 deletions src/lib/utils_misc.js
Original file line number Diff line number Diff line change
@@ -45,6 +45,92 @@ const utilsMisc = {
},


calculateCutter (toCut,howLong) {
var authorName = toCut
authorName = authorName.toUpperCase();
authorName = authorName.replace(/^[0-9]/,"a");
authorName = authorName.replace(/[^A-Za-z]/g,"");
//var authorNameLength = authorName.length;
authorName = authorName.replace(/^QU/i,"@");
authorName = authorName.replace(/(^.)CH/i,"$1#");
var cutter = "";
for (var i=0; i<authorName.length; i++) {
if (i == 0) {
cutter += authorName.slice(0,1); //alert (cutter);
cutter = cutter.replace(/a/,"A");
//alert (authorName + " " + cutter);
}
else if (i == 1) {
var initialLetter = authorName.slice(0,1); //alert (initialLetter);
var secondLetter = authorName.slice(1,2); //alert (secondLetter);
if (initialLetter.match(/^A|E|I|O|U$/)) {
if (secondLetter.match(/^A|B|C$/)) {cutter += "2"}
if (secondLetter.match(/^D|E|F|G|H$/)) {cutter += "3"}
if (secondLetter.match(/^I|J|K|L|M$/)) {cutter += "4"}
if (secondLetter.match(/^N$/)) {cutter += "5"}
if (secondLetter.match(/^O|P|Q$/)) {cutter += "6"}
if (secondLetter.match(/^R$/)) {cutter += "7"}
if (secondLetter.match(/^S|T$/)) {cutter += "8"}
if (secondLetter.match(/^U|V|W|X|Y|Z$/)) {cutter += "9"}
}
else if (initialLetter.match(/^S$/)) {
if (secondLetter.match(/^A|B|C$/)) {cutter += "2"}
if (secondLetter == "#") {cutter += "3"}
if (secondLetter.match(/^D|E|F|G$/)) {cutter += "4"}
if (secondLetter.match(/^H|I|J|K|L$/)) {cutter += "5"}
if (secondLetter.match(/^M|N|O|P$/)) {cutter += "6"}
if (secondLetter.match(/^Q|R|S|T$/)) {cutter += "7"}
if (secondLetter.match(/^U|V$/)) {cutter += "8"}
if (secondLetter.match(/^W|X|Y|Z$/)) {cutter += "9"}
}
else if (initialLetter.match(/^@$/)) {
if (secondLetter.match(/^A|B|C|D$/)) {cutter += "3"}
if (secondLetter.match(/^E|F|G|H$/)) {cutter += "4"}
if (secondLetter.match(/^I|J|K|L|M|N$/)) {cutter += "5"}
if (secondLetter.match(/^O|P|Q$/)) {cutter += "6"}
if (secondLetter.match(/^R|S$/)) {cutter += "7"}
if (secondLetter.match(/^T|U|V|W$/)) {cutter += "8"}
if (secondLetter.match(/^Y|Z$/)) {cutter += "9"}
}
else if (initialLetter.match(/^Q$/)) {
cutter += "2";
}
else if (initialLetter.match(/^a$/)) {
cutter += "1"; //alert ("yay")
}
else {
if (secondLetter.match(/^A|B|C|D$/)) {cutter += "3"}
if (secondLetter.match(/^E|F|G|H$/)) {cutter += "4"}
if (secondLetter.match(/^I|J|K|L$/)) {cutter += "5"}
if (secondLetter.match(/^M|N|O$/)) {cutter += "6"}
if (secondLetter.match(/^P|Q|R|S$/)) {cutter += "7"}
if (secondLetter.match(/^T|U|V$/)) {cutter += "8"}
if (secondLetter.match(/^W|X|Y|Z$/)) {cutter += "9"}
}
}
else if (i>1) {
var iLetter = authorName.slice(i,i+1);
if (iLetter.match(/^A|B|C|D$/)) {cutter += "3"}
if (iLetter.match(/^E|F|G|H$/)) {cutter += "4"}
if (iLetter.match(/^I|J|K|L$/)) {cutter += "5"}
if (iLetter.match(/^M|N|O$/)) {cutter += "6"}
if (iLetter.match(/^P|Q|R|S$/)) {cutter += "7"}
if (iLetter.match(/^T|U|V$/)) {cutter += "8"}
if (iLetter.match(/^W|X|Y|Z$/)) {cutter += "9"}
}
}
var noofdigits = howLong;
var cutterLength = cutter.length;
//alert (noofdigits + " " + cutterLength);
if (cutterLength-1 > noofdigits) {
noofdigits+=1;
//alert (noofdigits);
cutter = cutter.slice(0,noofdigits);
}
return cutter
}



}

308 changes: 308 additions & 0 deletions src/lib/utils_network.js

Large diffs are not rendered by default.

38 changes: 15 additions & 23 deletions src/lib/utils_profile.js
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ const utilsProfile = {

// link to the base userValue
let pointer = pt.userValue
console.log(propertyPath.length)

for (let p of propertyPath){

// the property path has two parts
@@ -264,57 +264,49 @@ const utilsProfile = {
},


/**
* Called from buildBlanknode to build the @types for a userValue it is a seperate function to allow it to run
* without blocking the creation of the blanknode which lags data input if we had to wait around why deciding the @types for the node
* @async
* @param {object} pt - the pt field for that component
* @param {array} propertyPath - the array of URI strings that points to the place to build the blank node obj
* @return {void} - doesn't return anything it works on the reference to the pt.userValue updating the orginal
*/
setTypesForBlankNode: async function(pt, propertyPath){
let pointer = pt.userValue

for (let p of propertyPath){

p = p.propertyURI

if (pointer[p][0]){



console.log("pointer ->",pointer)


// we may or maynot need to create a @type for this level, depending on what type of property it is,
// so test first the property info in the profile
let type = utilsRDF.suggestTypeProfile(p,pt)


if (type === false){
// did not find it in the profile, look to the network
type = await utilsRDF.suggestTypeNetwork(p)

}

if (type !== false){
// first we test to see if the type is a literal, if so then we
// don't need to set the type, as its not a blank node, just a nested property
if (utilsRDF.isUriALiteral(type) === false){
pointer[p][0]['@type'] = type
// if it doesn't yet have a type then go ahead and set it
if (!pointer[p][0]['@type']){
pointer[p][0]['@type'] = type
}
}else{
// nothing to do, its a literal
}
}else{
console.error("Could not find type for this property", p, 'of', propertyPath, 'in', pt)
}

pointer = pointer[p][0]

}else{
console.error("Trying to link to a level in userValue and unable to find it", p, 'of', propertyPath, 'in', pt)
}

}


console.log("Finished typing blank node")
console.log(pt)





},


10 changes: 10 additions & 0 deletions src/stores/config.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ export const useConfigStore = defineStore('config', {
publish : 'http://localhost:9401/util/publish/staging',
validate: 'http://localhost:5200/util/validate',
bfdb : 'https://preprod-8230.id.loc.gov/',
shelfListing: 'https://preprod-8231.id.loc.gov/',
profiles : 'http://localhost:9401/util/profiles/profile/prod',
starting: 'http://localhost:9401/util/profiles/starting/prod',

@@ -43,6 +44,7 @@ export const useConfigStore = defineStore('config', {
scriptshifter: 'https://editor.id.loc.gov/bfe2/scriptshifter/',
publish: 'https://preprod-3001.id.loc.gov/bfe2/util/publish/staging',
validate: 'https://preprod-3001.id.loc.gov/bfe2/util/validate',
shelfListing: 'https://preprod-8231.id.loc.gov/',
// bfdb : 'https://preprod-8210.id.loc.gov/',
bfdb : 'https://preprod-8230.id.loc.gov/',
profiles : '/bfe2/util/profiles/profile/stage',
@@ -61,6 +63,7 @@ export const useConfigStore = defineStore('config', {
utilLang : 'https://editor.id.loc.gov/bfe2/util-lang/',
scriptshifter : 'https://editor.id.loc.gov/bfe2/scriptshifter/',
publish: 'https://editor.id.loc.gov/bfe2/util/publish/production',
shelfListing: 'https://preprod-8231.id.loc.gov/',
validate: 'https://editor.id.loc.gov/bfe2/util/validate',
bfdb : 'https://preprod-8230.id.loc.gov/',
bfdbGPO : 'https://preprod-8210.id.loc.gov/',
@@ -197,6 +200,13 @@ export const useConfigStore = defineStore('config', {

],

// if the field is using these properties we might want to enhance the interface with shelflisting tools
lccFeatureProperties: [
'http://id.loc.gov/ontologies/bibframe/itemPortion',
'http://id.loc.gov/ontologies/bibframe/classificationPortion'

],


// xml files stored in the static file directory
testData:[
223 changes: 219 additions & 4 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ import utilsNetwork from '@/lib/utils_network';
import utilsParse from '@/lib/utils_parse';
import utilsRDF from '@/lib/utils_rdf';
import utilsExport from '@/lib/utils_export';
// import utilsMisc from '@/lib/utils_misc';



import utilsProfile from '../lib/utils_profile'
@@ -52,6 +54,15 @@ export const useProfileStore = defineStore('profile', {

showPostModal: false,
showValidateModal: false,
showShelfListingModal: false,
activeShelfListData:{
class:null,
cutter:null,
classGuid:null,
cuterGuid: null,
componentGuid: null
},


// bf:title component/predicate for example, value will be the structure object for this component

@@ -1368,6 +1379,8 @@ export const useProfileStore = defineStore('profile', {
pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
cachePt[componentGuid] = pt
}
console.log("--------pt 1------------")
console.log(JSON.stringify(pt,null,2))
// let pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
console.log(componentGuid, fieldGuid, propertyPath, value, lang, repeatedLiteral)
if (pt !== false){
@@ -1382,8 +1395,11 @@ export const useProfileStore = defineStore('profile', {
blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
cacheGuid[fieldGuid] = blankNode
}
console.log("--------pt 2------------")
console.log(JSON.stringify(pt,null,2))

// let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
// console.log("blankNode -->",blankNode)
console.log("blankNode -->",blankNode)
if (blankNode === false){
// create the path to the blank node
let buildBlankNodeResult
@@ -1407,7 +1423,8 @@ export const useProfileStore = defineStore('profile', {
blankNode['@guid'] = fieldGuid
// set a temp value that will be over written below
blankNode[lastProperty] = true

console.log("--------pt 3------------")
console.log(JSON.stringify(pt,null,2))

}else{

@@ -1437,7 +1454,8 @@ export const useProfileStore = defineStore('profile', {
blankNode = utilsProfile.returnGuidLocation(pt.userValue,newGuid)
// set a temp value that will be over written below
blankNode[lastProperty] = true

console.log("--------pt 4------------")
console.log(JSON.stringify(pt,null,2))


}
@@ -1489,7 +1507,8 @@ export const useProfileStore = defineStore('profile', {
delete parent[lastProperty]
}


console.log("--------pt 5------------")
console.log(JSON.stringify(pt,null,2))


}
@@ -2538,6 +2557,202 @@ export const useProfileStore = defineStore('profile', {
},


/**
* If it is a LCC component info about the LCC numbers
* used in the interface rendering
* @return {boolean}
*/
returnLccInfo: function(componentGuid, structure){


let pt = utilsProfile.returnPt(this.activeProfile,componentGuid)

let classNumber = null
let classGuid = null

let cutterNumber = null
let cutterGuid = null

let work = null
let title = null
let titleNonSort = null
let firstSubject = null
let contributors = []

// find the work and pull out stuff
for (let rtId in this.activeProfile.rt){

if (rtId.indexOf(":Work") > -1){
for (let ptId in this.activeProfile.rt[rtId].pt){
if (this.activeProfile.rt[rtId].pt[ptId]['@guid'] == componentGuid){
work = this.activeProfile.rt[rtId]
break
}
}
if (work){ break }
}
}

if (work){

for (let ptId in work.pt){

let pt = work.pt[ptId]

if (pt.propertyURI=='http://id.loc.gov/ontologies/bibframe/title'){
let titleUserValue = pt.userValue
if (titleUserValue && titleUserValue['http://id.loc.gov/ontologies/bibframe/title'] && titleUserValue['http://id.loc.gov/ontologies/bibframe/title'].length>0 && titleUserValue['http://id.loc.gov/ontologies/bibframe/title'][0]){
titleUserValue = titleUserValue['http://id.loc.gov/ontologies/bibframe/title'][0]
if (titleUserValue && titleUserValue['http://id.loc.gov/ontologies/bibframe/mainTitle']){
if (titleUserValue['http://id.loc.gov/ontologies/bibframe/mainTitle'].length > 0 && titleUserValue['http://id.loc.gov/ontologies/bibframe/mainTitle'][0] && titleUserValue['http://id.loc.gov/ontologies/bibframe/mainTitle'][0]['http://id.loc.gov/ontologies/bibframe/mainTitle']){
title = titleUserValue['http://id.loc.gov/ontologies/bibframe/mainTitle'][0]['http://id.loc.gov/ontologies/bibframe/mainTitle']
}
}
if (titleUserValue && titleUserValue['http://id.loc.gov/ontologies/bflc/nonSortNum']){
if (titleUserValue['http://id.loc.gov/ontologies/bflc/nonSortNum'].length > 0 && titleUserValue['http://id.loc.gov/ontologies/bflc/nonSortNum'][0] && titleUserValue['http://id.loc.gov/ontologies/bflc/nonSortNum'][0]['http://id.loc.gov/ontologies/bflc/nonSortNum']){
titleNonSort = titleUserValue['http://id.loc.gov/ontologies/bflc/nonSortNum'][0]['http://id.loc.gov/ontologies/bflc/nonSortNum']
}
}
}
}


if (pt.propertyURI=='http://id.loc.gov/ontologies/bibframe/contribution'){
let contributorUserValue = pt.userValue
let type="normal"

if (contributorUserValue && contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'] && contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'].length > 0 && contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0] && contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0]['@type']){
if (contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0]['@type'] === 'http://id.loc.gov/ontologies/bibframe/PrimaryContribution'){
type="PrimaryContribution"
}

if (contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0]['http://id.loc.gov/ontologies/bibframe/agent'] && contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0]['http://id.loc.gov/ontologies/bibframe/agent'][0]){
let agent = contributorUserValue['http://id.loc.gov/ontologies/bibframe/contribution'][0]['http://id.loc.gov/ontologies/bibframe/agent'][0]
if (agent && agent['http://www.w3.org/2000/01/rdf-schema#label'] && agent['http://www.w3.org/2000/01/rdf-schema#label'].length > 0 && agent['http://www.w3.org/2000/01/rdf-schema#label'][0] && agent['http://www.w3.org/2000/01/rdf-schema#label'][0]['http://www.w3.org/2000/01/rdf-schema#label']){
contributors.push({type:type,label:agent['http://www.w3.org/2000/01/rdf-schema#label'][0]['http://www.w3.org/2000/01/rdf-schema#label']})
}
}



}

}

if (pt.propertyURI=='http://id.loc.gov/ontologies/bibframe/subject' && firstSubject === null){
let subjectUserValue = pt.userValue

if (subjectUserValue && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'] && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'].length > 0 && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0] && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label']){
if (subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label'] && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label'].length>0 && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label'][0] && subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label'][0]['http://www.w3.org/2000/01/rdf-schema#label']){

firstSubject = subjectUserValue['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.w3.org/2000/01/rdf-schema#label'][0]['http://www.w3.org/2000/01/rdf-schema#label']


}

}

}



}
}




if (pt && pt.userValue && pt.userValue['http://id.loc.gov/ontologies/bibframe/classification'] && pt.userValue['http://id.loc.gov/ontologies/bibframe/classification'].length>0){
let uv = pt.userValue['http://id.loc.gov/ontologies/bibframe/classification'][0]


if (uv && uv['@type'] && uv['@type'] == 'http://id.loc.gov/ontologies/bibframe/ClassificationLcc'){

// this is a LCC field then

// we need to gather info from the component and the rest of the work to build links/suggestions




if (uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'] && uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'].length>0 && uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'][0] && uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'][0]['http://id.loc.gov/ontologies/bibframe/classificationPortion']){
classNumber = uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'][0]['http://id.loc.gov/ontologies/bibframe/classificationPortion']
classGuid = uv['http://id.loc.gov/ontologies/bibframe/classificationPortion'][0]['@guid']

}
if (uv['http://id.loc.gov/ontologies/bibframe/itemPortion'] && uv['http://id.loc.gov/ontologies/bibframe/itemPortion'].length>0 && uv['http://id.loc.gov/ontologies/bibframe/itemPortion'][0] && uv['http://id.loc.gov/ontologies/bibframe/itemPortion'][0]['http://id.loc.gov/ontologies/bibframe/itemPortion']){
cutterNumber = uv['http://id.loc.gov/ontologies/bibframe/itemPortion'][0]['http://id.loc.gov/ontologies/bibframe/itemPortion']
cutterGuid = uv['http://id.loc.gov/ontologies/bibframe/itemPortion'][0]['@guid']

}





if (titleNonSort && titleNonSort.trim().length >0){
if (isNaN(parseInt(titleNonSort)) == false ){
titleNonSort = parseInt(titleNonSort)
title = title.substr(titleNonSort).trim()
}
}

// console.log('classNumber',classNumber)
// console.log('cutterNumber',cutterNumber)
// console.log('work',work)
// console.log('title',title)
// console.log('titleNonSort',titleNonSort)
// console.log("contributors",contributors)




return {
title: title,
classNumber:classNumber,
cutterNumber:cutterNumber,
titleNonSort:titleNonSort,
contributors:contributors,
firstSubject:firstSubject,
cutterGuid:cutterGuid,
classGuid:classGuid
}

}


}else{


if (pt && pt.userValue && pt.propertyURI == 'http://id.loc.gov/ontologies/bibframe/classification' && Object.keys(pt.userValue).length == 1){

// it is a new record, so there is no info but the LCC classification is by default so populate the other stuff
return {
title: title,
classNumber:null,
cutterNumber:null,
titleNonSort:titleNonSort,
contributors:contributors,
firstSubject:firstSubject,
cutterGuid:null,
classGuid:null
}


}





}


//ClassificationLcc
return false

},




4 changes: 2 additions & 2 deletions src/views/Edit.vue
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
<pane
:class="{'edit-main-splitpane-edit': true, 'edit-main-splitpane-edit-no-scrollbar': preferenceStore.returnValue('--b-edit-main-splitpane-edit-no-scrollbar')}"
:size="preferenceStore.returnValue('--n-edit-main-splitpane-edit-width')">
{{ (this.activeProfile) ? Object.keys(this.activeProfile).length : "" }}

<EditPanel :key="test" :instanceMode="false"/>
</pane>

@@ -183,7 +183,7 @@
if (this.profilesLoaded && this.activeProfile){
if (this.activeProfile.neweId){
console.log("New record just created.")
// if they just created a new record then we should save the record to back end first thing so it is recorded
this.profileStore.saveRecord()

0 comments on commit d0b1df3

Please sign in to comment.