Line data Source code
1 : // @ts-check 2 : 3 : import Vue from "vue"; 4 : import PropertyMixin from "./PropertyMixin"; 5 : import BadgeButton from "../BadgeButton.vue"; 6 : import { getAttribute } from "../../utils/element"; 7 : import { parser } from "@cern/ssvg-engine"; 8 : 9 : 10 : /** 11 : * @typedef {typeof import("@cern/base-vue").BaseSelect} BaseSelect 12 : * @typedef {{ value: V.Instance<BaseSelect> }} Refs 13 : */ 14 : 15 : export default /** @type {V.Constructor<any, Refs>} */ (Vue).extend({ 16 : name: "PropertyEnumerated", 17 : components: { BadgeButton }, 18 : mixins: [ PropertyMixin ], 19 : computed: { 20 : /** @return {string[]} */ 21 : valueList() { 22 4 : try { 23 4 : return parser.parseList({ index: 0, value: getAttribute(this.property, "values") }, 24 : parser.parseString); 25 : } 26 : catch { 27 0 : return []; 28 : } 29 : } 30 : }, 31 : watch: { 32 3 : value() { this.$refs.value.editValue = this.value; } 33 : }, 34 : mounted() { 35 3 : this.$refs.value.editValue = this.value; 36 : }, 37 : methods: { 38 : onEdit() { 39 6 : if (!this.$refs.value.hasFocus) { return; } 40 0 : this.$store.commit("engine/updateState", { [this.name]: this.$refs?.value?.editValue }); 41 : } 42 : } 43 : });