From c3716debd56a60cac60639926c9b018ab5c3163d Mon Sep 17 00:00:00 2001 From: Moises Sacal Date: Thu, 12 Oct 2023 16:09:43 +1100 Subject: [PATCH] fixes: https://github.com/Language-Research-Technology/crate-o/issues/57 --- package-lock.json | 4 ++-- package.json | 2 +- src/components/CrateEditor.vue | 24 ++++++++++++++++-------- src/components/EditorState.js | 2 +- src/components/Entity.vue | 2 +- src/default_layout.json | 7 ++++--- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 86e8861..8055885 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10438,7 +10438,7 @@ }, "node_modules/ro-crate-editor-profiles": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Language-Research-Technology/ro-crate-editor-profiles.git#9c1609248bfdb11e8bfcac1038d4737d5139bc1f", + "resolved": "git+ssh://git@github.com/Language-Research-Technology/ro-crate-editor-profiles.git#ab03b70a529afdad1d33258531d6d1dd2b54ec95", "license": "GPL-3.0" }, "node_modules/ro-crate-excel": { @@ -20624,7 +20624,7 @@ } }, "ro-crate-editor-profiles": { - "version": "git+ssh://git@github.com/Language-Research-Technology/ro-crate-editor-profiles.git#9c1609248bfdb11e8bfcac1038d4737d5139bc1f", + "version": "git+ssh://git@github.com/Language-Research-Technology/ro-crate-editor-profiles.git#ab03b70a529afdad1d33258531d6d1dd2b54ec95", "from": "ro-crate-editor-profiles@github:Language-Research-Technology/ro-crate-editor-profiles" }, "ro-crate-excel": { diff --git a/package.json b/package.json index 851f6d1..cb167bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crate-o", - "version": "0.1.47", + "version": "0.2.0", "type": "module", "private": true, "scripts": { diff --git a/src/components/CrateEditor.vue b/src/components/CrateEditor.vue index b8f2833..f223428 100644 --- a/src/components/CrateEditor.vue +++ b/src/components/CrateEditor.vue @@ -132,8 +132,12 @@ watch(() => props.profile, (profile) => { newEntityUpdate(); }, {immediate: true}); -const unlinkedEntities = computed(() => state.entities.filter(e => e['@reverse'] === undefined)); -const reverseEntities = computed(() => Object.values(data.entity?.['@reverse'] || {}).reduce((a, e) => a.concat(e), []).filter(e => e !== state.crate.metadataFileEntity)); +const unlinkedEntities = computed(() => state.entities.filter(e => { + //TODO: make this into an utility function because we are doing this in many parts + const linksCount = Object.values(e['@reverse']).reduce((count, refs) => count + refs.length, 0); + return linksCount <= 0; +})); +//const reverseEntities = computed(() => Object.values(data.entity?.['@reverse'] || {}).reduce((a, e) => a.concat(e), []).filter(e => e !== state.crate.metadataFileEntity)); const forceKey = ref(0); defineExpose({ @@ -176,8 +180,9 @@ function onSelectNewEntity(type) { "name": [cleanName] }; state.crate.addEntity(item, {replace: true, recurse: true}); + const newEntity = state.crate.getEntity(item['@id']) state.ensureContext(type); - state.entities.push(item); + state.entities.push(newEntity); showEntity(item); } @@ -188,13 +193,16 @@ function deleteEntity() { const entityMessage = linksCount > 1 ? 'entities' : 'entity'; if (linksCount === 0 || window.confirm(`This entity is referenced by ${linksCount} other ${entityMessage}. Are you sure you want to delete it?`)) { const currentEntity = data.entity; + const i = state.entities.findIndex(e => e['@id'] === currentEntity['@id']); if (i >= 0) state.entities.splice(i, 1); - data.history.pop(); - data.entity = null; - state.crate.deleteEntity(currentEntity, {references: true}); - const someEntity = data.history[data.history.length - 1] ?? data.rootDataset; - $router.push({query: {id: encodeURIComponent(someEntity['@id'])}}); + nextTick(() => { + data.history.pop(); + data.entity = null; + state.crate.deleteEntity(currentEntity, {references: true}); + const someEntity = data.history[data.history.length - 1] ?? data.rootDataset; + $router.push({query: {id: encodeURIComponent(someEntity['@id'])}}); + }) } } diff --git a/src/components/EditorState.js b/src/components/EditorState.js index f1b3f97..33b7098 100644 --- a/src/components/EditorState.js +++ b/src/components/EditorState.js @@ -94,7 +94,7 @@ export class EditorState { const crate = this.crate = new ROCrate(rawCrate, { array: true, link: true }); var mid = this.metadataFileEntityId = crate.metadataFileEntity['@id']; this.meta = reactive({}); - this.entities = shallowReactive(Array.from(crate.entities({ filter: e => e['@id'] !== mid }))); + this.entities = reactive(Array.from(crate.entities({ filter: e => e['@id'] !== mid }))); await crate.resolveContext(); return crate; } diff --git a/src/components/Entity.vue b/src/components/Entity.vue index 5d7242b..b17e766 100644 --- a/src/components/Entity.vue +++ b/src/components/Entity.vue @@ -44,7 +44,7 @@ watch(() => $route.query.prop, (eProp, oldProp) => { const activeGroup = computed({ get() { - console.log('get:currentProperty', props.currentProperty) + //console.log('get:currentProperty', props.currentProperty) return state.meta[props.modelValue['@id']]?.__activeLayout || 'About'; }, set(val) { diff --git a/src/default_layout.json b/src/default_layout.json index bb45993..5cf4a48 100644 --- a/src/default_layout.json +++ b/src/default_layout.json @@ -44,7 +44,6 @@ "http://schema.org/hasFile", "http://schema.org/inDefinedTermSet", "http://schema.org/hasDefinedTerm" - ] }, { @@ -66,8 +65,10 @@ "http://schema.org/temporalCoverage", "http://schema.org/spatialCoverage", "http://schema.org/contentLocation", - "http://schema.org/locationCreated" - + "http://schema.org/locationCreated", + "http://schema.org/geo", + "http://www.opengis.net/ont/geosparql#asWKT", + "http://schema.org/address" ] }, {