From aa28be29cba69efce55028fa08c3a6c9a45ccc3d Mon Sep 17 00:00:00 2001 From: Kelani Tolulope Date: Wed, 24 May 2023 13:00:51 +0100 Subject: [PATCH] Add record filter preset saving --- .../components/Common/RecordListFilter.vue | 49 +++++-- .../components/PageBlocks/RecordListBase.vue | 135 ++++++++++++++---- .../PageBlocks/RecordListConfigurator.vue | 15 ++ .../Record/CustomFilterPreset/index.vue | 100 +++++++++++++ .../compose/types/page-block/record-list.ts | 3 + locale/en/corteza-webapp-compose/block.yaml | 6 + 6 files changed, 269 insertions(+), 39 deletions(-) create mode 100644 client/web/compose/src/components/Public/Record/CustomFilterPreset/index.vue diff --git a/client/web/compose/src/components/Common/RecordListFilter.vue b/client/web/compose/src/components/Common/RecordListFilter.vue index c2bf299e45..29d973da38 100644 --- a/client/web/compose/src/components/Common/RecordListFilter.vue +++ b/client/web/compose/src/components/Common/RecordListFilter.vue @@ -215,13 +215,23 @@ {{ $t('general:label.reset') }} - - {{ $t('general.label.save') }} - +
+ + {{ $t('recordList.filter.addFilterToPreset') }} + + + {{ $t('general.label.save') }} + +
@@ -288,6 +298,11 @@ export default { type: String, default: '', }, + + allowFilterPresetSave: { + type: Boolean, + default: false, + }, }, data () { @@ -592,13 +607,8 @@ export default { } }, - onSave (close = true) { - if (close) { - this.$refs.popover.$emit('close') - } - - // Emit only value and not whole record with every filter - this.$emit('filter', this.componentFilter.map(({ groupCondition, filter = [], name }) => { + processFilter () { + return this.componentFilter.map(({ groupCondition, filter = [], name }) => { filter = filter.map(({ record, ...f }) => { if (record) { f.value = record[f.name] || record.values[f.name] @@ -615,7 +625,16 @@ export default { }) return { groupCondition, filter, name } - })) + }) + }, + + onSave (close = true, type = 'filter') { + if (close) { + this.$refs.popover.$emit('close') + } + + // Emit only value and not whole record with every filter + this.$emit(type, this.processFilter()) }, updateFilterProperties (filter) { diff --git a/client/web/compose/src/components/PageBlocks/RecordListBase.vue b/client/web/compose/src/components/PageBlocks/RecordListBase.vue index 49e1e227c8..72b954e0fe 100644 --- a/client/web/compose/src/components/PageBlocks/RecordListBase.vue +++ b/client/web/compose/src/components/PageBlocks/RecordListBase.vue @@ -78,22 +78,32 @@ @export="onExport" /> - - - {{ f.name }} - - + {{ $t('recordList.filter.filters.label') }} + + + + @@ -609,6 +621,13 @@ open-on-select @save="onInlineEdit()" /> + + +