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
a9b64054
Commit
a9b64054
authored
11 months ago
by
Valdemar Åstorp Beere
Browse files
Options
Downloads
Patches
Plain Diff
refactor(homepage):
Moved data form child to parent component
parent
c064bdb7
No related branches found
No related tags found
3 merge requests
!66
Final merge
,
!32
refactor(component):
,
!4
Pipeline fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/SavingsPath.vue
+25
-13
25 additions, 13 deletions
src/components/SavingsPath.vue
src/views/HomeView.vue
+1
-1
1 addition, 1 deletion
src/views/HomeView.vue
with
26 additions
and
14 deletions
src/components/SavingsPath.vue
+
25
−
13
View file @
a9b64054
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
<p
class=
"text-center"
data-cy=
"challenge-title"
>
{{
challenge
.
title
}}
</p>
<p
class=
"text-center"
data-cy=
"challenge-title"
>
{{
challenge
.
title
}}
</p>
<img
<img
@
click=
"editChallenge(challenge)"
@
click=
"editChallenge(challenge)"
:data-cy=
"'challenge-icon-'+challenge.id"
:src=
"getChallengeIcon(challenge)"
:src=
"getChallengeIcon(challenge)"
class=
"max-w-20 max-h-20 cursor-pointer"
class=
"max-w-20 max-h-20 cursor-pointer"
:alt=
"challenge.title"
:alt=
"challenge.title"
...
@@ -68,6 +69,7 @@
...
@@ -68,6 +69,7 @@
>
>
<div
<div
class=
"bg-green-600 h-2.5 rounded-full"
class=
"bg-green-600 h-2.5 rounded-full"
data-cy=
"challenge-progress"
:style=
"
{
:style=
"
{
width:
width:
(challenge.saved / challenge.target) *
(challenge.saved / challenge.target) *
...
@@ -83,6 +85,7 @@
...
@@ -83,6 +85,7 @@
<button
<button
@
click=
"incrementSaved(challenge)"
@
click=
"incrementSaved(challenge)"
:data-cy=
"'increment-challenge'+challenge.id"
type=
"button"
type=
"button"
class=
"inline-block mb-2 ml-2 h-7 w-8 rounded-full p-1 uppercase leading-normal transition duration-150 ease-in-out focus:bg-green-accent-300 focus:shadow-green-2 focus:outline-none focus:ring-0 active:bg-green-600 active:shadow-green-200 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong"
class=
"inline-block mb-2 ml-2 h-7 w-8 rounded-full p-1 uppercase leading-normal transition duration-150 ease-in-out focus:bg-green-accent-300 focus:shadow-green-2 focus:outline-none focus:ring-0 active:bg-green-600 active:shadow-green-200 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong"
>
>
...
@@ -194,29 +197,38 @@ import anime from 'animejs'
...
@@ -194,29 +197,38 @@ import anime from 'animejs'
import
type
{
Challenge
}
from
'
@/types/challenge
'
import
type
{
Challenge
}
from
'
@/types/challenge
'
import
type
{
Goal
}
from
'
@/types/goal
'
import
type
{
Goal
}
from
'
@/types/goal
'
import
confetti
from
'
canvas-confetti
'
import
confetti
from
'
canvas-confetti
'
import
{
useGoalStore
}
from
'
@/stores/goalStore
'
import
{
useChallengeStore
}
from
'
@/stores/challengeStore
'
import
{
useRouter
}
from
"
vue-router
"
;
import
{
useRouter
}
from
"
vue-router
"
;
import
{
useGoalStore
}
from
"
@/stores/goalStore
"
;
import
{
useChallengeStore
}
from
"
@/stores/challengeStore
"
;
const
router
=
useRouter
()
const
router
=
useRouter
()
const
goalStore
=
useGoalStore
()
const
goalStore
=
useGoalStore
()
const
challengeStore
=
useChallengeStore
()
const
challengeStore
=
useChallengeStore
()
const
challenges
=
ref
<
Challenge
[]
>
([])
interface
Props
{
const
goals
=
ref
<
Goal
[]
>
([])
challenges
:
Challenge
[]
goal
:
Goal
|
null
|
undefined
}
const
props
=
defineProps
<
Props
>
()
const
goal
=
ref
<
Goal
|
null
|
undefined
>
(
null
)
onMounted
(
async
()
=>
{
const
challenges
=
ref
<
Challenge
[]
>
(
props
.
challenges
)
await
goalStore
.
getUserGoals
()
const
goal
=
ref
<
Goal
|
null
|
undefined
>
(
props
.
goal
)
await
challengeStore
.
getUserChallenges
()
challenges
.
value
=
challengeStore
.
challenges
goals
.
value
=
goalStore
.
goals
goal
.
value
=
goals
.
value
[
0
]
console
.
log
(
'
Goals:
'
,
goals
.
value
)
})
// Utilizing watch to specifically monitor for changes in the props
watch
(()
=>
props
.
goal
,
(
newGoal
,
oldGoal
)
=>
{
if
(
newGoal
!==
oldGoal
)
{
goal
.
value
=
newGoal
;
console
.
log
(
'
Updated goal:
'
,
goal
.
value
);
}
},
{
immediate
:
true
});
watch
(()
=>
props
.
challenges
,
(
newChallenges
,
oldChallenges
)
=>
{
if
(
newChallenges
!==
oldChallenges
)
{
challenges
.
value
=
newChallenges
;
console
.
log
(
'
Updated challenges:
'
,
challenges
.
value
);
}
},
{
immediate
:
true
});
// Reactive references for DOM elements
// Reactive references for DOM elements
const
iconRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
iconRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
containerRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
containerRef
=
ref
<
HTMLElement
|
null
>
(
null
)
...
...
This diff is collapsed.
Click to expand it.
src/views/HomeView.vue
+
1
−
1
View file @
a9b64054
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<ButtonAddGoalOrChallenge
:buttonText=
"'Legg til spareutfordring'"
:type=
"'challenge'"
/>
<ButtonAddGoalOrChallenge
:buttonText=
"'Legg til spareutfordring'"
:type=
"'challenge'"
/>
</div>
</div>
</div>
</div>
<savings-path></savings-path>
<savings-path
:challenges=
"challenges"
:goal=
"goal"
></savings-path>
</div>
</div>
</
template
>
</
template
>
...
...
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