| <template> |
| <a :class="linkClass" @click.prevent="goToMenuPath" v-html="titleToUse"></a> |
| </template> |
|
|
| <script lang="ts"> |
| import { Options, Vue } from "vue-class-component"; |
| import { Prop } from "vue-property-decorator"; |
| import MenuLevel1 from "./Menu/MenuLevel1.vue"; |
| |
| import { PluginParentClass } from "@/Plugins/Parents/PluginParentClass/PluginParentClass"; |
| import { loadedPlugins } from "@/Plugins/LoadedPlugins"; |
| import { messagesApi } from "@/Api/Messages"; |
| import { pluginsApi } from "@/Api/Plugins"; |
| import { delayForPopupOpenClose } from "@/Core/GlobalVars"; |
| |
| |
| |
| |
| @Options({ |
| components: { |
| MenuLevel1, |
| }, |
| }) |
| export default class PluginPathLink extends Vue { |
| @Prop({ required: true }) plugin!: PluginParentClass | string; |
| @Prop({ default: undefined }) title!: string | undefined; |
| @Prop({ default: "link-primary" }) linkClass!: string; |
| pluginToUse: PluginParentClass | null = null; |
| |
| |
| |
| |
| |
| |
| get titleToUse(): string { |
| if (this.pluginToUse === null) { |
| |
| return ""; |
| } |
| |
| if (this.title !== undefined) { |
| return this.title; |
| } |
| |
| |
| if (this.pluginToUse.menuPath === null) { |
| return ""; |
| } |
| |
| |
| let menuPath = Array.isArray(this.pluginToUse.menuPath) |
| ? this.pluginToUse.menuPath.join("/") |
| : this.pluginToUse.menuPath; |
| |
| |
| menuPath = menuPath.replace(/\[\d+\] /g, ""); |
| |
| menuPath = menuPath.replace(/\//g, " → "); |
| |
| return menuPath; |
| } |
| |
| |
| |
| |
| goToMenuPath() { |
| pluginsApi.closeAllPlugins(); |
| |
| const waitId = messagesApi.startWaitSpinner(); |
| |
| setTimeout(() => { |
| if (this.pluginToUse !== null) { |
| this.pluginToUse.menuOpenPlugin(); |
| messagesApi.stopWaitSpinner(waitId); |
| } |
| }, delayForPopupOpenClose); |
| } |
| |
| |
| |
| |
| mounted() { |
| if (typeof this.plugin === "string") { |
| |
| const interval = setInterval(() => { |
| const plugin = loadedPlugins[this.plugin as string]; |
| if (plugin !== undefined) { |
| this.pluginToUse = plugin; |
| clearInterval(interval); |
| } |
| }, 100); |
| } else { |
| this.pluginToUse = this.plugin; |
| } |
| } |
| } |
| </script> |
|
|
| |
| <style scoped lang="scss"></style> |
|
|