hyperboria/library/js/components/BaseList.vue
the-superpirate d51e5ab65d - fix: Various fixes for release
- fix: Translation fixes
- fix: Various fixes
- feat: PB translations, configuration changes
- fix: Bugfixes

GitOrigin-RevId: 55f8b148c42a296162fc707c36a5146ca0073b4b
2021-01-29 11:26:51 +03:00

57 lines
1.0 KiB
Vue

<script>
export default {
name: 'BaseList',
props: {
value: {
type: Array,
default: function () { return [] }
},
typeName: {
type: String,
default: 'element'
},
getDisplayName: {
type: Function,
default: function (x) {
return x
}
},
afterProcess: {
type: Function,
default: function (x) {
return x
}
},
mutable: {
type: Boolean,
default: true
}
},
data () {
return {
newElement: null
}
},
methods: {
handleAddElementInit () {
this.$refs.newElementModal.show()
},
handleAddElementOk () {
let processed = this.afterProcess(this.newElement)
this.value.push(processed)
this.$emit('added', processed)
this.newElement = null
},
handleAddElementCancel () {
this.newElement = null
},
deleteElement (elementIndex) {
let deleted = this.value[elementIndex]
this.value.splice(elementIndex, 1)
this.$emit('deleted', deleted)
}
}
}
</script>