All files / src/BaseParam BaseParamToggle.vue.js

20% Statements 1/5
0% Branches 0/2
0% Functions 0/2
20% Lines 1/5

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                        1x                                                          
// @ts-check
 
import { invoke } from "lodash";
import Vue from "vue";
 
import ParamCard from "./ParamCard.vue";
import BaseToggle from "../BaseInput/BaseToggle.vue";
 
/**
 * @typedef {V.ExtVue<any,any> & V.Instance<BaseToggle>} Instance
 */
 
const component = /** @type {V.Constructor<any, any>} */(Vue).extend({
  name: "BaseParamToggle",
  components: { ParamCard },
  extends: BaseToggle,
  props: {
    title: { type: String, default: undefined }
  },
  computed: {
    /**
     * @this {Instance}
     * @return {boolean}
     */
    showEditIcon() {
      return this.hasFocus && this.hasEditRequest;
    }
  },
  methods: {
    /**
     * @this {Instance}
     * @param {boolean} value
     */
    emitEditRequest(value) {
      invoke(this.$refs, [ "input", "focus" ]);
      this.keepFocusOnNextTick("input");
      this.$emit("edit-request", value);
    }
  }
});
export default component;