Skip to content

Commit

Permalink
Merge branch 'release/1.25.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Mar 25, 2022
2 parents ca2e2d9 + fd54d14 commit 60dd73b
Show file tree
Hide file tree
Showing 36 changed files with 837 additions and 1,703 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Local App Config
vue-client/.env.development
vue-client/.env.development*

# Common OS, Tool and Editor Files
.vscode/*
Expand Down
3 changes: 3 additions & 0 deletions lxljs/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export function getItemLabel(item, resources, quoted, settings, inClass = '') {
// Assume this is already a label.
return item;
}
if (typeof item === 'number') {
return `${item}`;
}
if (!item || typeof item === 'undefined') {
throw new Error('getItemLabel was called with an undefined object.');
}
Expand Down
5 changes: 4 additions & 1 deletion lxljs/tests/string.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as VocabUtil from '../vocab.js';
import * as StringUtil from '../string.js';
import context from '../../test-resources/context';
import testContext from '../../test-resources/context';

const context = VocabUtil.preprocessContext(testContext);

describe('StringUtil', () => {

Expand Down
2 changes: 1 addition & 1 deletion lxljs/tests/vocab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import vocab from '../../test-resources/vocab';

const resources = {
vocab,
context: context['@context'],
context: VocabUtil.preprocessContext(context)['@context'],
};

describe('VocabUtil', () => {
Expand Down
57 changes: 53 additions & 4 deletions lxljs/vocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function getTermObject(term, vocab, context) {
tries.push(cn);
}
}
if (!_class && term.endsWith('ByLang')) {
cn = cn.replace('ByLang', '');
if (!_class && getContextValue(term, '@container', context) === '@language') {
cn = getContextValue(term, '@id', context);
_class = vocab.get(cn);
tries.push(cn);
}
Expand Down Expand Up @@ -600,6 +600,24 @@ export function getBaseUriFromPrefix(prefix, context) {
return baseUri;
}

export function getContainedBaseUri(uri, context) {
// If uri contains a baseUri defined in the context, return that baseUri
const contextList = context[0];
let baseUri = '';
forOwn(contextList, (value) => {
if (uri.includes(value)) {
baseUri = value;
}
});
return baseUri;
}

export function getContainedPrefix(uri, context) {
// If uri contains a prefix defined in the context, return that prefix
const baseUri = getContainedBaseUri(uri, context);
return getPrefixFromBaseUri(baseUri, context);
}

export function getPrefixFromBaseUri(baseUri, context) {
// Returns prefix that corresponds to the provided baseUri.
const contextList = context[0];
Expand Down Expand Up @@ -643,6 +661,9 @@ export function isAbstract(termObject) {

export function getTree(term, vocab, context, counter = 0, parentChainString = '') {
const termObj = getTermObject(term, vocab, context);
if (typeof termObj === 'undefined') {
return {};
}
const treeNode = {
id: term,
labels: termObj.labelByLang || termObj.prefLabelByLang,
Expand Down Expand Up @@ -686,11 +707,39 @@ export function printTree(term, vocab, context) {
}

export function preprocessContext(context) {
const computed = { containerMap: computeContainerMap(context['@context'][1]) };
context['@context'].push(computed);
// Internal structure by index: 0 = prefixes, 1 = terms, 2 = computed
const prefixes = {};
const terms = {};

const ctx = context['@context'];
const ctxArray = isArray(ctx) ? ctx : [ctx];
for (const oneCtx of ctxArray) {
if (!isPlainObject(oneCtx)) {
continue;
}
forOwn(oneCtx, (value, key) => {
if (isPrefix(value)) {
prefixes[key] = value;
} else {
terms[key] = value;
}
});
}

const computed = { containerMap: computeContainerMap(terms) };
context['@context'] = [prefixes, terms, computed];

return context;
}

function isPrefix(value) {
if (isPlainObject(value) && value['@prefix'] === true) {
return true;
}
const id = isPlainObject(value) ? value['@id'] : value;
return typeof id === 'string' && id.match(/[/#:]$/) !== null;
}

export function computeContainerMap(contextList) {
function forContextList(closure) {
forOwn(contextList, (value, key) => {
Expand Down
10 changes: 2 additions & 8 deletions nuxt-app/components/EntityNode.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<template>
<div class="EntityNode" :class="{ 'chip': isChip }">
<template v-if="typeof entityData == 'string'">
<span class="">{{ entityData }}</span>
</template>
<template v-else-if="entityData">
<span class="" v-if="!entityData['@id']">
<template v-if="entityData">
<span class="string-value" v-if="!entityData['@id']">
{{ getItemLabel }}
</span>
<template v-else-if="entityData['@id']">
Expand Down Expand Up @@ -89,9 +86,6 @@ export default {
},
computed: {
...mapGetters(['currentDocument', 'quoted', 'settings', 'resources', 'appState']),
isByLangValue() {
return this.parentKey.includes('ByLang');
},
typeOfLibrisService() {
const id = this.entityData['@id'];
if (id.includes('https://id.kb.se/')) {
Expand Down
6 changes: 2 additions & 4 deletions nuxt-app/components/EntityTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="EntityTable-body" :class="{ 'is-inner-table': isInnerTable, 'is-linked-table': isLinked }" v-if="itemData">
<div class="PropertyRow d-md-flex" v-if="showUri && itemData.hasOwnProperty('@id')">
<div class="PropertyRow-bodyKey d-block d-md-inline">
<div class="PropertyRow-bodyKey d-block d-md-inline" title="@id">
URI ({{ translateUi('link to resource') }})
</div>
<div class="PropertyRow-bodyValue">
Expand Down Expand Up @@ -42,6 +42,7 @@ export default {
'reverseLinks',
'meta',
'hasItem',
'baseClassChain',
],
idCopied: false,
clipboardAvailable: false,
Expand All @@ -51,9 +52,6 @@ export default {
this.clipboardAvailable = typeof navigator !== 'undefined' && typeof navigator.clipboard !== 'undefined';
},
methods: {
isByLangKey(key) {
return key.endsWith('ByLang');
},
copyId() {
const self = this;
navigator.clipboard.writeText(this.ownPath).then(function() {
Expand Down
10 changes: 8 additions & 2 deletions nuxt-app/components/Facet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</template>

<script>
import { mapGetters } from 'vuex';
import * as VocabUtil from 'lxljs/vocab';
import * as DisplayUtil from 'lxljs/display';
export default {
data() {
return {
Expand Down Expand Up @@ -49,14 +53,16 @@ export default {
},
},
computed: {
...mapGetters(['vocabContext', 'resources', 'settings']),
checked() {
if (this.$route.query.hasOwnProperty(this.dimension) && this.$route.query[this.dimension] === this.facet.object['@id']) {
return true;
}
return false;
},
label() {
let prop = '';
return DisplayUtil.getItemLabel(this.facet.object, this.resources, null, this.settings);
// let prop = '';
if (this.facet.object.hasOwnProperty('labelByLang')) {
prop = 'labelByLang';
} else if (this.facet.object.hasOwnProperty('titleByLang')) {
Expand All @@ -69,7 +75,7 @@ export default {
prop = 'code';
}
if (this.facet.object[prop]) {
if (prop.includes('ByLang')) {
if (VocabUtil.getContextValue(prop, '@container', this.vocabContext) == '@language') {
return this.facet.object[prop][this.settings.language] || Object.values(this.facet.object[prop])[0];
}
return this.facet.object[prop];
Expand Down
1 change: 0 additions & 1 deletion nuxt-app/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<h4>{{ translateUi('Information') }}</h4>
<ul class="bd-footer-links ps-0 mb-3 text-light">
<li class="d-block"><a class="text-light" href="https://www.kb.se/digital-tillganglighet">{{ translateUi('Accessibility statement') }}</a></li>
<li class="d-block"><a class="text-light" href="https://www.kb.se/libris-versionsinformation">{{ translateUi('Release notes') }}</a></li>
</ul>
</div>
<div class="col-md-5 d-flex flex-column">
Expand Down
4 changes: 2 additions & 2 deletions nuxt-app/components/NavMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<NuxtLink @click.native="linkActivated" to="/" class="nav-link" :class="{'active': $route.name == 'find' || $route.name == 'index' }">{{ translateUi('Search') }}</NuxtLink>
</li>
<li class="nav-item">
<NuxtLink @click.native="linkActivated" to="/marcframe/" class="nav-link" tabindex="-1" :class="{'active': $route.name.startsWith('marcframe') }">{{ translateUi('MARC mappings') }}</NuxtLink>
<NuxtLink @click.native="linkActivated" to="/vocab/" class="nav-link" :class="{'active': $route.name == 'vocab-term' || $route.name == 'vocab' }">{{ translateUi('Vocabulary') }}</NuxtLink>
</li>
<li class="nav-item">
<NuxtLink @click.native="linkActivated" to="/vocab/" class="nav-link" :class="{'active': $route.name == 'vocab-term' || $route.name == 'vocab' }">{{ translateUi('Vocabulary') }}</NuxtLink>
<NuxtLink @click.native="linkActivated" to="/marcframe/" class="nav-link" tabindex="-1" :class="{'active': $route.name.startsWith('marcframe') }">{{ translateUi('MARC mappings') }}</NuxtLink>
</li>
<li class="nav-item">
<NuxtLink @click.native="linkActivated" to="/doc/about" class="nav-link" :class="{'active': $route.path == '/doc/about' }">{{ translateUi('About id.kb.se') }}</NuxtLink>
Expand Down
3 changes: 1 addition & 2 deletions nuxt-app/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nav class="Navbar navbar navbar-expand-lg navbar-dark">
<div class="container-fluid">
<div class="Navbar-brandContainer">
<NuxtLink :title="`Version ${version}`" v-if="appState.domain === 'id'" to="/" class="Navbar-brand navbar-brand">
<NuxtLink v-if="appState.domain === 'id'" to="/" class="Navbar-brand navbar-brand">
<Logo />
{{ siteTitle }}
</NuxtLink>
Expand Down Expand Up @@ -53,7 +53,6 @@ export default {
return this.settings.version;
},
versionInfo() {
if (this.settings.environment === 'prod') return '';
return `${this.environmentLabel.toUpperCase()} ${this.version}`;
},
environmentLabel() {
Expand Down
12 changes: 3 additions & 9 deletions nuxt-app/components/PropertyRow.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div class="PropertyRow d-md-flex" :data-property="property">
<div :data-property="property" class="PropertyRow-bodyKey d-block d-md-inline" :title="translateKey(property)">{{ translateKey(property) }}</div>
<div :data-property="property" class="PropertyRow-bodyKey d-block d-md-inline" :title="property">{{ translateKey(property) }}</div>
<div :data-property="property" class="PropertyRow-bodyValue single" v-if="!Array.isArray(value)">
<span class="" v-if="valueType == 'boolean'">{{ translateUi(value == true ? 'Yes' : 'No') }}</span>
<EntityTable v-else-if="isIntegral && isInner == false" :entity="value" :is-main-entity="false" />
<EntityNode :parent-key="property" :entity="value" v-else-if="!isByLangProperty" />
<EntityNode :parent-key="property" :entity="value" v-else-if="containerType != '@language'" />
<span v-else-if="valueType !== 'object'">{{ value }}</span>
<div class="PropertyRow-grid" v-else>
<template v-for="(v, lang) in value">
Expand Down Expand Up @@ -58,20 +58,14 @@ export default {
},
computed: {
...mapGetters(['quoted', 'settings', 'resources', 'vocabContext', 'display', 'vocab']),
isByLangProperty() {
return this.property.includes('ByLang');
},
valueType() {
return typeof this.value;
},
isIntegral() {
return VocabUtil.hasCategory(this.property, 'integral', this.resources);
},
containerType() {
if (this.vocabContext[1].hasOwnProperty(this.property) && this.vocabContext[1][this.property].hasOwnProperty('@container')) {
return this.vocabContext[1][this.property]['@container'];
}
return null;
return VocabUtil.getContextValue(this.property, '@container', this.vocabContext);
},
finalizedValue() {
return this.withoutFilteredTypes;
Expand Down
Loading

0 comments on commit 60dd73b

Please sign in to comment.