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
0e8f60c6
Commit
0e8f60c6
authored
10 months ago
by
Jens Christian Aanestad
Browse files
Options
Downloads
Patches
Plain Diff
refactor/Changed ExpenseBox component to emit expense id when editing
parent
91237c04
No related branches found
Branches containing commit
No related tags found
1 merge request
!53
Refactor/integration budgetview
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/Budget/ExpenseBox.vue
+17
-10
17 additions, 10 deletions
src/components/Budget/ExpenseBox.vue
with
17 additions
and
10 deletions
src/components/Budget/ExpenseBox.vue
+
17
−
10
View file @
0e8f60c6
<
script
setup
lang=
"ts"
>
import
Button1
from
'
@/components/Buttons/Button1.vue
'
import
{
type
CreateAppFunction
,
ref
}
from
'
vue
'
import
{
ref
}
from
'
vue
'
const
emit
=
defineEmits
([
'
deleteEvent
'
,
'
editEvent
'
]);
const
props
=
defineProps
({
id
:
{
type
:
Number
,
required
:
true
},
index
:
{
type
:
Number
,
default
:
0
...
...
@@ -19,24 +22,24 @@ const props = defineProps({
})
// Reactive variables for expense description and amount
let
editDescription
=
ref
(
''
)
let
editAmount
=
ref
(
''
)
let
editDescription
=
ref
(
props
.
description
)
let
editAmount
=
ref
(
props
.
amount
)
/**
* Emits an event to parent component with the type 'deleteEvent' to signalize
* that an expense with
index 'index'
must be removed.
* that an expense with
given id
must be removed.
*/
const
emitDeleteEvent
=
()
=>
{
emit
(
'
deleteEvent
'
,
props
.
i
ndex
)
emit
(
'
deleteEvent
'
,
props
.
i
d
)
}
/**
* Emits an event to parent component with the type 'editEvent' to signalize
* that an expense with
index 'index'
is to be edited with the values 'editDescription'
* that an expense with
given id
is to be edited with the values 'editDescription'
* and 'editAmount'
*/
const
emitEditEvent
=
()
=>
{
emit
(
'
editEvent
'
,
props
.
i
ndex
,
editDescription
.
value
,
editAmount
.
value
)
emit
(
'
editEvent
'
,
props
.
i
d
,
editDescription
.
value
,
editAmount
.
value
)
}
</
script
>
...
...
@@ -55,11 +58,11 @@ const emitEditEvent = () => {
</button>
</div>
<div
class=
"collapse"
id=
index
>
<div
class=
"collapse"
:
id=
String(
index
)
>
<div
class=
"container collapse-container"
>
<form
@
submit.prevent=
"emitEditEvent"
>
<div
class=
"input-group"
>
<span
class=
"input-group-text"
>
Edit expense
#
{{
index
+
1
}}
:
</span>
<span
class=
"input-group-text"
>
Edit expense
{{
index
+
1
}}
</span>
<input
type=
"text"
class=
"form-control"
placeholder=
"Expense description"
required
v-model=
"editDescription"
>
<input
type=
"number"
min=
"0"
class=
"form-control"
placeholder=
"Amount (kr)"
required
v-model=
"editAmount"
>
<button
type=
"submit"
class=
"btn btn-primary"
data-bs-toggle=
"collapse"
:data-bs-target=
"'#' + index"
>
Confirm
</button>
...
...
@@ -70,6 +73,10 @@ const emitEditEvent = () => {
</
template
>
<
style
scoped
>
div
.collapse
{
margin-bottom
:
10px
;
}
.expense-container
{
padding
:
0
10px
;
display
:
grid
;
...
...
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