better cValue logic in shadow-control

This commit is contained in:
Henry Jameson 2024-10-07 01:31:22 +03:00
parent 97c058ebda
commit f75ea738ca
2 changed files with 10 additions and 13 deletions

View file

@ -82,9 +82,7 @@ const moveDn = () => {
} }
const add = () => { const add = () => {
const newModel = [...props.modelValue] const newModel = [...props.modelValue, props.getAddValue()]
newModel.push(props.getAddValue())
console.log(newModel)
emit('update:modelValue', newModel) emit('update:modelValue', newModel)
emit('update:selectedId', Math.max(newModel.length - 1, 0)) emit('update:selectedId', Math.max(newModel.length - 1, 0))

View file

@ -50,11 +50,8 @@ export default {
], ],
emits: ['update:modelValue', 'subShadowSelected'], emits: ['update:modelValue', 'subShadowSelected'],
data () { data () {
console.log('MODEL VALUE', this.modelValue, this.fallback)
return { return {
selectedId: 0, selectedId: 0
// TODO there are some bugs regarding display of array (it's not getting updated when deleting for some reason)
cValue: (this.modelValue ?? this.fallback ?? []).map(toModel)
} }
}, },
components: { components: {
@ -66,10 +63,15 @@ export default {
Popover, Popover,
ComponentPreview ComponentPreview
}, },
beforeUpdate () {
this.cValue = (this.modelValue ?? this.fallback ?? []).map(toModel)
},
computed: { computed: {
cValue: {
get () {
return (this.modelValue ?? this.fallback ?? []).map(toModel)
},
set (newVal) {
this.$emit('update:modelValue', newVal)
}
},
selectedType: { selectedType: {
get () { get () {
return typeof this.selected return typeof this.selected
@ -124,9 +126,6 @@ export default {
} }
}, },
watch: { watch: {
modelValue (value) {
if (!value) this.cValue = (this.modelValue ?? this.fallback ?? []).map(toModel)
},
selected (value) { selected (value) {
this.$emit('subShadowSelected', this.selectedId) this.$emit('subShadowSelected', this.selectedId)
} }