Vue.component("origin-input-box", { props: ["v-family", "v-oss-types"], data: function () { let family = this.vFamily if (family == null) { family = "http" } let ossTypes = this.vOssTypes if (ossTypes == null) { ossTypes = [] } return { origins: [], isAdding: false, family: family, ossTypes: ossTypes } }, methods: { add: function () { let scheme = "" switch (this.family) { case "http": scheme = "http" break case "tcp": scheme = "tcp" break case "udp": scheme = "udp" break } this.origins.push({ id: "", host: "", isPrimary: true, isPrimaryValue: 1, scheme: scheme }) let that = this setTimeout(function () { let inputs = that.$refs.originHost if (inputs != null) { inputs[inputs.length - 1].focus() } }, 10) }, confirm: function () { }, cancel: function () { }, remove: function (index) { this.origins.$remove(index) }, changePrimary: function (origin) { origin.isPrimary = origin.isPrimaryValue == 1 }, changeFamily: function (family) { this.family = family let that = this this.origins.forEach(function (origin) { let scheme = "" switch (that.family) { case "http": scheme = "http" break case "tcp": scheme = "tcp" break case "udp": scheme = "udp" break } origin.scheme = scheme }) } }, template: `
` })