From 015d5432df6a23666662a96d7b9e41e1e9f4234c Mon Sep 17 00:00:00 2001 From: Arkadiusz Sygulski Date: Tue, 30 Apr 2024 21:01:38 +0200 Subject: [PATCH] Add `sensitive` option to config to treat a field like a password --- src/components/Config/Fields/Input.vue | 3 +++ src/components/Config/Fields/InputString.vue | 22 +++++++++++++++++++- src/views/ASFConfig.vue | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/Config/Fields/Input.vue b/src/components/Config/Fields/Input.vue index 85d5c8299..71b4711e1 100644 --- a/src/components/Config/Fields/Input.vue +++ b/src/components/Config/Fields/Input.vue @@ -54,6 +54,9 @@ errorText() { return this.errors.map(error => `Value is ${error}!`).join(' '); }, + sensitive() { + return !!this.schema.sensitive; + }, }, watch: { value: { diff --git a/src/components/Config/Fields/InputString.vue b/src/components/Config/Fields/InputString.vue index 1c0965e69..0563e4f53 100644 --- a/src/components/Config/Fields/InputString.vue +++ b/src/components/Config/Fields/InputString.vue @@ -3,7 +3,7 @@
- + {{ errorText }}
@@ -17,11 +17,31 @@ export default { name: 'InputString', mixins: [Input], + data() { + return { + active: false, + }; + }, + computed: { + fieldType() { + if (this.sensitive && !this.active) { + return 'password'; + } + + return 'text'; + }, + }, methods: { + onFocus() { + this.active = true; + }, onBlur() { + this.active = false; if (this.value === '') this.value = this.defaultValue; }, onKeyPress($event) { + this.active = true; + if (this.schema.type !== 'uint64') return true; const charCode = ($event.which) ? $event.which : $event.keyCode; diff --git a/src/views/ASFConfig.vue b/src/views/ASFConfig.vue index 30f7c9c7f..f45b5789a 100644 --- a/src/views/ASFConfig.vue +++ b/src/views/ASFConfig.vue @@ -106,6 +106,7 @@ const extendedFields = { IPCPassword: { placeholder: this.$t('keep-unchanged') }, + LicenseID: { sensitive: true }, }; this.fields = Object.keys(fields).map(key => {