Skip to content

Commit

Permalink
Move default condition for batch operations to gridlist component
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jan 15, 2024
1 parent a442801 commit 8d09263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/src/components/Grid/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ watch(operationMessage, () => {
<div class="d-flex">
<div v-for="(batchOperation, batchIndex) in gridConfig.batch" :key="batchIndex">
<BButton
v-if="!batchOperation.condition || batchOperation.condition(Array.from(selected))"
v-if="
selected.size > 0 &&
(!batchOperation.condition || batchOperation.condition(Array.from(selected)))
"
class="mr-2"
size="sm"
variant="primary"
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/Grid/configs/histories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const batch: BatchOperationArray = [
{
title: "Delete",
icon: faTrash,
condition: (data: Array<HistoryEntry>) => data.length > 0 && !data.some((x) => x.deleted),
condition: (data: Array<HistoryEntry>) => !data.some((x) => x.deleted),
handler: async (data: Array<HistoryEntry>) => {
if (confirm(_l(`Are you sure that you want to delete the selected histories?`))) {
try {
Expand All @@ -84,7 +84,7 @@ const batch: BatchOperationArray = [
{
title: "Restore",
icon: faTrashRestore,
condition: (data: Array<HistoryEntry>) => data.length > 0 && !data.some((x) => !x.deleted || x.purged),
condition: (data: Array<HistoryEntry>) => !data.some((x) => !x.deleted || x.purged),
handler: async (data: Array<HistoryEntry>) => {
if (confirm(_l(`Are you sure that you want to restore the selected histories?`))) {
try {
Expand All @@ -106,7 +106,7 @@ const batch: BatchOperationArray = [
{
title: "Purge",
icon: faTrash,
condition: (data: Array<HistoryEntry>) => data.length > 0 && !data.some((x) => x.purged),
condition: (data: Array<HistoryEntry>) => !data.some((x) => x.purged),
handler: async (data: Array<HistoryEntry>) => {
if (confirm(_l(`Are you sure that you want to permanently delete the selected histories?`))) {
try {
Expand Down

0 comments on commit 8d09263

Please sign in to comment.