Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
idatt2106_2024_02_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 - Gruppe 2
idatt2106_2024_02_frontend
Commits
c93076ab
Commit
c93076ab
authored
11 months ago
by
Ina Martini
Browse files
Options
Downloads
Patches
Plain Diff
refactor:
update modal componant and tests
parent
93dcf7f5
No related branches found
No related tags found
3 merge requests
!66
Final merge
,
!18
Update login page and implement forgot password feature
,
!4
Pipeline fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/ModalComponent.vue
+8
-30
8 additions, 30 deletions
src/components/ModalComponent.vue
src/components/__tests__/ModalTest.spec.ts
+0
-26
0 additions, 26 deletions
src/components/__tests__/ModalTest.spec.ts
with
8 additions
and
56 deletions
src/components/ModalComponent.vue
+
8
−
30
View file @
c93076ab
...
@@ -6,23 +6,14 @@
...
@@ -6,23 +6,14 @@
<div
class=
"bg-white p-6 rounded-lg shadow-lg max-w-sm w-full"
>
<div
class=
"bg-white p-6 rounded-lg shadow-lg max-w-sm w-full"
>
<h2
class=
"font-bold mb-4"
>
{{
title
}}
</h2>
<h2
class=
"font-bold mb-4"
>
{{
title
}}
</h2>
<p
class=
"mb-4"
>
{{
message
}}
</p>
<p
class=
"mb-4"
>
{{
message
}}
</p>
<input
v-if=
"showInput"
<slot
name=
"input"
></slot>
:type=
"typeValue"
v-model=
"inputValue"
@
input=
"$emit('update:inputValue', inputValue)"
class=
"border border-gray-300 p-2 w-full"
:placeholder=
"inputPlaceholder"
/>
<div
class=
"flex flex-col justify-center items-center gap-3 mt-3 w-full"
>
<div
class=
"flex flex-col justify-center items-center gap-3 mt-3 w-full"
>
<button
<slot
name=
"buttons"
></slot>
v-if=
"showButton"
</div>
:disabled=
"!isInputValid"
@
click=
"buttonAction && buttonAction!()"
<div
class=
"flex justify-center mt-4"
>
class=
"active-button font-bold py-2 px-4 w-1/2 hover:bg-[#f7da7c] border-2 border-[#f7da7c] disabled:border-transparent"
>
{{
button1
}}
</button>
<button
<button
@
click=
"closeModal"
@
click=
"closeModal"
class=
"font-bold py-2 px-4 w-1/2 bg-white border-2 border-[#f7da7c] hover:bg-[#f7da7c]"
class=
"font-bold py-2 px-4 w-1/2 bg-white border-2 border-[#f7da7c] hover:bg-[#f7da7c]"
...
@@ -36,29 +27,16 @@
...
@@ -36,29 +27,16 @@
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'
vue
'
defineProps
({
defineProps
({
title
:
String
,
title
:
String
,
message
:
String
,
message
:
String
,
button1
:
String
,
isModalOpen
:
Boolean
,
isModalOpen
:
Boolean
,
buttonAction
:
{
type
:
Function
,
default
:
()
=>
{}
},
showButton
:
Boolean
,
showInput
:
Boolean
,
typeValue
:
String
,
inputPlaceholder
:
String
,
isInputValid
:
Boolean
})
})
const
emits
=
defineEmits
([
'
update:isModalOpen
'
,
'
update:inputValue
'
])
const
emits
=
defineEmits
([
'
update:isModalOpen
'
])
const
inputValue
=
ref
(
''
)
function
closeModal
()
{
function
closeModal
()
{
inputValue
.
value
=
''
emits
(
'
update:isModalOpen
'
,
false
)
emits
(
'
update:isModalOpen
'
,
false
)
}
}
</
script
>
</
script
>
This diff is collapsed.
Click to expand it.
src/components/__tests__/ModalTest.spec.ts
+
0
−
26
View file @
c93076ab
...
@@ -39,30 +39,4 @@ describe('ModalComponent', () => {
...
@@ -39,30 +39,4 @@ describe('ModalComponent', () => {
throw
new
Error
(
'
Close button not found
'
)
throw
new
Error
(
'
Close button not found
'
)
}
}
})
})
it
(
'
button is shown when showButton is true
'
,
async
()
=>
{
expect
(
wrapper
.
props
().
showButton
).
toBe
(
true
)
expect
(
wrapper
.
find
(
'
.active-button
'
).
exists
()).
toBe
(
true
)
})
it
(
'
button is not shown when showButton is false
'
,
async
()
=>
{
await
wrapper
.
setProps
({
showButton
:
false
})
await
wrapper
.
vm
.
$nextTick
()
expect
(
wrapper
.
props
().
showButton
).
toBe
(
false
)
expect
(
wrapper
.
find
(
'
.active-button
'
).
exists
()).
toBe
(
false
)
})
it
(
'
input is shown when showInput is true
'
,
async
()
=>
{
await
wrapper
.
setProps
({
showInput
:
true
})
await
wrapper
.
vm
.
$nextTick
()
expect
(
wrapper
.
props
().
showInput
).
toBe
(
true
)
expect
(
wrapper
.
find
(
'
input
'
).
exists
()).
toBe
(
true
)
})
it
(
'
input is not shown when showInput is false
'
,
async
()
=>
{
expect
(
wrapper
.
props
().
showInput
).
toBe
(
false
)
expect
(
wrapper
.
find
(
'
input
'
).
exists
()).
toBe
(
false
)
})
})
})
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