diff --git a/crm/api/doc.py b/crm/api/doc.py index 02d14b993..dbadf320d 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -57,10 +57,13 @@ def get_list_data(doctype: str, filters: dict, order_by: str): ] rows = ["name"] + is_default = True + if frappe.db.exists("CRM List View Settings", doctype): list_view_settings = frappe.get_doc("CRM List View Settings", doctype) columns = frappe.parse_json(list_view_settings.columns) rows = frappe.parse_json(list_view_settings.rows) + is_default = False else: list = get_controller(doctype) @@ -113,7 +116,13 @@ def get_list_data(doctype: str, filters: dict, order_by: str): if field not in fields: fields.append(field) - return {'data': data, 'columns': columns, 'rows': rows, 'fields': fields} + return { + "data": data, + "columns": columns, + "rows": rows, + "fields": fields, + "is_default": is_default, + } @frappe.whitelist() diff --git a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py index ea5917282..66770ce8c 100644 --- a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py +++ b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py @@ -43,3 +43,8 @@ def sync_default_list_rows(doctype): rows = list.default_list_data().get("rows") return rows + +@frappe.whitelist() +def reset_to_default(doctype): + if frappe.db.exists("CRM List View Settings", doctype): + frappe.delete_doc("CRM List View Settings", doctype) \ No newline at end of file diff --git a/frontend/src/components/Icons/ReloadIcon.vue b/frontend/src/components/Icons/ReloadIcon.vue new file mode 100644 index 000000000..09c8e6c85 --- /dev/null +++ b/frontend/src/components/Icons/ReloadIcon.vue @@ -0,0 +1,22 @@ + diff --git a/frontend/src/components/ViewSettings.vue b/frontend/src/components/ViewSettings.vue index a678be040..f6189b96f 100644 --- a/frontend/src/components/ViewSettings.vue +++ b/frontend/src/components/ViewSettings.vue @@ -45,7 +45,7 @@ -
+
+
@@ -115,6 +126,7 @@ import SettingsIcon from '@/components/Icons/SettingsIcon.vue' import EditIcon from '@/components/Icons/EditIcon.vue' import DragIcon from '@/components/Icons/DragIcon.vue' +import ReloadIcon from '@/components/Icons/ReloadIcon.vue' import NestedPopover from '@/components/NestedPopover.vue' import Autocomplete from '@/components/frappe-ui/Autocomplete.vue' import Draggable from 'vuedraggable' @@ -137,6 +149,13 @@ const column = ref({ width: '10rem', }) +const is_default = computed({ + get: () => list.value?.data?.is_default, + set: (val) => { + list.value.data.is_default = val + }, +}) + const columns = computed({ get: () => list.value?.data?.columns, set: (val) => { @@ -207,6 +226,7 @@ function cancelUpdate() { } async function updateColumnDetails() { + is_default.value = false await call( 'crm.fcrm.doctype.crm_list_view_settings.crm_list_view_settings.update', { @@ -216,4 +236,14 @@ async function updateColumnDetails() { } ) } + +async function resetToDefault() { + await call( + 'crm.fcrm.doctype.crm_list_view_settings.crm_list_view_settings.reset_to_default', + { + doctype: props.doctype, + } + ) + list.value.reload() +}