fix: show name quick filter if added and sort based on global settings
This commit is contained in:
parent
5280a478e7
commit
44bf3d1cf7
@ -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"}):
|
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 = frappe.db.get_value("CRM Global Settings", global_settings, "json")
|
||||||
_quick_filters = json.loads(_quick_filters) or []
|
_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:
|
else:
|
||||||
fields = [field for field in meta.fields if field.in_standard_filter]
|
fields = [field for field in meta.fields if field.in_standard_filter]
|
||||||
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
options = field.options
|
options = field.get("options")
|
||||||
if field.fieldtype == "Select" and options and isinstance(options, str):
|
if field.get("fieldtype") == "Select" and options and isinstance(options, str):
|
||||||
options = options.split("\n")
|
options = options.split("\n")
|
||||||
options = [{"label": option, "value": option} for option in options]
|
options = [{"label": option, "value": option} for option in options]
|
||||||
if not any([not option.get("value") for option in options]):
|
if not any([not option.get("value") for option in options]):
|
||||||
options.insert(0, {"label": "", "value": ""})
|
options.insert(0, {"label": "", "value": ""})
|
||||||
quick_filters.append(
|
quick_filters.append(
|
||||||
{
|
{
|
||||||
"label": _(field.label),
|
"label": _(field.get("label")),
|
||||||
"fieldname": field.fieldname,
|
"fieldname": field.get("fieldname"),
|
||||||
"fieldtype": field.fieldtype,
|
"fieldtype": field.get("fieldtype"),
|
||||||
"options": options,
|
"options": options,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -729,7 +729,7 @@ const quickFilterOptions = computed(() => {
|
|||||||
if (!options.some((f) => f.fieldname === 'name')) {
|
if (!options.some((f) => f.fieldname === 'name')) {
|
||||||
options.push({
|
options.push({
|
||||||
label: __('Name'),
|
label: __('Name'),
|
||||||
fieldname: 'name',
|
value: 'name',
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Data',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user