Skip to content

Commit

Permalink
Merge pull request #170 from lcnetdev/bfp-268-auto-dewey-2
Browse files Browse the repository at this point in the history
[BFP 268] Auto Dewey
  • Loading branch information
f-osorio authored Dec 17, 2024
2 parents 8f7c740 + 5fa93de commit 55744df
Show file tree
Hide file tree
Showing 10 changed files with 11,920 additions and 35 deletions.
25 changes: 14 additions & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import HubStubCreateModal from "@/components/panels/edit/modals/HubStubCreateMod
import ShelfListingModal from "@/components/panels/edit/modals/ShelfListing.vue";
import AutoDeweyModal from "./components/panels/edit/modals/AutoDeweyModal.vue";
import UpdateAvailableModal from "@/components/general/UpdateAvailableModal.vue";
Expand All @@ -41,6 +41,7 @@ export default {
ShelfListingModal,
DiacriticsConfigModal,
UpdateAvailableModal,
AutoDeweyModal,
TextMacroModal,
NonLatinBulkModal,
NonLatinAgentModal,
Expand All @@ -60,7 +61,7 @@ export default {
...mapStores(useConfigStore, useProfileStore, usePreferenceStore),
// // gives read access to this.count and this.double
...mapState(useProfileStore, ['profilesLoaded', 'showValidateModal','profilesLoaded', 'showPostModal']),
...mapWritableState(useProfileStore, ['showShelfListingModal','showHubStubCreateModal']),
...mapWritableState(useProfileStore, ['showShelfListingModal','showHubStubCreateModal', 'showAutoDeweyModal']),
...mapState(usePreferenceStore, ['showPrefModal','catCode']),
...mapWritableState(usePreferenceStore, ['showLoginModal','showScriptshifterConfigModal','showDiacriticConfigModal','showTextMacroModal','showFieldColorsModal']),
Expand All @@ -86,10 +87,10 @@ export default {
}
},
async mounted() {
console.log(this.configStore.versionMajor)
async mounted() {
console.log(this.configStore.versionMajor)
// const configStore = useConfigStore()
// const profileStore = useProfileStore()
// const profileStore = useProfileStore()
this.preferenceStore.initalize()
// this.profileStore.buildProfiles()
Expand Down Expand Up @@ -141,7 +142,7 @@ export default {
<DiacriticsConfigModal v-model="showDiacriticConfigModal" />
</template>


<template v-if="showShelfListingModal==true">
<ShelfListingModal v-model="showShelfListingModal" />
</template>
Expand All @@ -151,24 +152,26 @@ export default {
<template v-if="showTextMacroModal==true">
<TextMacroModal v-model="showTextMacroModal" />
</template>

<template v-if="showNonLatinBulkModal==true">
<NonLatinBulkModal v-model="showNonLatinBulkModal" />
</template>

<template v-if="showNonLatinAgentModal==true">
<NonLatinAgentModal v-model="showNonLatinAgentModal" />
</template>

<template v-if="showFieldColorsModal==true">
<FieldColorsModal v-model="showFieldColorsModal" />
</template>
<template v-if="showHubStubCreateModal==true">
<HubStubCreateModal v-model="showHubStubCreateModal" />
</template>




<template v-if="showAutoDeweyModal==true">
<AutoDeweyModal v-model="showAutoDeweyModal" />
</template>

</template>


Expand Down
11 changes: 5 additions & 6 deletions src/components/panels/edit/fields/Literal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

</template>

<template v-else>
<template v-else>
<div class="lookup-fake-input" v-if="showField" >
<div class="literal-holder" @click="focusClick(lValue)" v-for="lValue in literalValues">
<!-- <div>Literal ({{propertyPath.map((x)=>{return x.propertyURI}).join('>')}})</div> -->
Expand Down Expand Up @@ -116,7 +116,6 @@

</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;">
Expand Down Expand Up @@ -783,7 +782,7 @@ export default {
let data = this.profileStore.returnLccInfo(this.guid, this.structure)
if (data.contributors && data.contributors.length>0){
data.contributors[0].secondLetterLabel = data.contributors[0].label.substring(1)
}
}
return data
}
return false
Expand Down Expand Up @@ -824,7 +823,7 @@ export default {
// this.lccFeatureData = this.profileStore.returnLccInfo(this.guid, this.structure)
// }
// }
dataChangedTimestamp(newVal, oldVal) {
dataChangedTimestamp(newVal, oldVal) {
this.lccFeatureDataCounter++
}
Expand Down Expand Up @@ -1010,8 +1009,8 @@ textarea{
.lookup-fake-input{
min-height: 2em;
background-color: transparent;
}
textarea:focus-within{
Expand Down
48 changes: 42 additions & 6 deletions src/components/panels/edit/fields/helpers/ActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
</button>
</template>

<template v-if="this.structure.parentId == 'lc:RT:bf2:LCC'">
<button style="width:100%" :id="`action-button-command-${fieldGuid}-0`" class="" @click="convertLcc2Dewey()">
<span class="">🤖</span>AutoDewey
</button>
</template>

<button style="width:100%" :id="`action-button-command-${fieldGuid}-0`" class="" @click="showDebug()">
<span class="button-shortcut-label">0</span>
Expand Down Expand Up @@ -156,14 +161,18 @@

<script>
import AutoDewey from "@/components/panels/edit/modals/AutoDeweyModal.vue";
import { usePreferenceStore } from '@/stores/preference'
import { useProfileStore } from '@/stores/profile'
import short from 'short-uuid'
import { mapStores, mapState, mapWritableState } from 'pinia'
export default {
components: {
AutoDewey
},
props: {
type: String,
guid: String,
Expand All @@ -181,8 +190,10 @@
popperKeyboardShortcutEvent: null,
popperKeyboardShortcutElement: null,
isMenuShown:false,
displayDewey: false,
lcCall: null,
}
},
Expand All @@ -194,6 +205,7 @@
...mapWritableState(usePreferenceStore, ['debugModalData','showDebugModal']),
...mapWritableState(useProfileStore, ['showAutoDeweyModal', 'deweyData']),
scriptShifterOptionsForMenu(){
Expand Down Expand Up @@ -237,11 +249,11 @@
},
methods: {
hideDeweyModal:function (){
this.displayDewey = false
},
showBuildHubStub(){
console.log("this.propertyPath",this.propertyPath)
if (!this.propertyPath) return false;
Expand Down Expand Up @@ -343,7 +355,6 @@
if (this.structure.parentId.includes("lc:RT:bf2:SeriesHub")){
return false
}
console.info("this.structure", this.structure.parentId)
//does this have defaults, or are the defaults higher up?
let defaults = this.structure.valueConstraint.defaults
Expand Down Expand Up @@ -594,6 +605,31 @@
// this.showActionButtonMenu=false
// }
convertLcc2Dewey: function(){
const parent = this.profileStore.returnStructureByComponentGuid(this.guid)
let lccn = null
try{
const data = parent.userValue["http://id.loc.gov/ontologies/bibframe/classification"][0]
const classPortion = data["http://id.loc.gov/ontologies/bibframe/classificationPortion"][0]["http://id.loc.gov/ontologies/bibframe/classificationPortion"]
lccn = classPortion
try {
const itemPortion = data["http://id.loc.gov/ontologies/bibframe/itemPortion"][0]["http://id.loc.gov/ontologies/bibframe/itemPortion"]
lccn += itemPortion
} catch {}
} catch(e) {
// alert("Couldn't generate an LC class number for auto dewey. Make sure all the pieces are present.")
console.error("AutoDewey Error", e)
}
this.lcCall = lccn
this.deweyData = {
lcc: lccn,
guid: this.guid,
structure: this.structure
}
this.showAutoDeweyModal = true
},
},
watch: {
Expand Down
Loading

0 comments on commit 55744df

Please sign in to comment.