Skip to content

Commit

Permalink
Give more control for QueryResultList to the place it is used in.
Browse files Browse the repository at this point in the history
Adjust ClassList, GraphList, InstanceList accordingly and add the
respective functionality to App.vue
  • Loading branch information
white-gecko committed Aug 16, 2024
1 parent 6fb3a03 commit eeaa59a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import 'splitpanes/dist/splitpanes.css'
<pane size="30">
<splitpanes horizontal style="height: 80vh">
<pane size="30">
<GraphList/>
<GraphList :graph_iri="graph_iri" :selectGraph="(iri) => {useSelectionStore().changeGraphIri(iri); useSelectionStore().changeResourceIri(iri)}" />
</pane>
<pane size="70">
<ClassList/>
<ClassList :class_iri="resource_iri" :selectClass="(iri) => {useSelectionStore().changeResourceIri(iri)}" />
</pane>
</splitpanes>
</pane>
Expand Down Expand Up @@ -51,6 +51,7 @@ import 'splitpanes/dist/splitpanes.css'
<script>
import { mapState } from 'pinia'
import { useRdfStore } from './stores/rdf'
import { useSelectionStore } from './stores/selection'
export default {
name: 'App',
Expand All @@ -60,6 +61,7 @@ export default {
},
computed: {
...mapState(useRdfStore, {store_ready: store => store.ready}),
...mapState(useSelectionStore, ['graph_iri', 'resource_iri'])
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/ClassList.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<script setup>
import QueryResultList from './QueryResultList.vue'
import { mapState } from 'pinia'
import { useSelectionStore } from '../stores/selection'
</script>

<template>
<QueryResultList title="Class List" search query="select distinct ?class { {?s a ?class} union {?class a <http://www.w3.org/2000/01/rdf-schema#Class>} union {?class a <http://www.w3.org/2002/07/owl#Class>} } order by ?class" select-variable="class" ref="classList" :activeResource="resource_iri" />
<QueryResultList title="Class List" search query="select distinct ?class { {?s a ?class} union {?class a <http://www.w3.org/2000/01/rdf-schema#Class>} union {?class a <http://www.w3.org/2002/07/owl#Class>} } order by ?class" select-variable="class" ref="classList" :activeResource="class_iri" :selectResource="selectClass" />
</template>

<script>
import { mapState } from 'pinia'
export default {
name: 'ClassList',
components: {
QueryResultList
props: {
class_iri: String,
selectClass: Function
},
watch: {
graph_iri (value) {
Expand All @@ -22,7 +23,7 @@ export default {
}
},
computed: {
...mapState(useSelectionStore, ['graph_iri', 'resource_iri'])
...mapState(useSelectionStore, ['graph_iri'])
}
}
Expand Down
17 changes: 6 additions & 11 deletions src/components/GraphList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<QueryResultList title="Graph List" search query="select distinct ?graph { graph ?graph {?s ?p ?o}} order by ?graph" query-quads select-variable="graph" ref="classList" :add="() => {add_graph_modal.show()}" :selectResource="(graphIri) => {select(graphIri)}" :activeResource="graph_iri"/>
<QueryResultList title="Graph List" search query="select distinct ?graph { graph ?graph {?s ?p ?o}} order by ?graph" query-quads select-variable="graph" ref="classList" :add="() => {add_graph_modal.show()}" :selectResource="selectGraph" :activeResource="graph_iri" />
<div class="modal fade" ref="add_graph" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" size="lg">
<div class="modal-dialog modal-lg">
<div class="modal-content">
Expand Down Expand Up @@ -31,7 +31,6 @@
<script>
import { mapState } from 'pinia'
import { useRdfStore } from '../stores/rdf'
import { useSelectionStore } from '../stores/selection'
import { Modal } from 'bootstrap'
import rdf from '@rdfjs/data-model'
Expand All @@ -42,13 +41,16 @@ export default {
name: 'GraphList',
setup () {
const store = useRdfStore();
const selection = useSelectionStore();
return { store, selection }
return { store }
},
components: {
TermInput,
QueryResultList
},
props: {
graph_iri: String,
selectGraph: Function
},
data () {
return {
graphs: [],
Expand All @@ -59,14 +61,7 @@ export default {
mounted() {
this.add_graph_modal = new Modal(this.$refs.add_graph)
},
computed: {
...mapState(useSelectionStore, ['graph_iri'])
},
methods: {
select (graph) {
this.selection.changeGraphIri(graph)
this.selection.changeResourceIri(graph)
},
async add_graph () {
const newGraphData = [rdf.quad(this.new_graph_iri, rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdf.namedNode('http://www.w3.org/2000/01/rdf-schema#Graph'))]
console.log(this.new_graph_iri)
Expand Down
12 changes: 6 additions & 6 deletions src/components/InstanceList.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<script setup>
import { useSelectionStore } from '../stores/selection'
import QueryResultList from './QueryResultList.vue'
</script>

<template>
<QueryResultList title="Instance List" search :query="'select distinct ?instance { ?instance a <' + resource_iri + '> } order by ?instance'" select-variable="instance" itemClass="py-2" ref="instanceList" />
<QueryResultList title="Instance List" search :query="'select distinct ?instance { ?instance a <' + resource_iri + '> } order by ?instance'" select-variable="instance" itemClass="py-2" ref="instanceList" :activeResource="resource_iri" :selectResource="(iri) => {useSelectionStore().changeResourceIri(iri)}" />
</template>

<script>
import QueryResultList from './QueryResultList.vue'
import { mapState } from 'pinia'
import { useSelectionStore } from '../stores/selection'
export default {
name: 'InstanceList',
components: {
QueryResultList
},
computed: {
...mapState(useSelectionStore, ['resource_iri'])
},
Expand Down
2 changes: 0 additions & 2 deletions src/components/QueryResultList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ export default {
select (resource) {
if (this.selectResource) {
this.selectResource(resource)
} else {
this.selection.changeResourceIri(resource)
}
},
async updateList () {
Expand Down

0 comments on commit eeaa59a

Please sign in to comment.