Skip to content

Commit

Permalink
Filter using table filter functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
juanantoniocid committed Feb 25, 2021
1 parent 9d3897c commit 44b6b7e
Showing 1 changed file with 15 additions and 40 deletions.
55 changes: 15 additions & 40 deletions browser/flagr-ui/src/components/Flags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,12 @@
</el-row>

<el-row>
<el-col :span="19">
<el-input
placeholder="Search a flag"
prefix-icon="el-icon-search"
v-model="searchTerm"
v-focus
></el-input>
</el-col>
<el-col :span="4" :offset="1">
<template>
<el-select v-model="statusValue" placeholder="Filter by state">
<el-option
v-for="item in statusFilter"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-col>
<el-input
placeholder="Search a flag"
prefix-icon="el-icon-search"
v-model="searchTerm"
v-focus
></el-input>
</el-row>

<el-table
Expand Down Expand Up @@ -93,7 +79,9 @@
sortable
align="center"
fixed="right"
width="100"
width="140"
:filters="[{ text: 'Enabled', value: true }, { text: 'Disabled', value: false }]"
:filter-method="filterTag"
>
<template slot-scope="scope">
<el-tag
Expand Down Expand Up @@ -182,18 +170,7 @@ export default {
searchTerm: "",
newFlag: {
description: ""
},
statusFilter: [{
value: 'all',
label: 'All the flags'
}, {
value: 'enabled',
label: 'Enabled flags'
}, {
value: 'disabled',
label: 'Disabled flags'
}],
statusValue: 'all'
}
};
},
created() {
Expand All @@ -206,13 +183,8 @@ export default {
},
computed: {
filteredFlags: function() {
if (this.searchTerm || this.statusValue != "all") {
return this.flags.filter(({ enabled }) =>
this.statusValue === "all" ||
(this.statusValue === "enabled" && enabled) ||
(this.statusValue === "disabled" && !enabled)
)
.filter(({ id, description, tags }) =>
if (this.searchTerm) {
return this.flags.filter(({ id, description, tags }) =>
this.searchTerm
.split(",")
.map(term => {
Expand Down Expand Up @@ -293,6 +265,9 @@ export default {
self.deletedFlagsLoaded = true;
}, handleErr.bind(this));
}
},
filterTag(value, row) {
return row.enabled === value;
}
}
};
Expand Down

0 comments on commit 44b6b7e

Please sign in to comment.