Skip to content

Commit

Permalink
Always use modifyItem when items are modified (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Nov 18, 2021
1 parent b693991 commit 5a58ab7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/components/ConceptDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ import computed from "../mixins/computed.js"
import hotkeys from "../mixins/hotkeys.js"
import mappedStatus from "../mixins/mapped-status.js"
import { getItem, getItems, loadConcepts, saveItem } from "@/items"
import { getItem, getItems, loadConcepts, modifyItem, saveItem } from "@/items"
/**
* Component that displays an item's (either scheme or concept) details (URI, notation, identifier, ...).
Expand Down Expand Up @@ -526,12 +526,12 @@ export default {
await loadConcepts(gndConcepts)
// Set property "__GNDMAPPINGS__" for item
this.$set(itemBefore, "__GNDMAPPINGS__", mappings)
modifyItem(itemBefore, "__GNDMAPPINGS__", mappings)
},
async loadColiAna() {
const api = this.config["coli-ana"]
if (!api) return
const itemBefore = this._item
const itemBefore = getItem(this._item, { relatedItems: true })
if (!itemBefore) return
if (itemBefore.memberList) {
// Data already loaded
Expand All @@ -557,7 +557,7 @@ export default {
})
})
// Save memberList to item
this.$set(
modifyItem(
itemBefore,
"memberList",
resultConcept.memberList.map(member => member ? { uri: member.uri } : null),
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/cdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import jskos from "jskos-tools"
import { cdk } from "cocoda-sdk"
import _ from "lodash"
import computed from "./computed.js"
import { getItem, getItems, saveItem, schemes } from "@/items"
import { getItem, getItems, modifyItem, saveItem, schemes } from "@/items"

let objects = {}
let topConcepts = {}
Expand Down Expand Up @@ -153,7 +153,7 @@ export default {
if (targetScheme) {
for (let concept of sourceConcepts) {
if (!concept.__MAPPED__) {
this.$set(concept, "__MAPPED__", [])
modifyItem(concept, "__MAPPED__", [])
}
const existing = concept.__MAPPED__.find(item => jskos.compareFast(item.registry, registry) && jskos.compare(item.scheme, targetScheme))
if (existing && !existing.exist.length) {
Expand Down
6 changes: 3 additions & 3 deletions src/mixins/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import _ from "lodash"
import FileSaver from "file-saver"
import jskos from "jskos-tools"
import { getItem, loadAncestors, loadConcepts, loadNarrower, loadTop, loadTypes, saveItem } from "@/items"
import { getItem, loadAncestors, loadConcepts, loadNarrower, loadTop, loadTypes, modifyItem, saveItem } from "@/items"

// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
function escapeRegExp(string) {
Expand Down Expand Up @@ -165,7 +165,7 @@ export default {
// Load information about its broader concepts
if (concept.broader && !concept.__BROADERLOADED__) {
loadConcepts(concept.broader.filter(Boolean), { scheme }).then(() => {
this.$set(concept, "__BROADERLOADED__", true)
modifyItem(concept, "__BROADERLOADED__", true)
})
}

Expand Down Expand Up @@ -283,7 +283,7 @@ export default {
if (!concept) return
let open = Object.assign({}, concept.__ISOPEN__)
open[isLeft] = isOpen
this.$set(concept, "__ISOPEN__", open)
modifyItem(concept, "__ISOPEN__", open)
},
/**
* Uses the mouse position to determine whether it is hovering over an element.
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/mapped-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mixin regarding mapped status for concepts.
*/

import { getItems } from "@/items"
import { getItems, modifyItem } from "@/items"
import _ from "lodash"
import objects from "./cdk.js"

Expand Down Expand Up @@ -56,7 +56,7 @@ export default {
}))).then(() => {
// Set to false for every concept that still has no entry for current registry + other scheme
for (let concept of concepts.filter(c => !_.get(c, "__MAPPED__", []).find(item => this.$jskos.compareFast(item.registry, registry) && this.$jskos.compare(item.scheme, otherScheme)))) {
this.$set(concept, "__MAPPED__", [])
modifyItem(concept, "__MAPPED__", [])
concept.__MAPPED__.push({
registry,
scheme: otherScheme,
Expand Down

0 comments on commit 5a58ab7

Please sign in to comment.