[editor] [#25] Allow searching in / sort rules

resolves #25

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-04-23 17:56:13 +02:00
parent 41a7e6bf17
commit 86144f8783
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -1,5 +1,23 @@
<template> <template>
<div> <div>
<b-row class="mb-2">
<b-col>
<b-input-group>
<b-form-input
v-model.lazy="filter"
placeholder="Search in / filter rules..."
/>
<b-input-group-append>
<b-button @click="filter = ''">
<font-awesome-icon
fixed-width
:icon="['fas', 'trash']"
/>
</b-button>
</b-input-group-append>
</b-input-group>
</b-col>
</b-row>
<b-row> <b-row>
<b-col> <b-col>
<b-table <b-table
@ -7,7 +25,7 @@
:busy="!rules" :busy="!rules"
:fields="rulesFields" :fields="rulesFields"
hover hover
:items="rules" :items="filteredRules"
striped striped
> >
<template #cell(_actions)="data"> <template #cell(_actions)="data">
@ -594,11 +612,19 @@ export default {
count += this.models.rule.match_users ? 1 : 0 count += this.models.rule.match_users ? 1 : 0
return count return count
}, },
filteredRules() {
const rules = [...this.rules]
.filter(rule => !this.filter || rule.description.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()))
rules.sort((a, b) => a.description.toLocaleLowerCase().localeCompare(b.description.toLocaleLowerCase()))
return rules
},
}, },
data() { data() {
return { return {
actions: [], actions: [],
filter: '',
models: { models: {
addAction: '', addAction: '',
rule: {}, rule: {},