Skip to content

Commit

Permalink
add ability to remove connections to collections in graph
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbocarsly authored and ml-evs committed Nov 27, 2024
1 parent 0dff4f2 commit 301d5e9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion webapp/src/components/ItemGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@

<label for="ignore-items">Ignore connections to items:</label>
<ItemSelect id="ignore-items" v-model="ignoreItems" multiple />

<label for="ignore-collections">Ignore connections to collections:</label>
<CollectionSelect id="ignore-collections" v-model="ignoreCollections" multiple />
</div>
</div>
<div id="cy" v-bind="$attrs" />
</template>

<script>
import ItemSelect from "@/components/ItemSelect.vue";
import CollectionSelect from "@/components/CollectionSelect.vue";
import { itemTypes } from "@/resources.js";
import cytoscape from "cytoscape";
import dagre from "cytoscape-dagre";
Expand Down Expand Up @@ -89,6 +93,7 @@ export default {
name: "ItemGraph",
components: {
ItemSelect,
CollectionSelect,
},
props: {
graphData: {
Expand All @@ -109,16 +114,22 @@ export default {
graphStyle: this.defaultGraphStyle,
optionsDisplayed: false,
ignoreItems: [],
ignoreCollections: [],
};
},
computed: {
filteredGraphData() {
const ignoredItemIds = this.ignoreItems.map((d) => d.item_id);
const ignoredCollectionIds = this.ignoreCollections.map(
(d) => `Collection: ${d.collection_id}`,
);
return {
edges: this.graphData.edges.filter(
(edge) =>
!(
ignoredItemIds.includes(edge.data.source) || ignoredItemIds.includes(edge.data.target)
ignoredItemIds.includes(edge.data.source) ||
ignoredItemIds.includes(edge.data.target) ||
ignoredCollectionIds.includes(edge.data.source)
),
),
nodes: this.graphData.nodes,
Expand All @@ -136,6 +147,9 @@ export default {
ignoreItems() {
this.generateCyNetworkPlot();
},
ignoreCollections() {
this.generateCyNetworkPlot();
},
},
async mounted() {
this.generateCyNetworkPlot();
Expand Down

0 comments on commit 301d5e9

Please sign in to comment.