Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106-2024-07
frontend
Commits
ed506ba7
Commit
ed506ba7
authored
11 months ago
by
Anders Høvik
Browse files
Options
Downloads
Patches
Plain Diff
Fixed validation and added the initial information of user to form
parent
e9663c8e
No related branches found
Branches containing commit
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/UpdateUserComponents/UpdateUserLayout.vue
+68
-34
68 additions, 34 deletions
src/components/UpdateUserComponents/UpdateUserLayout.vue
with
68 additions
and
34 deletions
src/components/UpdateUserComponents/UpdateUserLayout.vue
+
68
−
34
View file @
ed506ba7
<
script
setup
lang=
"ts"
>
import
BaseInput
from
"
@/components/InputFields/BaseInput.vue
"
;
import
{
ref
}
from
"
vue
"
;
import
{
onMounted
,
ref
}
from
"
vue
"
;
import
{
AuthenticationService
,
LeaderboardService
,
UserControllerService
}
from
"
@/api
"
;
const
firstNameRef
=
ref
(
''
)
const
firstNameRef
=
ref
()
const
surnameRef
=
ref
(
''
)
const
emailRef
=
ref
(
''
)
const
passwordRef
=
ref
(
''
)
...
...
@@ -10,6 +15,26 @@ const confirmPasswordRef = ref('')
const
formRef
=
ref
()
let
samePasswords
=
ref
(
true
)
async
function
setupForm
()
{
try
{
let
response
=
await
UserControllerService
.
getUser
();
console
.
log
(
response
.
firstName
)
firstNameRef
.
value
=
response
.
firstName
;
if
(
response
.
lastName
!=
null
)
{
surnameRef
.
value
=
response
.
lastName
;
}
if
(
response
.
email
!=
null
)
{
emailRef
.
value
=
response
.
email
}
}
catch
(
err
){
console
.
error
(
err
)
}
}
const
handleFirstNameInputEvent
=
(
newValue
:
any
)
=>
{
firstNameRef
.
value
=
newValue
}
...
...
@@ -34,21 +59,28 @@ const handleConfirmPasswordInputEvent = (newValue: any) => {
const
handleSubmit
=
async
()
=>
{
console
.
log
(
firstNameRef
.
value
)
let
isValid
samePasswords
.
value
=
(
passwordRef
.
value
===
confirmPasswordRef
.
value
)
console
.
log
(
samePasswords
.
value
)
formRef
.
value
.
classList
.
add
(
"
was-validated
"
)
const
form
=
formRef
.
value
;
// Check if the form is valid
if
(
form
.
checkValidity
())
{
// Form is valid, submit the form or perform other actions
console
.
log
(
'
Form is valid
'
);
}
else
{
console
.
log
(
'
Form is not valid
'
);
}
formRef
.
value
.
classList
.
add
(
"
was-validated
"
)
// Check if the form is valid
if
(
form
.
checkValidity
())
{
if
(
samePasswords
.
value
){
console
.
log
(
'
Form is valid
'
);
}
}
else
{
console
.
log
(
'
Form is not valid
'
);
}
}
onMounted
(()
=>
{
setupForm
()
})
...
...
@@ -63,77 +95,79 @@ const handleSubmit = async () => {
<p
class=
"h2"
>
Username
</p>
</div>
<div
class=
"col-md-10"
>
<form
@
submit.prevent=
"handleSubmit"
>
<form
ref=
"formRef"
@
submit.prevent=
"handleSubmit"
id=
"newForm"
>
<div
class=
"row"
>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6"
>
<!--
<label
for=
"inputFirstName"
class=
"form-label"
>
First Name
</label>
<input
type=
"text"
class=
"form-control"
id=
"inputFirstName"
placeholder=
"ex: Brian"
>
-->
<BaseInput
:model-value=
"firstNameRef
.value
"
<BaseInput
:model-value=
"firstNameRef"
@
input-change-event=
"handleFirstNameInputEvent"
ref=
"firstNameRef"
id=
"firstNameInput-change"
input-id=
"first-name"
id=
"firstNameInputChange"
input-id=
"first-name-new"
type=
"text"
label=
"First name"
placeholder=
"Enter your first name"
invalid-message=
"Please enter your first name"
/>
invalid-message=
"Please enter your first name"
/>
</div>
<div
class=
"form-group col-md-6"
>
<!--
<label
for=
"inputPassword4"
>
Last Name
</label>
<input
type=
"text"
class=
"form-control"
id=
"inputLastName"
placeholder=
"ex: Cox"
>
-->
<BaseInput
:model-value=
"surnameRef
.value
"
<BaseInput
:model-value=
"surnameRef"
@
input-change-event=
"handleSurnameInputEvent"
ref=
"surnameRef"
id=
"surnameInput-change"
input-id=
"surname"
input-id=
"surname
-new
"
type=
"text"
label=
"Surname"
placeholder=
"Enter your surname"
invalid-message=
"Please enter your surname"
/>
invalid-message=
"Please enter your surname"
/>
</div>
</div>
<div
class=
"form-group col-md-6"
>
<!--
<label
for=
"inputAddress"
>
Email
</label>
<input
type=
"email"
class=
"form-control"
id=
"inputMail"
placeholder=
"ex: briancox@mail.com"
>
-->
<BaseInput
:model-value=
"emailRef
.value
"
<BaseInput
:model-value=
"emailRef"
@
input-change-event=
"handleEmailInputEvent"
ref=
"emailRef"
id=
"emailInput-change"
input-id=
"email"
input-id=
"email
-new
"
type=
"email"
label=
"Email"
placeholder=
"Enter your email"
invalid-message=
"Invalid email"
/>
invalid-message=
"Invalid email"
/>
</div>
<div
class=
"row"
>
<div
class=
"form-group col-md-6"
>
<!--
<label
for=
"inputPassword"
>
Password
</label>
<input
type=
"password"
class=
"form-control"
id=
"inputPassword"
placeholder=
"Password with capital letter, number and a special character"
>
-->
<BaseInput
:model-value=
"passwordRef
.value
"
<BaseInput
:model-value=
"passwordRef"
@
input-change-event=
"handlePasswordInputEvent"
ref=
"passwordRef"
id=
"passwordInput-change"
input-id=
"password"
input-id=
"password
-new
"
type=
"password"
pattern=
"(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).
{4,16}"
label="Password"
placeholder="Enter password"
invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"/>
invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"
/>
</div>
<div
class=
"form-group col-md-6"
>
<!--
<label
for=
"inputPasswordConfirmed"
>
Confirmed Password
</label>
<input
type=
"password"
class=
"form-control"
id=
"inputPasswordConfirmed"
placeholder=
"Repeat password"
>
-->
<BaseInput
:modelValue=
"confirmPasswordRef
.value
"
<BaseInput
:modelValue=
"confirmPasswordRef"
@
input-change-event=
"handleConfirmPasswordInputEvent"
ref=
"confirmPasswordRef"
id=
"confirmPasswordInput-change"
input-id=
"confirmPassword"
input-id=
"confirmPassword
-new
"
type=
"password"
pattern=
"(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).
{4,16}"
label="Confirm Password"
placeholder="Confirm password"
invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"/>
<p
v-if=
"samePasswords"
class=
"text-danger"
>
The passwords are not identical
</p>
invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"
/>
<p
v-if=
"!samePasswords"
class=
"text-danger"
>
The passwords are not identical
</p>
</div>
</div>
<button
type=
"submit"
@
click=
"handleSubmit"
class=
"btn btn-primary"
>
Change settings
</button>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment