From facf98d1d0ba3daa6becdf309946e54dac2600f1 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 01:53:07 +0530 Subject: [PATCH 01/15] feat: customize quick filter option and UI --- frontend/src/components/Icons/ExportIcon.vue | 16 +++ .../src/components/Icons/QuickFilterIcon.vue | 20 ++++ frontend/src/components/ViewControls.vue | 103 ++++++++++++++++-- 3 files changed, 132 insertions(+), 7 deletions(-) create mode 100644 frontend/src/components/Icons/ExportIcon.vue create mode 100644 frontend/src/components/Icons/QuickFilterIcon.vue diff --git a/frontend/src/components/Icons/ExportIcon.vue b/frontend/src/components/Icons/ExportIcon.vue new file mode 100644 index 00000000..a6f62ef2 --- /dev/null +++ b/frontend/src/components/Icons/ExportIcon.vue @@ -0,0 +1,16 @@ + diff --git a/frontend/src/components/Icons/QuickFilterIcon.vue b/frontend/src/components/Icons/QuickFilterIcon.vue new file mode 100644 index 00000000..3776a36a --- /dev/null +++ b/frontend/src/components/Icons/QuickFilterIcon.vue @@ -0,0 +1,20 @@ + diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index ee38ccc0..4715f0f6 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -58,6 +58,62 @@ +
+
+ + + + + +
+
+ +
+
- h(FeatherIcon, { name: 'download', class: 'h-4 w-4' }), + icon: () => h(ExportIcon, { class: 'h-4 w-4' }), onClick: () => (showExportDialog = true), }, + { + label: __('Customize quick filters'), + icon: () => h(QuickFilterIcon, { class: 'h-4 w-4' }), + onClick: () => (customizeQuickFilter = true), + }, ], }, ]" @@ -218,7 +278,10 @@ import DuplicateIcon from '@/components/Icons/DuplicateIcon.vue' import CheckIcon from '@/components/Icons/CheckIcon.vue' import PinIcon from '@/components/Icons/PinIcon.vue' import UnpinIcon from '@/components/Icons/UnpinIcon.vue' +import ExportIcon from '@/components/Icons/ExportIcon.vue' +import QuickFilterIcon from '@/components/Icons/QuickFilterIcon.vue' import ViewModal from '@/components/Modals/ViewModal.vue' +import Autocomplete from '@/components/frappe-ui/Autocomplete.vue' import SortBy from '@/components/SortBy.vue' import Filter from '@/components/Filter.vue' import GroupBy from '@/components/GroupBy.vue' @@ -229,8 +292,10 @@ import { getSettings } from '@/stores/settings' import { globalStore } from '@/stores/global' import { viewsStore } from '@/stores/views' import { usersStore } from '@/stores/users' -import { isEmoji } from '@/utils' +import { getMeta } from '@/stores/meta' +import { isEmoji, createToast } from '@/utils' import { + Tooltip, createResource, Dropdown, call, @@ -594,11 +659,28 @@ const viewsDropdownOptions = computed(() => { return _views }) +const { getFields } = getMeta(props.doctype) + +const customizeQuickFilter = ref(false) + +const newQuickFilters = ref([]) + +function addQuickFilter(f) { + // +} + +function removeQuickFilter(f) { + // +} + +function saveQuickFilters() { + // +} + +const quickFilterOptions = [] + const quickFilterList = computed(() => { - let filters = [{ fieldname: 'name', fieldtype: 'Data', label: __('ID') }] - if (quickFilters.data) { - filters.push(...quickFilters.data) - } + let filters = quickFilters.data || [] filters.forEach((filter) => { filter['value'] = filter.fieldtype == 'Check' ? false : '' @@ -630,6 +712,13 @@ const quickFilters = createResource({ params: { doctype: props.doctype }, cache: ['Quick Filters', props.doctype], auto: true, + onSuccess(filters) { + newQuickFilters.value = filters.map((f) => ({ + label: f.label, + fieldname: f.fieldname, + fieldtype: f.fieldtype, + })) + }, }) function applyQuickFilter(filter, value) { From d1cfb361983d22f459306832d3e511cd750a9d51 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 01:55:00 +0530 Subject: [PATCH 02/15] fix: remove quick filter --- frontend/src/components/ViewControls.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 4715f0f6..6fb8beda 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -670,7 +670,9 @@ function addQuickFilter(f) { } function removeQuickFilter(f) { - // + newQuickFilters.value = newQuickFilters.value.filter( + (filter) => filter.fieldname !== f.fieldname, + ) } function saveQuickFilters() { From c2cdafb4bb324e6b49f7b2213b7ca247c43aa98a Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 01:55:37 +0530 Subject: [PATCH 03/15] fix: add quick filter --- frontend/src/components/ViewControls.vue | 32 ++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 6fb8beda..c8506e63 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -666,7 +666,13 @@ const customizeQuickFilter = ref(false) const newQuickFilters = ref([]) function addQuickFilter(f) { - // + if (!newQuickFilters.value.some((filter) => filter.fieldname === f.value)) { + newQuickFilters.value.push({ + label: f.label, + fieldname: f.value, + fieldtype: f.fieldtype, + }) + } } function removeQuickFilter(f) { @@ -679,7 +685,29 @@ function saveQuickFilters() { // } -const quickFilterOptions = [] +const quickFilterOptions = computed(() => { + let fields = getFields() + if (!fields) return [] + + let restrictedFieldtypes = ['Tab Break', 'Section Break', 'Column Break'] + let options = fields + .filter((f) => f.label && !restrictedFieldtypes.includes(f.fieldtype)) + .map((field) => ({ + label: field.label, + value: field.fieldname, + fieldtype: field.fieldtype, + })) + + if (!options.some((f) => f.fieldname === 'name')) { + options.push({ + label: __('Name'), + fieldname: 'name', + fieldtype: 'Data', + }) + } + + return options +}) const quickFilterList = computed(() => { let filters = quickFilters.data || [] From 60fa705cac272c1407a2ffc94f1c592516202378 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 01:58:16 +0530 Subject: [PATCH 04/15] fix: save (added and removed) quick filters --- crm/api/doc.py | 43 +++++++++++++++++++++--- frontend/src/components/ViewControls.vue | 28 ++++++++++++++- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 175bccb9..c5082fde 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -2,6 +2,7 @@ import json import frappe from frappe import _ +from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.model import no_value_fields from frappe.model.document import get_controller from frappe.utils import make_filter_tuple @@ -205,6 +206,40 @@ def get_quick_filters(doctype: str): return quick_filters +@frappe.whitelist() +def update_quick_filters(quick_filters: str, old_filters: str, doctype: str): + quick_filters = json.loads(quick_filters) + old_filters = json.loads(old_filters) + + new_filters = [filter for filter in quick_filters if filter not in old_filters] + removed_filters = [filter for filter in old_filters if filter not in quick_filters] + + # remove old filters + for filter in removed_filters: + update_in_standard_filter(filter, doctype, 0) + + # add new filters + for filter in new_filters: + update_in_standard_filter(filter, doctype, 1) + + +def update_in_standard_filter(fieldname, doctype, value): + if property_name := frappe.db.exists( + "Property Setter", + {"doc_type": doctype, "field_name": fieldname, "property": "in_standard_filter"}, + ): + frappe.db.set_value("Property Setter", property_name, "value", value) + else: + make_property_setter( + doctype, + fieldname, + "in_standard_filter", + value, + "Check", + validate_fields_for_doctype=False, + ) + + @frappe.whitelist() def get_data( doctype: str, @@ -382,7 +417,7 @@ def get_data( all_count = frappe.get_list( doctype, filters=convert_filter_to_tuple(doctype, new_filters), - fields="count(*) as total_count" + fields="count(*) as total_count", )[0].total_count kc["all_count"] = all_count @@ -485,9 +520,9 @@ def get_data( "page_length_count": page_length_count, "is_default": is_default, "views": get_views(doctype), - "total_count": frappe.get_list( - doctype, filters=filters, fields="count(*) as total_count" - )[0].total_count, + "total_count": frappe.get_list(doctype, filters=filters, fields="count(*) as total_count")[ + 0 + ].total_count, "row_count": len(data), "form_script": get_form_script(doctype), "list_script": get_form_script(doctype, "List"), diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index c8506e63..cc9b258c 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -681,8 +681,34 @@ function removeQuickFilter(f) { ) } +const updateQuickFilters = createResource({ + url: 'crm.api.doc.update_quick_filters', + onSuccess() { + customizeQuickFilter.value = false + quickFilters.reload() + + createToast({ + title: __('Quick Filters updated successfully'), + icon: 'check', + iconClasses: 'text-ink-green-3', + }) + }, +}) + function saveQuickFilters() { - // + let new_filters = + newQuickFilters.value?.map((filter) => filter.fieldname) || [] + let old_filters = quickFilters.data?.map((filter) => filter.fieldname) || [] + + updateQuickFilters.update({ + params: { + quick_filters: JSON.stringify(new_filters), + old_filters: JSON.stringify(old_filters), + doctype: props.doctype, + }, + }) + + updateQuickFilters.fetch() } const quickFilterOptions = computed(() => { From 58523afbf3a72683e37d274eee5804bc17054d7d Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 01:58:45 +0530 Subject: [PATCH 05/15] fix: do not cached while reloading quick filters --- crm/api/doc.py | 4 ++-- frontend/src/components/ViewControls.vue | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index c5082fde..37d62b64 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -179,8 +179,8 @@ def get_doctype_fields_meta(DocField, doctype, allowed_fieldtypes, restricted_fi @frappe.whitelist() -def get_quick_filters(doctype: str): - meta = frappe.get_meta(doctype) +def get_quick_filters(doctype: str, cached: bool = True): + meta = frappe.get_meta(doctype, cached) fields = [field for field in meta.fields if field.in_standard_filter] quick_filters = [] diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index cc9b258c..7edbca70 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -685,6 +685,8 @@ const updateQuickFilters = createResource({ url: 'crm.api.doc.update_quick_filters', onSuccess() { customizeQuickFilter.value = false + + quickFilters.update({ params: { doctype: props.doctype, cached: false } }) quickFilters.reload() createToast({ From 5253c67196e20c9b7508484fb1733c6b98dd736b Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 15:07:42 +0530 Subject: [PATCH 06/15] fix: added global settings doctype to store quick filters order --- .../doctype/crm_global_settings/__init__.py | 0 .../crm_global_settings.js | 8 ++ .../crm_global_settings.json | 74 +++++++++++++++++++ .../crm_global_settings.py | 9 +++ .../test_crm_global_settings.py | 30 ++++++++ 5 files changed, 121 insertions(+) create mode 100644 crm/fcrm/doctype/crm_global_settings/__init__.py create mode 100644 crm/fcrm/doctype/crm_global_settings/crm_global_settings.js create mode 100644 crm/fcrm/doctype/crm_global_settings/crm_global_settings.json create mode 100644 crm/fcrm/doctype/crm_global_settings/crm_global_settings.py create mode 100644 crm/fcrm/doctype/crm_global_settings/test_crm_global_settings.py diff --git a/crm/fcrm/doctype/crm_global_settings/__init__.py b/crm/fcrm/doctype/crm_global_settings/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/crm/fcrm/doctype/crm_global_settings/crm_global_settings.js b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.js new file mode 100644 index 00000000..1a5a5af6 --- /dev/null +++ b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("CRM Global Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_global_settings/crm_global_settings.json b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.json new file mode 100644 index 00000000..9214f829 --- /dev/null +++ b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.json @@ -0,0 +1,74 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{type}-{dt}", + "creation": "2025-02-28 14:37:10.002433", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "dt", + "column_break_kipp", + "type", + "section_break_vass", + "json" + ], + "fields": [ + { + "default": "DocType", + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "label": "DocType", + "options": "DocType", + "reqd": 1 + }, + { + "fieldname": "column_break_kipp", + "fieldtype": "Column Break" + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Quick Filters\nSidebar Items", + "reqd": 1 + }, + { + "fieldname": "section_break_vass", + "fieldtype": "Section Break" + }, + { + "fieldname": "json", + "fieldtype": "JSON", + "label": "JSON" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "links": [], + "modified": "2025-02-28 14:55:33.801215", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Global Settings", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "row_format": "Dynamic", + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_global_settings/crm_global_settings.py b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.py new file mode 100644 index 00000000..a66508c1 --- /dev/null +++ b/crm/fcrm/doctype/crm_global_settings/crm_global_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class CRMGlobalSettings(Document): + pass diff --git a/crm/fcrm/doctype/crm_global_settings/test_crm_global_settings.py b/crm/fcrm/doctype/crm_global_settings/test_crm_global_settings.py new file mode 100644 index 00000000..e0e1fb20 --- /dev/null +++ b/crm/fcrm/doctype/crm_global_settings/test_crm_global_settings.py @@ -0,0 +1,30 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the doctype test records and all +# link-field test record dependencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestCRMGlobalSettings(UnitTestCase): + """ + Unit tests for CRMGlobalSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestCRMGlobalSettings(IntegrationTestCase): + """ + Integration tests for CRMGlobalSettings. + Use this class for testing interactions between multiple components. + """ + + pass From 6fa5133665a0c5cea8c924660ad0135ee4f6ae7b Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 15:08:16 +0530 Subject: [PATCH 07/15] fix: get quick filters from global settings if exists --- crm/api/doc.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 37d62b64..472d667f 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -181,9 +181,15 @@ def get_doctype_fields_meta(DocField, doctype, allowed_fieldtypes, restricted_fi @frappe.whitelist() def get_quick_filters(doctype: str, cached: bool = True): meta = frappe.get_meta(doctype, cached) - fields = [field for field in meta.fields if field.in_standard_filter] quick_filters = [] + if global_settings := frappe.db.exists("CRM Global Settings", {"dt": doctype, "type": "Quick Filters"}): + _quick_filters = frappe.db.get_value("CRM Global Settings", global_settings, "json") + _quick_filters = json.loads(_quick_filters) or [] + fields = [field for field in meta.fields if field.fieldname in _quick_filters] + else: + fields = [field for field in meta.fields if field.in_standard_filter] + for field in fields: options = field.options if field.fieldtype == "Select" and options and isinstance(options, str): From 5280a478e77466994d981081d9b003155024ee98 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 15:21:55 +0530 Subject: [PATCH 08/15] fix: create or update quick filter global settings --- crm/api/doc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crm/api/doc.py b/crm/api/doc.py index 472d667f..dbdde3e0 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -220,6 +220,9 @@ def update_quick_filters(quick_filters: str, old_filters: str, doctype: str): new_filters = [filter for filter in quick_filters if filter not in old_filters] removed_filters = [filter for filter in old_filters if filter not in quick_filters] + # update or create global quick filter settings + create_update_global_settings(doctype, quick_filters) + # remove old filters for filter in removed_filters: update_in_standard_filter(filter, doctype, 0) @@ -229,6 +232,18 @@ def update_quick_filters(quick_filters: str, old_filters: str, doctype: str): update_in_standard_filter(filter, doctype, 1) +def create_update_global_settings(doctype, quick_filters): + if global_settings := frappe.db.exists("CRM Global Settings", {"dt": doctype, "type": "Quick Filters"}): + frappe.db.set_value("CRM Global Settings", global_settings, "json", json.dumps(quick_filters)) + else: + # create CRM Global Settings doc + doc = frappe.new_doc("CRM Global Settings") + doc.dt = doctype + doc.type = "Quick Filters" + doc.json = json.dumps(quick_filters) + doc.insert() + + def update_in_standard_filter(fieldname, doctype, value): if property_name := frappe.db.exists( "Property Setter", From 44bf3d1cf706f7dc58a26f4a957eb6e9bf43ce5c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 15:44:10 +0530 Subject: [PATCH 09/15] fix: show name quick filter if added and sort based on global settings --- crm/api/doc.py | 22 ++++++++++++++++------ frontend/src/components/ViewControls.vue | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index dbdde3e0..9cc5c653 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -186,22 +186,32 @@ def get_quick_filters(doctype: str, cached: bool = True): if global_settings := frappe.db.exists("CRM Global Settings", {"dt": doctype, "type": "Quick Filters"}): _quick_filters = frappe.db.get_value("CRM Global Settings", global_settings, "json") _quick_filters = json.loads(_quick_filters) or [] - fields = [field for field in meta.fields if field.fieldname in _quick_filters] + + fields = [] + + for filter in _quick_filters: + if filter == "name": + fields.append({"label": "Name", "fieldname": "name", "fieldtype": "Data"}) + else: + field = next((f for f in meta.fields if f.fieldname == filter), None) + if field: + fields.append(field) + else: fields = [field for field in meta.fields if field.in_standard_filter] for field in fields: - options = field.options - if field.fieldtype == "Select" and options and isinstance(options, str): + options = field.get("options") + if field.get("fieldtype") == "Select" and options and isinstance(options, str): options = options.split("\n") options = [{"label": option, "value": option} for option in options] if not any([not option.get("value") for option in options]): options.insert(0, {"label": "", "value": ""}) quick_filters.append( { - "label": _(field.label), - "fieldname": field.fieldname, - "fieldtype": field.fieldtype, + "label": _(field.get("label")), + "fieldname": field.get("fieldname"), + "fieldtype": field.get("fieldtype"), "options": options, } ) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 7edbca70..3da088f2 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -729,7 +729,7 @@ const quickFilterOptions = computed(() => { if (!options.some((f) => f.fieldname === 'name')) { options.push({ label: __('Name'), - fieldname: 'name', + value: 'name', fieldtype: 'Data', }) } From 6675b2b0e966f50c2d2c29a6ca27c4d9b0e61da7 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 15:47:03 +0530 Subject: [PATCH 10/15] fix: only show customize quick filter option to manager --- frontend/src/components/ViewControls.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 3da088f2..9d1bf696 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -193,6 +193,7 @@ label: __('Customize quick filters'), icon: () => h(QuickFilterIcon, { class: 'h-4 w-4' }), onClick: () => (customizeQuickFilter = true), + condition: () => isManager(), }, ], }, From 6973d782f873ebbd429d3025a14aae6995ab9820 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 16:02:14 +0530 Subject: [PATCH 11/15] fix: newQuickFilters getting cleared --- frontend/src/components/ViewControls.vue | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 9d1bf696..494b927a 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -192,7 +192,7 @@ { label: __('Customize quick filters'), icon: () => h(QuickFilterIcon, { class: 'h-4 w-4' }), - onClick: () => (customizeQuickFilter = true), + onClick: () => showCustomizeQuickFilter(), condition: () => isManager(), }, ], @@ -664,6 +664,11 @@ const { getFields } = getMeta(props.doctype) const customizeQuickFilter = ref(false) +function showCustomizeQuickFilter() { + customizeQuickFilter.value = true + setupNewQuickFilters(quickFilters.data) +} + const newQuickFilters = ref([]) function addQuickFilter(f) { @@ -772,14 +777,18 @@ const quickFilters = createResource({ cache: ['Quick Filters', props.doctype], auto: true, onSuccess(filters) { - newQuickFilters.value = filters.map((f) => ({ - label: f.label, - fieldname: f.fieldname, - fieldtype: f.fieldtype, - })) + setupNewQuickFilters(filters) }, }) +function setupNewQuickFilters(filters) { + newQuickFilters.value = filters.map((f) => ({ + label: f.label, + fieldname: f.fieldname, + fieldtype: f.fieldtype, + })) +} + function applyQuickFilter(filter, value) { let filters = { ...list.value.params.filters } let field = filter.fieldname From 63dbe6cae797c0b0dd7698c86aa9cc97cd94e2ba Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 16:02:51 +0530 Subject: [PATCH 12/15] fix: restrict non value fieldtypes for quick filter options --- frontend/src/components/ViewControls.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 494b927a..5b9c0225 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -723,7 +723,18 @@ const quickFilterOptions = computed(() => { let fields = getFields() if (!fields) return [] - let restrictedFieldtypes = ['Tab Break', 'Section Break', 'Column Break'] + let restrictedFieldtypes = [ + 'Tab Break', + 'Section Break', + 'Column Break', + 'Table', + 'Table MultiSelect', + 'HTML', + 'Button', + 'Image', + 'Fold', + 'Heading', + ] let options = fields .filter((f) => f.label && !restrictedFieldtypes.includes(f.fieldtype)) .map((field) => ({ From 6e16869a4060f9fba3da1690c0cbac984ca5c2ec Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 28 Feb 2025 16:06:10 +0530 Subject: [PATCH 13/15] fix: scrollable quick filter area --- frontend/src/components/ViewControls.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index 5b9c0225..7d148cf3 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -62,10 +62,13 @@ v-else-if="customizeQuickFilter" class="flex items-center justify-between gap-2 p-5" > -
+