fix: separate group-remove from per-condition remove in filter builder

The group remove button sat inline with the first condition's close button (8px apart, easy to misclick). Move it to a labeled 'Remove group' header button (trash icon) so it's clearly distinct from the per-condition X.
This commit is contained in:
Abhinav Raut
2026-06-07 15:34:12 +05:30
parent 9b31e282c8
commit 496264d590
2 changed files with 30 additions and 22 deletions
@@ -1,35 +1,42 @@
<template>
<div class="rounded-lg border border-border bg-muted/30 p-3">
<div class="flex items-start gap-2">
<div class="flex-1 space-y-2">
<template v-for="(rule, index) in group.rules" :key="rule.__id">
<ConnectorToggle v-if="index > 0" v-model:modelValue="group.logic" />
<FilterRow v-model:modelValue="group.rules[index]" :fields="fields" @remove="removeRule(index)" />
</template>
<Button
type="button"
variant="ghost"
size="sm"
class="text-muted-foreground"
@click.stop="addCondition"
>
<Plus class="w-3 h-3 mr-1" />
{{ t('actions.addCondition') }}
</Button>
</div>
<CloseButton v-if="canRemove" type="button" :onClose="() => emit('remove')" />
<div class="rounded-lg border border-border bg-muted/30 p-3 space-y-2">
<div v-if="canRemove" class="flex justify-end">
<Button
type="button"
variant="ghost"
size="sm"
class="text-muted-foreground hover:text-foreground h-7 px-2"
@click.stop="emit('remove')"
>
<Trash2 class="w-3 h-3 mr-1" />
{{ t('filter.removeGroup') }}
</Button>
</div>
<template v-for="(rule, index) in group.rules" :key="rule.__id">
<ConnectorToggle v-if="index > 0" v-model:modelValue="group.logic" />
<FilterRow v-model:modelValue="group.rules[index]" :fields="fields" @remove="removeRule(index)" />
</template>
<Button
type="button"
variant="ghost"
size="sm"
class="text-muted-foreground"
@click.stop="addCondition"
>
<Plus class="w-3 h-3 mr-1" />
{{ t('actions.addCondition') }}
</Button>
</div>
</template>
<script setup>
import { Button } from '@shared-ui/components/ui/button'
import { Plus } from 'lucide-vue-next'
import { Plus, Trash2 } from 'lucide-vue-next'
import { useI18n } from 'vue-i18n'
import FilterRow from '@/components/filter/FilterRow.vue'
import ConnectorToggle from '@/components/filter/ConnectorToggle.vue'
import CloseButton from '@/components/button/CloseButton.vue'
import { createLeaf } from '@/components/filter/filterTree'
defineProps({
+1
View File
@@ -544,6 +544,7 @@
"filter.addGroup": "Add group",
"filter.containsAnyOf": "contains any of",
"filter.containsNoneOf": "contains none of",
"filter.removeGroup": "Remove group",
"filter.toggleConnector": "Click to switch between and / or",
"globals.messages.add": "Add",
"globals.messages.addAnnouncement": "Add announcement",