Skip to content

Commit

Permalink
Merge pull request #94 from lcnetdev/bfp-239-non-latin-improvements
Browse files Browse the repository at this point in the history
Bfp 239 non latin improvements
  • Loading branch information
thisismattmiller authored Oct 21, 2024
2 parents e7343fa + 8e702ad commit 7f4480d
Show file tree
Hide file tree
Showing 7 changed files with 735 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import LoginModal from "@/components/panels/nav/LoginModal.vue";
import ScriptshifterConfigModal from "@/components/panels/edit/modals/ScriptshifterConfigModal.vue";
import DiacriticsConfigModal from "@/components/panels/edit/modals/DiacriticsConfigModal.vue";
import TextMacroModal from "@/components/panels/edit/modals/TextMacroModal.vue";
import NonLatinBulkModal from "@/components/panels/edit/modals/NonLatinBulkModal.vue";
Expand Down Expand Up @@ -35,7 +36,8 @@ export default {
ShelfListingModal,
DiacriticsConfigModal,
UpdateAvailableModal,
TextMacroModal
TextMacroModal,
NonLatinBulkModal
},
data() {
Expand All @@ -54,7 +56,7 @@ export default {
...mapState(usePreferenceStore, ['showPrefModal','catCode']),
...mapWritableState(usePreferenceStore, ['showLoginModal','showScriptshifterConfigModal','showDiacriticConfigModal','showTextMacroModal']),
...mapWritableState(useConfigStore, ['showUpdateAvailableModal']),
...mapWritableState(useConfigStore, ['showUpdateAvailableModal','showNonLatinBulkModal']),
showLocalPreferenceModal: {
Expand Down Expand Up @@ -142,8 +144,12 @@ export default {
<TextMacroModal v-model="showTextMacroModal" />
</template>

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




</template>

Expand Down
545 changes: 545 additions & 0 deletions src/components/panels/edit/modals/NonLatinBulkModal.vue

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/components/panels/nav/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
...mapState(useConfigStore, ['layouts']),
...mapWritableState(usePreferenceStore, ['showLoginModal','showScriptshifterConfigModal','showDiacriticConfigModal','showTextMacroModal','layoutActiveFilter','layoutActive']),
...mapWritableState(useProfileStore, ['showPostModal', 'showShelfListingModal', 'activeShelfListData','showValidateModal', 'showRecoveryModal']),
...mapWritableState(useConfigStore, ['showNonLatinBulkModal']),
panelTitleProperties(){
Expand Down Expand Up @@ -162,10 +165,19 @@
}, icon:"🗄️" },
{
text: "Non-Latin Literals",
// active: this.happy,
click: () => { this.showNonLatinBulkModal = true }
}
] }
)
}
Expand Down Expand Up @@ -313,6 +325,9 @@
menu.push(
{
Expand Down
44 changes: 44 additions & 0 deletions src/lib/utils_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,47 @@ const utilsParse = {
sniffWorkRelationType(xml){
for (let child of xml.children){
if (child.tagName == 'bf:relation'){

// let hasUncontrolled = false
// if (child.innerHTML.indexOf("bflc:Uncontrolled")>-1||child.innerHTML.indexOf("bf:Uncontrolled")>-1){ hasUncontrolled = true }
// if (child.innerHTML.indexOf("bflc/Uncontrolled")>-1||child.innerHTML.indexOf("bibframe/Uncontrolled")>-1){ hasUncontrolled = true }

// let hasSeriesProperty = false
// if (child.innerHTML.indexOf("bf:hasSeries")>-1){ hasSeriesProperty = true }

// let hasWork = false
// if (child.innerHTML.indexOf("bf:Work")>-1) { hasWork = true}

// let hasHub = false
// if (child.innerHTML.indexOf("bf:Hub")>-1) { hasHub = true}

// let hasSeries = false
// if (child.innerHTML.indexOf("bf:Series")>-1){ hasSeries = true }

// let hasAssociatedResource = false
// if (child.innerHTML.indexOf("bf:associatedResource")>-1) { hasAssociatedResource = true}

// if (hasSeriesProperty && hasAssociatedResource && hasSeries){
// child.setAttribute('local:pthint', 'lc:RT:bf2:SeriesHub')
// }else if (hasAssociatedResource && (hasWork || hasHub) && hasSeriesProperty ){
// child.setAttribute('local:pthint', 'lc:RT:bf2:SeriesHubLookup')
// }else if (hasUncontrolled && hasAssociatedResource && hasWork){
// child.setAttribute('local:pthint', 'lc:RT:bf2:RelWorkLookup')
// }

// console.log(child)
// console.log('hasUncontrolled',hasUncontrolled)
// console.log('hasSeriesProperty',hasSeriesProperty)
// console.log('hasWork',hasWork)
// console.log('hasHub',hasHub)
// console.log('hasSeries',hasSeries)
// console.log('hasAssociatedResource',hasAssociatedResource)





// old Logic
if ( (child.innerHTML.indexOf("bflc:Uncontrolled")>-1||child.innerHTML.indexOf("bf:Uncontrolled")>-1) && child.innerHTML.indexOf("hasSeries")>-1){
child.setAttribute('local:pthint', 'lc:RT:bf2:SeriesHub')
} else if ( (child.innerHTML.indexOf("bflc/Uncontrolled")>-1||child.innerHTML.indexOf("bibframe/Uncontrolled")>-1) && child.innerHTML.indexOf("hasSeries")>-1){
Expand All @@ -268,6 +309,9 @@ const utilsParse = {
}else{
// leave blank?
}



}
}
return xml
Expand Down
9 changes: 5 additions & 4 deletions src/stores/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const useConfigStore = defineStore('config', {
state: () => ({

versionMajor: 0,
versionMinor: 14,
versionPatch: 42,
versionMinor: 15,
versionPatch: 0,

regionUrls: {

Expand Down Expand Up @@ -125,6 +125,7 @@ export const useConfigStore = defineStore('config', {

showUpdateAvailableModal:false,

showNonLatinBulkModal: false,

scriptshifterLanguages: {},

Expand Down Expand Up @@ -795,10 +796,10 @@ export const useConfigStore = defineStore('config', {
"code": "kv-Cyrl"
},
"korean_names": {
"code": "ko-hang"
"code": "ko-Kore"
},
"korean_nonames": {
"code": "ko-hang"
"code": "ko-Kore"
},
"koryak_cyrillic": {
"code": "kpy-Cyrl"
Expand Down
10 changes: 10 additions & 0 deletions src/stores/preference.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,16 @@ export const usePreferenceStore = defineStore('preference', {
group: 'Diacritics',
range: null
},
'--o-literal-lang-bulk-options' : {
value:[],
desc: '',
descShort: 'The lang-script options to use in the bulk tool',
type: 'other',
group: 'Diacritics',
range: null
},



//Shelflisting
'--b-shelflist-link-1-label' : {
Expand Down
108 changes: 108 additions & 0 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ let cachePt = {}
let cacheGuid = {}
let dataChangedTimeout = null

// const nonLatinRegex = /^[A-z\u00C0-\u00ff\s'\.,-\/#!$%\^&\*;:{}=\-_`~()0-9]+$/;
// const latinRegex = /^[\u3040-\u309F\u30A0-\u30FF]+$/;
const latinRegex = /^[A-z\s'\.,-\/#!$%\^&\*;:{}=\-_`~()0-9\u0000-\u007F\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u1E00-\u1EFF\u2C60-\u2C7F\uA720-\uA7FF]+$/

//https://stackoverflow.com/questions/49562546/how-to-get-all-properties-values-of-a-javascript-nested-objects-without-knowing
// clean cacheGuid of items that match the children of the PT that is insert default values too
function cleanCacheGuid(cache, obj, target){
Expand Down Expand Up @@ -3455,6 +3459,110 @@ export const useProfileStore = defineStore('profile', {

},

/**
*
*
* @return {array}
*/
returnAllNonLatinLiterals: function(){

function process (obj, func) {

if (obj && obj.userValue){
obj = obj.userValue
}

if (Array.isArray(obj)){
obj.forEach(function (child) {
process(child, func);
});
}else if (typeof obj == 'object' && obj !== null){
for (let k in obj){
if (Array.isArray(obj[k])){
process(obj[k], func);
}else{
if (!k.startsWith('@')){
func(obj,k,obj[k]);
}
}
}
}

}




let nonLatinNodes = []
for (let rt of this.activeProfile.rtOrder){
for (let pt of this.activeProfile.rt[rt].ptOrder){
let ptObj = this.activeProfile.rt[rt].pt[pt]


process(ptObj, function (obj,key,value) {
// e.g.
// console.log(obj,key);
if (!latinRegex.test(value)){
console.log("VALUIE ==",value)
nonLatinNodes.push({
ptObj:ptObj,
node: obj,
propertyURI: key,
value: value
})
}
});



}
}

// console.log("nonLatinNodes",nonLatinNodes)
return nonLatinNodes
},




/**
* Set lang of literal value
*
* @param {string} componentGuid - the guid of the component (the parent of all fields)
* @param {string} fieldGuid - the guid of the field
* @param {string} lang - the ISO rdf language value like 'en' to append to the literal 'xxxxx@en'
* @return {void}
*/
setBulkLang: function(componentGuid, fieldGuid, lang){


let pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
if (pt !== false){
let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
if (blankNode){

console.log(blankNode)
if (lang){
blankNode['@language'] = lang
}else{
if (blankNode['@language']){
delete blankNode['@language']
}
}


}else{
console.warn("Cannot find blankNode",pt)
}
}else{
console.warn("Cannot find pt",componentGuid)
}


},





}
Expand Down

0 comments on commit 7f4480d

Please sign in to comment.