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
5f7ced47
Commit
5f7ced47
authored
1 year ago
by
Valdemar Åstorp Beere
Browse files
Options
Downloads
Patches
Plain Diff
refactor(component):
Add info options to challenge or goal
parent
85222b7d
No related branches found
Branches containing commit
No related tags found
3 merge requests
!66
Final merge
,
!43
chore:
,
!4
Pipeline fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/SavingsPath.vue
+29
-13
29 additions, 13 deletions
src/components/SavingsPath.vue
with
29 additions
and
13 deletions
src/components/SavingsPath.vue
+
29
−
13
View file @
5f7ced47
...
@@ -12,8 +12,7 @@
...
@@ -12,8 +12,7 @@
<div
class=
"h-1 w-4/6 mx-auto my-2 opacity-10"
></div>
<div
class=
"h-1 w-4/6 mx-auto my-2 opacity-10"
></div>
<div
<div
ref=
"containerRef"
ref=
"containerRef"
class=
"container relative pt-6 w-4/5 mx-auto md:w-4/5 no-scrollbar h-full max-h-[60vh] md:max-h-[60v] md:min-w-2/5 overflow-y-auto border-2 border-slate-300 rounded-lg bg-white shadow-lg"
class=
"container relative pt-6 w-4/5 mx-auto md:w-4/5 no-scrollbar h-full max-h-[60vh] md:max-h-[60v] md:min-w-2/5 overflow-y-auto border-2 border-slate-300 rounded-lg bg-white shadow-lg"
>
<div>
<div>
<img
src=
"@/assets/start.png"
alt=
"Spare"
class=
"md:w-1/6 md:h-auto h-20"
/>
<img
src=
"@/assets/start.png"
alt=
"Spare"
class=
"md:w-1/6 md:h-auto h-20"
/>
</div>
</div>
...
@@ -32,26 +31,34 @@
...
@@ -32,26 +31,34 @@
>
>
<div
class=
"right-auto just"
>
<div
class=
"right-auto just"
>
<img
<img
v-if=
"index
=== 3 || index%4
===3"
v-if=
"index
%6
===3"
src=
"@/assets/sleepingSpare.gif"
src=
"@/assets/sleepingSpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"w-32 h-32 border-2 rounded-lg border-stale-400"
class=
"w-32 h-32 border-2 rounded-lg border-stale-400"
/>
/>
<img
<img
v-else-if=
"index
=== 1 || index%4
=== 1"
v-else-if=
"index
%6
=== 1"
src=
"@/assets/golfSpare.gif"
src=
"@/assets/golfSpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"w-32 h-32 border-2 rounded-lg border-stale-400"
class=
"w-32 h-32 border-2 rounded-lg border-stale-400"
/>
/>
<img
v-else-if=
"index%6===5"
src=
"@/assets/archerSpare.gif"
alt=
"could not load"
class=
"w-32 h-32 border-2 rounded-lg border-stale-400"
/>
</div>
</div>
<!-- Challenge Icon and Details -->
<!-- Challenge Icon and Details -->
<div
class=
"flex"
>
<div
class=
"flex"
>
<!-- Challenge Icon -->
<!-- Challenge Icon -->
<div
class=
"flex flex-col items-center"
>
<div
class=
"flex flex-col items-center"
>
<div
class=
"flex flex-row flex-nowrap"
>
<p
class=
"text-center text-wrap text-xs md:text-lg"
data-cy=
"challenge-title"
>
<p
class=
"text-center text-wrap text-xs md:text-lg"
data-cy=
"challenge-title"
>
{{
challenge
.
title
}}
{{
challenge
.
title
}}
</p>
</p>
<Countdown
v-if=
"screenSize > 768 && challenge.completion!==100"
class=
"flex flex-row"
countdownSize=
"1rem"
labelSize=
".5rem"
mainColor=
"white"
secondFlipColor=
"white"
mainFlipBackgroundColor=
"#30ab0e"
secondFlipBackgroundColor=
'#9af781'
:labels=
"
{ days: 'dager', hours: 'timer', minutes: 'min', seconds: 'sek', }" :deadlineISO="challenge.due">
</Countdown>
<display-info-for-challenge-or-goal
:goal=
"goal"
:challenge=
"challenge"
:is-challenge=
"true"
></display-info-for-challenge-or-goal>
</div>
<img
<img
@
click=
"editChallenge(challenge)"
@
click=
"editChallenge(challenge)"
:data-cy=
"'challenge-icon-' + challenge.id"
:data-cy=
"'challenge-icon-' + challenge.id"
...
@@ -111,17 +118,23 @@
...
@@ -111,17 +118,23 @@
</div>
</div>
<div
class=
""
>
<div
class=
""
>
<img
<img
v-if=
"index
=== 0 || index%4
===0"
v-if=
"index
%6
===0"
src=
"@/assets/cowboySpare.gif"
src=
"@/assets/cowboySpare.gif"
alt=
"could not load"
alt=
"could not load"
class=
"h-32 w-32 border-2 rounded-lg border-stale-400"
class=
"h-32 w-32 border-2 rounded-lg border-stale-400"
/>
/>
<img
<img
v-else-if=
"index
=== 2 || index%4
=== 2"
v-else-if=
"index
%6
=== 2"
src=
"@/assets/hotAirBalloonSpare.gif"
src=
"@/assets/hotAirBalloonSpare.gif"
class=
"h-32 w-32 border-stale-400 border-2 rounded-lg"
class=
"h-32 w-32 border-stale-400 border-2 rounded-lg"
alt=
"could not load"
alt=
"could not load"
/>
/>
<img
v-else-if=
"index %6===4"
src=
"@/assets/farmerSpare.gif"
alt=
"could not load"
class=
"h-32 w-32 border-stale-400 border-2 rounded-lg"
/>
</div>
</div>
</div>
</div>
<!-- Piggy Steps, centered -->
<!-- Piggy Steps, centered -->
...
@@ -156,9 +169,12 @@
...
@@ -156,9 +169,12 @@
</div>
</div>
<!-- Goal -->
<!-- Goal -->
<div
v-if=
"goal"
class=
"flex flex-row justify-around m-t-2 pt-6 w-full mx-auto"
>
<div
v-if=
"goal"
class=
"flex flex-row justify-around m-t-2 pt-6 w-full mx-auto"
>
<div
class=
"flex flex-col items-start cursor-pointer"
@
click=
"editGoal(goal)"
>
<div
class=
"grid grid-rows-2 grid-flow-col gap 4"
>
<img
:src=
"getGoalIcon(goal)"
class=
"w-12 h-12 mx-auto"
:alt=
"goal.title"
/>
<div
class=
"row-span-3 cursor-pointer"
@
click=
"editGoal(goal)"
>
<div
class=
"text-lg font-bold"
data-cy=
"goal-title"
>
{{
goal
.
title
}}
</div>
<img
:src=
"getGoalIcon(goal)"
class=
"w-12 h-12 mx-auto"
:alt=
"goal.title"
/>
<div
class=
"text-lg font-bold"
data-cy=
"goal-title"
>
{{
goal
.
title
}}
</div>
</div>
<display-info-for-challenge-or-goal
class=
"col-span-2"
:goal=
"goal"
:challenge=
"null"
:is-challenge=
"false"
></display-info-for-challenge-or-goal>
</div>
</div>
<div
class=
"flex flex-col items-end"
>
<div
class=
"flex flex-col items-end"
>
<div
@
click=
"goToEditGoal"
class=
"cursor-pointer"
>
<div
@
click=
"goToEditGoal"
class=
"cursor-pointer"
>
...
@@ -191,7 +207,7 @@ import confetti from 'canvas-confetti'
...
@@ -191,7 +207,7 @@ import confetti from 'canvas-confetti'
import
{
useRouter
}
from
'
vue-router
'
import
{
useRouter
}
from
'
vue-router
'
import
{
useGoalStore
}
from
'
@/stores/goalStore
'
import
{
useGoalStore
}
from
'
@/stores/goalStore
'
import
{
useChallengeStore
}
from
'
@/stores/challengeStore
'
import
{
useChallengeStore
}
from
'
@/stores/challengeStore
'
import
{
Countdown
}
from
'
vue3-flip-countdown
'
import
DisplayInfoForChallengeOrGoal
from
"
@/components/DisplayInfoForChallengeOrGoal.vue
"
;
const
router
=
useRouter
()
const
router
=
useRouter
()
const
goalStore
=
useGoalStore
()
const
goalStore
=
useGoalStore
()
...
@@ -217,9 +233,9 @@ const sortChallenges = () => {
...
@@ -217,9 +233,9 @@ const sortChallenges = () => {
challenges
.
value
.
sort
((
a
,
b
)
=>
{
challenges
.
value
.
sort
((
a
,
b
)
=>
{
// First, sort by completion status: non-completed (less than 100) before completed (100)
// First, sort by completion status: non-completed (less than 100) before completed (100)
if
(
a
.
completion
!==
100
&&
b
.
completion
===
100
)
{
if
(
a
.
completion
!==
100
&&
b
.
completion
===
100
)
{
return
-
1
;
// 'a' is not completed and 'b' is completed, 'a' should come first
return
1
;
// 'a' is not completed and 'b' is completed, 'a' should come first
}
else
if
(
a
.
completion
===
100
&&
b
.
completion
!==
100
)
{
}
else
if
(
a
.
completion
===
100
&&
b
.
completion
!==
100
)
{
return
1
;
// 'a' is completed and 'b' is not, 'b' should come first
return
-
1
;
// 'a' is completed and 'b' is not, 'b' should come first
}
else
{
}
else
{
// If both are completed or both are not completed, sort by the due date
// If both are completed or both are not completed, sort by the due date
return
new
Date
(
a
.
due
)
-
new
Date
(
b
.
due
);
return
new
Date
(
a
.
due
)
-
new
Date
(
b
.
due
);
...
...
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