Make aggregators removable

This commit is contained in:
chfhtw
2026-09-14 14:01:31 +02:00
parent 33f4019731
commit 892fe4e6ea
2 changed files with 29 additions and 9 deletions
@@ -45,6 +45,9 @@ export default {
addAggregator() {
this.modelValue.push({});
},
removeAggregator(index) {
this.$emit('update:modelValue', this.modelValue.toSpliced(index, 1));
},
preventOnCheckboxClick(evt) {
if (evt.explicitOriginalTarget.classList.contains('form-check-label')) {
evt.preventDefault();
@@ -94,7 +97,7 @@ export default {
</button>
</h3>
<div :id="'aggregator_' + myId + '_' + i" class="accordion-collapse collapse">
<report-aggregator v-model="agg" class="accordion-body" :index="i" />
<report-aggregator v-model="agg" class="accordion-body" :index="i" @remove="removeAggregator" />
</div>
</div>
</div>
@@ -20,7 +20,18 @@ export default {
},
emits: [
"update:modelValue",
"remove",
],
methods: {
remove() {
this.$fhcAlert.confirmDelete()
.then(result => {
if (result)
this.$emit('remove', this.index);
})
.catch(this.$fhcAlert.handleSystemError);
},
},
template: /*html*/ `
<div class="widgets-report-config-aggregators-aggregator">
<form-input
@@ -46,14 +57,20 @@ export default {
:placeholder="$p.t('dashboard/widget_report_kpi_aggregator_fields_placeholder')"
class="mb-3"
/>
<form-input
v-model="defaultAggregatorIndex"
type="radio"
name="aggregatordefault"
container-class="form-switch"
:label="$p.t('ui/default')"
:value="index"
/>
<div class="d-flex justify-content-between align-items-baseline">
<form-input
v-model="defaultAggregatorIndex"
type="radio"
name="aggregatordefault"
container-class="form-switch"
:label="$p.t('ui/default')"
:value="index"
/>
<button type="button" class="btn btn-danger" @click="remove">
<i class="fa-solid fa-trash"></i>
{{ $p.t('ui/loeschen') }}
</button>
</div>
</div>
`,
};