Skip to content

Commit

Permalink
🔨 Extend data list filter for bool columns
Browse files Browse the repository at this point in the history
  • Loading branch information
devmount committed Jun 1, 2024
1 parent fe51d04 commit 7760509
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<label class="flex items-center gap-4 whitespace-nowrap">
{{ filter.name }} {{ t('label.filter') }}:
<select class="rounded-md" @change="(evt) => onColumnFilter(evt, filter)">
<option :value="option.key" v-for="option in filter.options" :key="option.key">{{ option.name }}</option>
<option :value="option.key" v-for="option in filter.options" :key="option.key">
{{ option.name }}
</option>
</select>
</label>
</div>
Expand Down Expand Up @@ -173,7 +175,6 @@ const onFieldSelect = (evt, fieldData) => {
const onColumnFilter = (evt, filter) => {
mutableDataList.value = filter.fn(evt.target.value, dataList.value);
console.log('Data list info: ', mutableDataList.value, ' vs ', dataList.value);
if (mutableDataList.value === dataList.value) {
mutableDataList.value = null;
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/admin/SubscriberPanelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const filteredSubscribers = computed(() => subscribers.value.map((subscriber) =>
},
wasInvited: {
type: tableDataType.bool,
value: subscriber.invite,
value: Boolean(subscriber.invite),
},
disable: {
type: tableDataType.button,
Expand Down Expand Up @@ -161,11 +161,11 @@ const filters = [
},
{
name: 'Yes',
key: 'yes',
key: 'true',
},
{
name: 'No',
key: 'no',
key: 'false',
},
],
/**
Expand All @@ -178,7 +178,7 @@ const filters = [
if (selectedKey === 'all') {
return mutableDataList;
}
return mutableDataList.filter((data) => data.wasInvited.value.toLowerCase() === selectedKey);
return mutableDataList.filter((data) => data.wasInvited.value?.toString().toLowerCase() === selectedKey);
},
},
];
Expand Down

0 comments on commit 7760509

Please sign in to comment.