Skip to content

Commit

Permalink
fixes: #57
Browse files Browse the repository at this point in the history
  • Loading branch information
moisbo committed Oct 12, 2023
1 parent 61d5eca commit c3716de
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crate-o",
"version": "0.1.47",
"version": "0.2.0",
"type": "module",
"private": true,
"scripts": {
Expand Down
24 changes: 16 additions & 8 deletions src/components/CrateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
}
Expand All @@ -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'])}});
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Entity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions src/default_layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"http://schema.org/hasFile",
"http://schema.org/inDefinedTermSet",
"http://schema.org/hasDefinedTerm"

]
},
{
Expand All @@ -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"
]
},
{
Expand Down

0 comments on commit c3716de

Please sign in to comment.