Skip to content

Commit

Permalink
Merge pull request #1124 from libris/feature/bulkchange-soft-type-mat…
Browse files Browse the repository at this point in the history
…ching

Use unspecified type as default in bulk change view
  • Loading branch information
lrosenstrom authored Oct 21, 2024
2 parents 8986834 + 8a73583 commit 5a07be8
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 26 deletions.
4 changes: 1 addition & 3 deletions cataloging/src/components/care/bulk-changes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,8 @@ export default {
</div>
</div>
<div>


<!-- SPECIFICATION-->
<!-- <pre>{{this.currentBulkChange}}</pre>-->
<!-- <pre>{{ this.currentBulkChange }}</pre>-->
<!-- ENTITY FORM-->
<!-- <pre>{{ this.dataObj }}</pre>-->

Expand Down
1 change: 0 additions & 1 deletion cataloging/src/components/care/form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default {
:is-active="true"
:form-data="formData"
:locked="!isActive"
:in-bulk-change-view="true"
/>
</div>
</div>
Expand Down
15 changes: 13 additions & 2 deletions cataloging/src/components/inspector/entity-adder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export default {
hasSingleCreatable() {
return this.rangeCreatable.length === 1;
},
hasCreateable() {
return this.rangeCreatable.length > 0;
},
isVocabField() {
return VocabUtil.getContextValue(this.fieldKey, '@type', this.resources.context) === '@vocab';
},
Expand Down Expand Up @@ -190,6 +193,9 @@ export default {
}
return false;
},
inBulkChangeView() {
return this.$route.path.includes('bulkchanges');
},
},
mounted() {
this.addEmbedded = (this.valueList.length === 0 && this.onlyEmbedded && this.rangeFull.length > 1);
Expand Down Expand Up @@ -611,11 +617,16 @@ export default {
<div class="EntityAdder-create">
<button
class="EntityAdder-createBtn btn btn-primary btn--sm"
v-if="hasSingleCreatable && allowLocal"
v-if="hasSingleCreatable && allowLocal && !inBulkChangeView"
v-on:click="addEmpty(rangeCreatable[0])">{{ translatePhrase("Create local entity") }}
</button>
<button
class="EntityAdder-createBtn btn btn-primary btn--sm"
v-if="inBulkChangeView && hasCreateable && allowLocal"
v-on:click="addEmpty('Any')">{{ translatePhrase("Create local entity") }}
</button>
<filter-select
v-if="!hasSingleCreatable"
v-if="!hasSingleCreatable && !inBulkChangeView"
:input-id="'createselectInput'"
:class-name="'js-createSelect'"
:options="{ tree: selectOptions, priority: priorityOptions }"
Expand Down
5 changes: 4 additions & 1 deletion cataloging/src/components/inspector/item-local.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ export default {
},
isBulkChangeView() {
return this.$route.path.includes('bulkchanges');
},
typeLabel() {
return this.item['@type'] === 'Any' ? translatePhrase('Unspecified') : labelByLang(this.item['@type']);
}
},
methods: {
Expand Down Expand Up @@ -578,7 +581,7 @@ export default {
{{ translatePhrase("Extracted when the record is saved") }}
</span>
<span v-if="!expanded || !isExtracting">
{{ capitalize(labelByLang(item['@type'])) }}:
{{ capitalize(typeLabel) }}:
</span>
</span>
<span class="ItemLocal-collapsedLabel" v-show="!expanded || isEmpty">
Expand Down
25 changes: 13 additions & 12 deletions cataloging/src/components/inspector/item-type.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { filter } from 'lodash-es';
import {filter, isEmpty} from 'lodash-es';
import { mapGetters } from 'vuex';
import * as VocabUtil from 'lxljs/vocab';
import * as DisplayUtil from 'lxljs/display';
Expand Down Expand Up @@ -31,15 +31,6 @@ export default {
...mapGetters([
'resources',
]),
range() {
const docType = VocabUtil.getRecordType(this.entityType, this.resources.vocab, this.resources.context);
const combined = [docType].concat(VocabUtil.getAllSubClasses(docType, this.resources.vocabClasses, this.resources.context));
const filtered = filter(combined, (o) => {
const term = VocabUtil.getTermObject(o, this.resources.vocab, this.resources.context);
return term.abstract !== true;
});
return filtered;
},
onMainEntity() {
return this.path === 'mainEntity.@type';
},
Expand All @@ -51,12 +42,22 @@ export default {
isDisabled() {
return this.onMainEntity && this.numberOfRelations !== 0 && this.unlockedByUser === false;
},
typeLabel() {
return this.fieldValue === 'Any' ? translatePhrase('Unspecified') : labelByLang(this.fieldValue);
}
},
methods: {
translatePhrase,
labelByLang,
getLabelWithTreeDepth(term) {
return DisplayUtil.getLabelWithTreeDepth(term, this.settings, this.resources);
if (isEmpty(term)) {
return;
}
if (term?.id === 'Any') {
return translatePhrase('Unspecified');
} else {
return DisplayUtil.getLabelWithTreeDepth(term, this.settings, this.resources);
}
},
unlockEdit() {
this.unlockedByUser = true;
Expand Down Expand Up @@ -148,7 +149,7 @@ export default {
</div>
<span
class="ItemType-text"
v-if="isLocked">{{ labelByLang(fieldValue) }}
v-if="isLocked">{{ typeLabel }}
</span>
<modal-component
title="Byte av typ"
Expand Down
34 changes: 27 additions & 7 deletions cataloging/src/components/mixins/form-mixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as DisplayUtil from 'lxljs/display';
import * as VocabUtil from 'lxljs/vocab';
import * as StringUtil from 'lxljs/string';
import DisplayGroups from '@/resources/json/displayGroups.json';
import {getAllVocabProperties, getProperties, getRangeFull, getSubClassChain} from "lxljs/vocab.js";
export default {
props: {
Expand Down Expand Up @@ -76,11 +77,23 @@ export default {
const docType = VocabUtil.getRecordType(this.formType, this.resources.vocab, this.resources.context);
tree = [docType].map((type) => VocabUtil.getTree(type, this.resources.vocab, this.resources.context));
}
return VocabUtil.flattenTree(tree, this.resources.vocab, this.resources.context, this.settings.language);
const flattenedTree = VocabUtil.flattenTree(tree, this.resources.vocab, this.resources.context, this.settings.language);
if (this.isBulkChange) {
return [this.anyType, ...flattenedTree];
} else {
return flattenedTree;
}
},
isMainEntityForm() {
return this.editingObject === 'mainEntity';
},
anyType() {
return { id: 'Any', sub: [], abstract : false, depth: 0, parentChainString: 'Any'};
},
isBulkChange() {
return this.$route.path.includes('bulkchanges');
},
formType() {
return this.formObj['@type'];
},
Expand Down Expand Up @@ -180,12 +193,19 @@ export default {
return propertyList;
},
allowed() {
return VocabUtil.getPropertiesFromArray(
this.formObj['@type'],
this.resources.vocabClasses,
this.resources.vocabProperties,
this.resources.context,
);
if (this.formType === 'Any') {
return this.allVocabProperties;
} else {
return VocabUtil.getPropertiesFromArray(
this.formObj['@type'],
this.resources.vocabClasses,
this.resources.vocabProperties,
this.resources.context,
);
}
},
allVocabProperties() {
return VocabUtil.getAllVocabProperties(this.resources.vocabProperties);
},
allowedProperties() {
const formObj = this.formObj;
Expand Down
1 change: 1 addition & 0 deletions cataloging/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
'PlaceholderRecord',
'CacheRecord',
'ComplexSubject.termComponentList',
'Any'
],
keysToClear: {
duplication: [
Expand Down
6 changes: 6 additions & 0 deletions lxljs/vocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ export function getPropertiesFromArray(typeArray, vocabClasses, vocabProperties,
return props;
}

export function getAllVocabProperties(vocabProperties) {
return [...vocabProperties].map( (prop) => {
return {'item' : prop[1] };
});
}

export function isEmbedded(classId, vocab, settings, context) {
if (!classId || typeof classId === 'undefined') {
throw new Error('isEmbedded was called with an undefined class id');
Expand Down

0 comments on commit 5a07be8

Please sign in to comment.