Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toc vue implementation tweaks #1328

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions indigo_app/js/components/DocumentTOCView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
>
<template v-slot:right-icon="{item}">
<i :class="`float-right issue-icon issue-${item.issues_severity}`"
v-if="item.issues && item.issues.length"
v-if="item.issues.length"
data-toggle="popover"
:data-content="item.issues_description"
:data-title="item.issues_title"
Expand Down Expand Up @@ -79,7 +79,6 @@ export default {
titleQuery: "",
toc: [],
roots: [],
issuesState: null,
tocItems: [],
}
},
Expand Down Expand Up @@ -170,7 +169,11 @@ export default {
element: node,
type: node.localName,
id: qualified_id,
selected: false
selected: false,
issues: [],
issues_title: '',
issues_description: '',
issues_severity: ''
};
item.title = tradition.toc_element_title(item);
return item;
Expand All @@ -184,10 +187,6 @@ export default {
this.mergeIssues();
},

issuesChanged () {
this.mergeIssues();
},

mergeIssues () {
// fold document issues into the TOC
const withIssues = [];
Expand All @@ -196,7 +195,7 @@ export default {
entry.issues = [];
});

this.issuesState.each((issue) => {
this.issues.each((issue) => {
// find the toc entry for this issue
const element = issue.get('element');

Expand Down Expand Up @@ -287,7 +286,7 @@ export default {
},

watch: {
issuesState () { this.issuesChanged() }
issues () { this.mergeIssues(); }
},

updated() {
Expand All @@ -296,8 +295,6 @@ export default {

mounted() {
this.model.on('change:dom', this.rebuild, this);
this.issuesState = this.issues;
this.$nextTick(() => { this.$refs.tocController.expandAll(); })
}
}
</script>
2 changes: 1 addition & 1 deletion indigo_app/js/components/toc-controller/TOCItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
export default {
name: 'TOCItem',
data: () => ({
expanded: false,
expanded: true,
}),
props: {
item: {
Expand Down
3 changes: 2 additions & 1 deletion indigo_app/js/indigo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as vueComponents from "./components";
import Vue from "vue";

class IndigoApp {
setup() {
this.components = [];
this.Vue = indigoApp.Vue;
this.Vue = Vue;

this.registerVueComponents(vueComponents);
window.dispatchEvent(new Event("indigo.vue-components-registered"));
Expand Down
2 changes: 0 additions & 2 deletions indigo_app/js/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import app from "./indigo";
import Vue from "vue";

window.addEventListener("indigo.beforecreateviews", () => {
window.indigoApp = app;
window.indigoApp.Vue = Vue;
app.setup();
});
9 changes: 9 additions & 0 deletions indigo_app/static/javascript/indigo/views/document_toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

initialize: function(options) {
this.issues = options.document.issues;
this.listenTo(this.issues, 'reset change add remove', this.issuesChanged);

this.registeredComp = indigoApp.Vue.options.components.DocumentTOCView;
this.targetMountElement = document.getElementById("DocumentTOCView");
this.selection = new Backbone.Model({
Expand All @@ -31,9 +33,16 @@
}
},

issuesChanged: function () {
// force vue to realise the issues list has changed
this.compInstance.issues = [];
this.compInstance.issues = this.issues;
},

selectItem: function(i, force) {
if (this.compInstance) this.compInstance.selectItem(i, force);
},

selectItemById: function(itemId) {
if (this.compInstance) this.compInstance.selectItemById(itemId);
}
Expand Down