All files / src/BaseApp BaseWebApp.vue.js

62.5% Statements 5/8
0% Branches 0/2
80% Functions 4/5
71.42% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                        1x                       1x   2x     2x     2x                            
// @ts-check
 
import Vue from "vue";
 
import KeyboardEventMixin from "../mixins/BaseKeyboardEventMixin";
import { BaseStoreMixin } from "../store/utils";
 
/**
 * @typedef {typeof BaseVue.BaseModal} BaseModal
 * @typedef {{ sidebar: V.Instance<BaseModal> }} Refs
 */
 
const component = /** @type {V.Constructor<any, Refs>} */(Vue).extend({
  name: "BaseWebApp",
  mixins: [ KeyboardEventMixin({ local: false }), BaseStoreMixin ],
  props: {
    title: { type: String, default: "" },
    version: { type: String, default: "" },
    showRoutes: { type: Boolean, default: true },
    showThemeSwitcher: { type: Boolean, default: false },
    showAbout: { type: Boolean, default: false }
  },
  computed: {
    /** @return {boolean} */
    hasRouter() { return this.$route !== undefined; },
    /** @return {boolean} */
    showKeyHints() { return this.getBaseState([ "ui", "showKeyHints" ]); }
  },
  beforeMount() {
    this.dispatchBase("ui/applyTheme");
  },
  mounted() {
    this.onKey("ctrl-m-keydown", this.toggleSideBar);
  },
  methods: {
    /**
     * @param  {Event} event
     */
    toggleSideBar(event) {
      if (event) { event.preventDefault(); }
      this.$refs.sidebar.toggle();
    }
  }
});
 
export default component;