mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-11 05:19:41 +02:00
attempt to make chip component in settings dynamic fields
it's not updating data
This commit is contained in:
parent
4aecf483c1
commit
0993b8dbad
@ -409,7 +409,7 @@ window.app.component('lnbits-dynamic-fields', {
|
||||
data() {
|
||||
return {
|
||||
formData: null,
|
||||
rules: [val => !!val || 'Field is required']
|
||||
rules: [val => !!val || 'Field is required'],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -428,13 +428,45 @@ window.app.component('lnbits-dynamic-fields', {
|
||||
},
|
||||
handleValueChanged() {
|
||||
this.$emit('update:model-value', this.formData)
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.formData = this.buildData(this.options, this.modelValue)
|
||||
}
|
||||
})
|
||||
|
||||
window.app.component('lnbits-dynamic-chips', {
|
||||
template: '#lnbits-dynamic-chips',
|
||||
mixins: [window.windowMixin],
|
||||
props: ['modelValue'],
|
||||
data() {
|
||||
return {
|
||||
chip: '',
|
||||
chips: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addChip() {
|
||||
if (!this.chip) return
|
||||
this.chips.push(this.chip)
|
||||
this.chip = ''
|
||||
this.modelValue = this.chips.join(',')
|
||||
},
|
||||
removeChip(index) {
|
||||
this.chips.splice(index, 1)
|
||||
this.$emit('update:model-value', this.chips.join(','))
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (typeof this.modelValue === 'string') {
|
||||
this.chips = this.modelValue.split(',')
|
||||
} else {
|
||||
this.chips = [...this.modelValue]
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
window.app.component('lnbits-update-balance', {
|
||||
template: '#lnbits-update-balance',
|
||||
mixins: [window.windowMixin],
|
||||
|
@ -391,6 +391,12 @@
|
||||
style="display: none"
|
||||
:rules="applyRules(o.required)"
|
||||
></q-input>
|
||||
<div v-else-if="o.type === 'chips'">
|
||||
<lnbits-dynamic-chips
|
||||
:model-value="formData[o.name]"
|
||||
@update:model-value="handleValueChanged"
|
||||
></lnbits-dynamic-chips>
|
||||
</div>
|
||||
<q-input
|
||||
v-else
|
||||
v-model="formData[o.name]"
|
||||
@ -407,6 +413,32 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="lnbits-dynamic-chips">
|
||||
<q-input
|
||||
filled
|
||||
v-model="chip"
|
||||
@keydown.enter.prevent="addChip"
|
||||
type="text"
|
||||
label="wss://...."
|
||||
hint="Add relays"
|
||||
class="q-mb-md"
|
||||
>
|
||||
<q-btn @click="addChip" dense flat icon="add"></q-btn>
|
||||
</q-input>
|
||||
<div>
|
||||
<q-chip
|
||||
v-for="(chip, i) in chips"
|
||||
:key="chip"
|
||||
removable
|
||||
@remove="removeChip(i)"
|
||||
color="primary"
|
||||
text-color="white"
|
||||
:label="chip"
|
||||
>
|
||||
</q-chip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="lnbits-notifications-btn">
|
||||
<q-btn
|
||||
v-if="g.user.wallets"
|
||||
|
Loading…
x
Reference in New Issue
Block a user