Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Widgets/ListInput.vue
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | export default { | ||||
let value = this.input.value | let value = this.input.value | ||||
if (value) { | if (value) { | ||||
this.list.push(value) | this.list.push(value) | ||||
this.input.value = '' | this.input.value = '' | ||||
if (focus !== false) { | if (focus !== false) { | ||||
this.input.focus() | this.input.focus() | ||||
} | } | ||||
this.$emit('change', this.$el) | |||||
} | } | ||||
}, | }, | ||||
deleteItem(index) { | deleteItem(index) { | ||||
this.$delete(this.list, index) | this.$delete(this.list, index) | ||||
this.$emit('change', this.$el) | |||||
if (this.list.length == 1) { | if (this.list.length == 1) { | ||||
$(this.$el).removeClass('is-invalid') | $(this.$el).removeClass('is-invalid') | ||||
} | } | ||||
}, | }, | ||||
keyDown(e) { | keyDown(e) { | ||||
if (e.which == 13 && e.target.value) { | if (e.which == 13 && e.target.value) { | ||||
this.addItem() | this.addItem() | ||||
e.preventDefault() | e.preventDefault() | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |