2020-03-13 15:44:24 +05:30
|
|
|
<script>
|
|
|
|
import { mapActions, mapState } from 'vuex';
|
2020-04-22 19:07:51 +05:30
|
|
|
import eventHub from '../../notes/event_hub';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Popover from './popover.vue';
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Popover,
|
|
|
|
},
|
2022-05-07 20:08:51 +05:30
|
|
|
props: {
|
|
|
|
codeNavigationPath: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
blobPath: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
pathPrefix: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
computed: {
|
2020-05-24 23:13:21 +05:30
|
|
|
...mapState([
|
|
|
|
'currentDefinition',
|
|
|
|
'currentDefinitionPosition',
|
|
|
|
'currentBlobPath',
|
|
|
|
'definitionPathPrefix',
|
|
|
|
]),
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
mounted() {
|
2022-05-07 20:08:51 +05:30
|
|
|
if (this.codeNavigationPath && this.blobPath && this.pathPrefix) {
|
|
|
|
const initialData = {
|
|
|
|
blobs: [{ path: this.blobPath, codeNavigationPath: this.codeNavigationPath }],
|
|
|
|
definitionPathPrefix: this.pathPrefix,
|
|
|
|
};
|
|
|
|
this.setInitialData(initialData);
|
|
|
|
}
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
this.body = document.body;
|
|
|
|
|
|
|
|
eventHub.$on('showBlobInteractionZones', this.showBlobInteractionZones);
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
this.addGlobalEventListeners();
|
|
|
|
this.fetchData();
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2020-04-22 19:07:51 +05:30
|
|
|
eventHub.$off('showBlobInteractionZones', this.showBlobInteractionZones);
|
2020-03-13 15:44:24 +05:30
|
|
|
this.removeGlobalEventListeners();
|
|
|
|
},
|
|
|
|
methods: {
|
2022-05-07 20:08:51 +05:30
|
|
|
...mapActions(['fetchData', 'showDefinition', 'showBlobInteractionZones', 'setInitialData']),
|
2020-03-13 15:44:24 +05:30
|
|
|
addGlobalEventListeners() {
|
2020-04-22 19:07:51 +05:30
|
|
|
if (this.body) {
|
|
|
|
this.body.addEventListener('click', this.showDefinition);
|
2020-03-13 15:44:24 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
removeGlobalEventListeners() {
|
2020-04-22 19:07:51 +05:30
|
|
|
if (this.body) {
|
|
|
|
this.body.removeEventListener('click', this.showDefinition);
|
2020-03-13 15:44:24 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<popover
|
|
|
|
v-if="currentDefinition"
|
|
|
|
:position="currentDefinitionPosition"
|
|
|
|
:data="currentDefinition"
|
2020-04-22 19:07:51 +05:30
|
|
|
:definition-path-prefix="definitionPathPrefix"
|
2020-05-24 23:13:21 +05:30
|
|
|
:blob-path="currentBlobPath"
|
2020-03-13 15:44:24 +05:30
|
|
|
/>
|
|
|
|
</template>
|