From 4f5a91f607f4277d9b222341e73cb26a45c5d3a4 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 2 Mar 2021 13:36:33 +0100 Subject: [PATCH] fix(ui): correctly get/set buffer values (#795) fix(ui): correctly get/set buffer values --- src/components/ValueId.vue | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/ValueId.vue b/src/components/ValueId.vue index 1285d608e2e..16da94f5c00 100644 --- a/src/components/ValueId.vue +++ b/src/components/ValueId.vue @@ -8,7 +8,7 @@ :suffix="value.unit" :hint="help" persistent-hint - v-model="value.value" + v-model="parsedValue" > @@ -38,14 +38,14 @@ > @@ -221,7 +221,7 @@ export default { return { durations: ['seconds', 'minutes'], menu: false, - error: false + error: null } }, computed: { @@ -260,27 +260,28 @@ export default { this.value.newValue = v ? v.substr(1, 7) : null } }, - parsedAny: { + parsedValue: { get: function () { if (this.value.type === 'any') { - if (typeof this.value.newValue === 'object') { - return JSON.stringify(this.value.newValue) - } + return JSON.stringify(this.value.newValue) + } else if (this.value.type === 'buffer') { + return this.value.newValue && this.value.newValue.toString('hex') } return this.value.newValue }, set: function (v) { - if (this.value.type === 'any') { - if (typeof this.value.value === 'object') { - try { - this.value.newValue = JSON.parse(v) - this.error = false - } catch (error) { - this.error = 'Value not valid' - } + try { + if (this.value.type === 'any') { + this.value.newValue = JSON.parse(v) + } else if (this.value.type === 'buffer') { + this.value.newValue = Buffer.from(v, 'hex') + } else { + this.value.newValue = v } - } else { - this.value.newValue = v + + this.error = null + } catch (error) { + this.error = 'Value not valid' } } },