From d2b6b1864dfb2b7f194da0f41b266ae3c051ac8f Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 31 Aug 2022 12:06:30 +0200 Subject: [PATCH] Polish password field component - Fix fetch reason from password_policy api - Pass error/success state correctly - Better align icon in helper text Signed-off-by: Carl Schwan --- src/components/NcInputField/NcInputField.vue | 2 ++ src/components/NcPasswordField/NcPasswordField.vue | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/NcInputField/NcInputField.vue b/src/components/NcInputField/NcInputField.vue index d0b8f1ecaa..387044feb7 100644 --- a/src/components/NcInputField/NcInputField.vue +++ b/src/components/NcInputField/NcInputField.vue @@ -396,6 +396,8 @@ export default { &__icon { margin-right: 8px; + align-self: start; + margin-top: 4px; } &--error { diff --git a/src/components/NcPasswordField/NcPasswordField.vue b/src/components/NcPasswordField/NcPasswordField.vue index 53656c37ad..2a0b2c2adb 100644 --- a/src/components/NcPasswordField/NcPasswordField.vue +++ b/src/components/NcPasswordField/NcPasswordField.vue @@ -97,6 +97,8 @@ export default { :type="isPasswordHidden ? 'password' : 'text'" :show-trailing-button="true" :helper-text="computedHelperText" + :error="computedError" + :success="computedSuccess" :minlength="rules.minlength" :trailing-button-label="trailingButtonLabel" v-on="$listeners" @@ -290,16 +292,16 @@ export default { isPasswordHidden: true, internalHelpMessage: '', passwordPolicy: defaultPasswordPolicy, - isValid: true, + isValid: null, } }, computed: { computedError() { - return this.error || !this.isValid + return this.error || this.isValid === false }, computedSuccess() { - return this.success && this.isValid + return this.success || this.isValid === true }, computedHelperText() { if (this.helperText.length > 0) { @@ -358,7 +360,7 @@ export default { return } - this.internalHelpMessage = data.reason + this.internalHelpMessage = data.ocs.data.reason /** * Triggers when the internal password_policy detect that the * password entered is invalid.