diff --git a/resources/js/components/formElements/FieldError.vue b/resources/js/components/formElements/FieldError.vue index f4e8f0fb..860a4d0a 100644 --- a/resources/js/components/formElements/FieldError.vue +++ b/resources/js/components/formElements/FieldError.vue @@ -7,6 +7,10 @@ field: { type: String, required: true + }, + alertType: { + type: String, + default: 'is-danger' } }) @@ -14,7 +18,8 @@ \ No newline at end of file diff --git a/resources/js/components/formElements/FormLockField.vue b/resources/js/components/formElements/FormLockField.vue index 58ec66ef..6ff28723 100644 --- a/resources/js/components/formElements/FormLockField.vue +++ b/resources/js/components/formElements/FormLockField.vue @@ -9,7 +9,8 @@ const { inputId } = useIdGenerator(props.inputType, props.fieldName) const props = defineProps({ - modelValue: [String, Number, Boolean], + modelValue: String, + modelModifiers: { default: () => ({}) }, isEditMode: { type: Boolean, default: false @@ -55,15 +56,45 @@ }) const fieldIsLocked = ref(props.isDisabled || props.isEditMode) + const hasBeenTrimmed = ref(false) + const componentKey = ref(0); + + const emit = defineEmits(['input:modelValue']) + + /** + * Removes spaces from the input string + */ + function emitValue(e) { + let value = e.target.value + + + if (props.modelModifiers.trimAll) { + value = value.replace(/\s+/g, '') + } + + emit('update:modelValue', value) + } + + function alertOnSpace(e) { + let value = e.target.value + hasBeenTrimmed.value = value.includes(' ') + + emit('update:modelValue', value) + } + + function forceRefresh(e) { + hasBeenTrimmed.value = e.target.value.includes(' ') + componentKey.value += 1 + } + diff --git a/resources/js/views/twofaccounts/CreateUpdate.vue b/resources/js/views/twofaccounts/CreateUpdate.vue index 064e6ac8..f1c58c88 100644 --- a/resources/js/views/twofaccounts/CreateUpdate.vue +++ b/resources/js/views/twofaccounts/CreateUpdate.vue @@ -461,7 +461,7 @@
- +

{{ $t('commons.options') }}

diff --git a/resources/lang/en/twofaccounts.php b/resources/lang/en/twofaccounts.php index 08ad1e6c..086877e5 100644 --- a/resources/lang/en/twofaccounts.php +++ b/resources/lang/en/twofaccounts.php @@ -96,6 +96,7 @@ ], 'options_help' => 'You can leave the following options blank if you don\'t know how to set them. The most commonly used values will be applied.', 'alternative_methods' => 'Alternative methods', + 'spaces_are_ignored' => 'Unwanted spaces will be automatically removed' ], 'stream' => [ 'live_scan_cant_start' => 'Live scan can\'t start :(',