Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
7d1106cf
Commit
7d1106cf
authored
2 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Include Deletion Dialog Component
parent
8586b1ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!1237
Release 3.0
,
!1207
Resolve "Move DeleteDialog from Plank to Core"
,
!1183
Release 3.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/frontend/components/generic/DeleteDialog.vue
+132
-0
132 additions, 0 deletions
aleksis/core/frontend/components/generic/DeleteDialog.vue
with
132 additions
and
0 deletions
aleksis/core/frontend/components/generic/DeleteDialog.vue
0 → 100644
+
132
−
0
View file @
7d1106cf
<
template
>
<ApolloMutation
v-if=
"dialogOpen"
:mutation=
"gqlMutation"
:variables=
"
{ id: item.id }"
:update="update"
@done="close(true)"
>
<template
#default
="
{ mutate, loading, error }">
<v-dialog
v-model=
"dialogOpen"
max-width=
"500px"
>
<v-card>
<v-card-title
class=
"text-h5"
>
{{
$t
(
"
actions.confirm_deletion
"
)
}}
</v-card-title>
<v-card-text>
<p
class=
"text-body-1"
>
{{
nameOfObject
}}
</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
text
@
click=
"close(false)"
:disabled=
"loading"
>
{{
$t
(
"
actions.cancel
"
)
}}
</v-btn>
<v-btn
color=
"red"
text
@
click=
"mutate"
:loading=
"loading"
:disabled=
"loading"
>
{{
$t
(
"
actions.delete
"
)
}}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
:value=
"error !== null"
>
{{
error
}}
<template
#action
="
{ attrs }">
<v-btn
color=
"primary"
text
v-bind=
"attrs"
@
click=
"error = null"
icon
>
<v-icon>
$close
</v-icon>
</v-btn>
</
template
>
</v-snackbar>
</template>
</ApolloMutation>
</template>
<
script
>
export
default
{
name
:
"
DeleteDialog
"
,
computed
:
{
nameOfObject
()
{
return
this
.
itemAttribute
in
this
.
item
||
{}
?
this
.
item
[
this
.
itemAttribute
]
:
this
.
item
.
toString
();
},
dialogOpen
:
{
get
()
{
return
this
.
value
;
},
set
(
val
)
{
this
.
$emit
(
"
input
"
,
val
)
}
}
},
methods
:
{
update
(
store
)
{
if
(
!
this
.
gqlQuery
)
{
// There is no GraphQL query to update
return
;
}
// Read the data from cache for query
const
storedData
=
store
.
readQuery
({
query
:
this
.
gqlQuery
});
if
(
!
storedData
)
{
// There are no data in the cache yet
return
;
}
const
storedDataKey
=
Object
.
keys
(
storedData
)[
0
];
// Remove item from stored data
const
index
=
storedData
[
storedDataKey
].
findIndex
(
(
m
)
=>
m
.
id
===
this
.
item
.
id
);
storedData
[
storedDataKey
].
splice
(
index
,
1
);
// Write data back to the cache
store
.
writeQuery
({
query
:
this
.
gqlQuery
,
storedData
});
},
close
(
success
)
{
this
.
$emit
(
"
input
"
,
false
);
if
(
success
)
{
this
.
$emit
(
"
success
"
);
}
else
{
this
.
$emit
(
"
cancel
"
);
}
}
},
props
:
{
value
:
{
type
:
Boolean
,
required
:
true
,
},
item
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
itemAttribute
:
{
type
:
String
,
required
:
false
,
default
:
"
name
"
,
},
title
:
{
type
:
String
,
required
:
true
,
},
gqlMutation
:
{
type
:
Object
,
required
:
true
,
},
gqlQuery
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
},
};
</
script
>
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