bfg-common 1.4.316 → 1.4.318
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue +1 -1
- package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePasswordNew.vue +57 -16
- package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts +6 -0
- package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/utils.ts +11 -0
- package/package.json +1 -1
package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePasswordNew.vue
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
/>
|
|
20
20
|
|
|
21
21
|
<p class="change-password__description">
|
|
22
|
-
|
|
23
|
-
is different from any of your previous passwords.
|
|
22
|
+
{{ localization.common.changePasswordDesc }}
|
|
24
23
|
</p>
|
|
25
24
|
|
|
26
25
|
<div class="change-password__form">
|
|
@@ -30,6 +29,7 @@
|
|
|
30
29
|
:label="localization.auth.password"
|
|
31
30
|
:error="passwordErrorText"
|
|
32
31
|
type="password"
|
|
32
|
+
:autocomplete="'new-password'"
|
|
33
33
|
></ui-input>
|
|
34
34
|
|
|
35
35
|
<ui-input
|
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
import type { UI_I_Localization } from '~//lib/models/interfaces'
|
|
60
60
|
import type { UI_I_FormChangePassword } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
61
61
|
import type { UI_T_Project } from '~/lib/models/types'
|
|
62
|
+
import type { UI_I_InitialValidationFields } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
63
|
+
import { getPasswordMismatchError } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/utils'
|
|
62
64
|
|
|
63
65
|
const props = defineProps<{
|
|
64
66
|
project: UI_T_Project
|
|
@@ -72,32 +74,68 @@ const modelLocal = defineModel<UI_I_FormChangePassword>({ required: true })
|
|
|
72
74
|
|
|
73
75
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
const initValidationFields = ref<UI_I_InitialValidationFields>({
|
|
78
|
+
currentPassword: false,
|
|
79
|
+
newPassword: false,
|
|
80
|
+
confirmPassword: false,
|
|
81
|
+
})
|
|
82
|
+
const initValidation = (types: string[]): boolean => {
|
|
83
|
+
types.forEach((type) => (initValidationFields.value[type] = true))
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
!!passwordErrorText.value ||
|
|
87
|
+
!!newPasswordErrorText.value ||
|
|
88
|
+
!!confirmPasswordErrorText.value
|
|
89
|
+
)
|
|
90
|
+
}
|
|
77
91
|
|
|
78
92
|
const passwordErrorText = computed<string>(() => {
|
|
79
|
-
return ''
|
|
93
|
+
if (!initValidationFields.value.currentPassword) return ''
|
|
94
|
+
|
|
95
|
+
return !modelLocal.value.current_password
|
|
96
|
+
? localization.value.common.fieldRequired
|
|
97
|
+
: ''
|
|
80
98
|
})
|
|
81
99
|
const newPasswordErrorText = computed<string>(() => {
|
|
82
|
-
return ''
|
|
100
|
+
if (!initValidationFields.value.newPassword) return ''
|
|
101
|
+
|
|
102
|
+
const { new_password, confirm_password } = modelLocal.value
|
|
103
|
+
return !new_password
|
|
104
|
+
? localization.value.common.fieldRequired
|
|
105
|
+
: getPasswordMismatchError(
|
|
106
|
+
localization.value,
|
|
107
|
+
new_password,
|
|
108
|
+
confirm_password
|
|
109
|
+
)
|
|
83
110
|
})
|
|
84
111
|
const confirmPasswordErrorText = computed<string>(() => {
|
|
85
|
-
return ''
|
|
112
|
+
if (!initValidationFields.value.confirmPassword) return ''
|
|
113
|
+
const { new_password, confirm_password } = modelLocal.value
|
|
114
|
+
return !confirm_password
|
|
115
|
+
? localization.value.common.fieldRequired
|
|
116
|
+
: getPasswordMismatchError(
|
|
117
|
+
localization.value,
|
|
118
|
+
new_password,
|
|
119
|
+
confirm_password
|
|
120
|
+
)
|
|
86
121
|
})
|
|
87
122
|
|
|
88
|
-
// const
|
|
89
|
-
|
|
90
|
-
// errorText.value = text
|
|
91
|
-
// }
|
|
123
|
+
// const isValid = ref<boolean>(false)
|
|
124
|
+
const errorText = ref<string>('')
|
|
92
125
|
|
|
93
|
-
// const onHideModal = (): void => {
|
|
94
|
-
// emits('hide')
|
|
95
|
-
// setForm()
|
|
96
|
-
// isValid.value = false
|
|
97
|
-
// }
|
|
98
126
|
|
|
99
127
|
const onSubmit = (): void => {
|
|
128
|
+
const isFieldValid = initValidation([
|
|
129
|
+
'currentPassword',
|
|
130
|
+
'newPassword',
|
|
131
|
+
'confirmPassword',
|
|
132
|
+
])
|
|
100
133
|
// const { } = modelLocal.value
|
|
134
|
+
|
|
135
|
+
if (!isFieldValid) {
|
|
136
|
+
console.log(1111111)
|
|
137
|
+
}
|
|
138
|
+
|
|
101
139
|
errorText.value = 'asdaldjlkdjkadj'
|
|
102
140
|
|
|
103
141
|
const notReady = true
|
|
@@ -106,6 +144,9 @@ const onSubmit = (): void => {
|
|
|
106
144
|
}
|
|
107
145
|
emits('change-password')
|
|
108
146
|
}
|
|
147
|
+
const onHideModal = (): void => {
|
|
148
|
+
emits('hide')
|
|
149
|
+
}
|
|
109
150
|
</script>
|
|
110
151
|
|
|
111
152
|
<style lang="scss" scoped>
|
package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { UI_I_Validation } from '~/lib/models/plugins/validation/interfaces'
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
export interface UI_I_InitialValidationFields {
|
|
5
|
+
currentPassword: boolean
|
|
6
|
+
newPassword: boolean
|
|
7
|
+
confirmPassword: boolean
|
|
8
|
+
}
|
|
3
9
|
export interface UI_I_FormChangePassword {
|
|
4
10
|
password: UI_I_Validation
|
|
5
11
|
newPassword: UI_I_Validation
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UI_I_Localization } from '~//lib/models/interfaces'
|
|
2
|
+
|
|
3
|
+
export const getPasswordMismatchError = (
|
|
4
|
+
localization: UI_I_Localization,
|
|
5
|
+
password: string,
|
|
6
|
+
confirmPassword: string
|
|
7
|
+
): string => {
|
|
8
|
+
return password === confirmPassword
|
|
9
|
+
? ''
|
|
10
|
+
: localization.common.thePasswordsDoNotMatch
|
|
11
|
+
}
|