From 4ed8a54a98feb9be3ff84922af17388605d06616 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 17 Jun 2025 12:37:08 +0530 Subject: [PATCH] fix: renamed component names from Agent to User (cherry picked from commit b534aae70bc6304c818ef33e05c8a0a50146a4cf) --- .../{crm_agent => crm_user}/__init__.py | 0 .../crm_agent.js => crm_user/crm_user.js} | 2 +- .../crm_agent.json => crm_user/crm_user.json} | 18 +-- .../crm_agent.py => crm_user/crm_user.py} | 18 +-- .../test_crm_user.py} | 8 +- frontend/components.d.ts | 2 + ...InviteAgentPage.vue => InviteUserPage.vue} | 0 frontend/src/components/Settings/Settings.vue | 16 +-- .../Settings/{Agents.vue => Users.vue} | 121 +++++++++--------- 9 files changed, 92 insertions(+), 93 deletions(-) rename crm/fcrm/doctype/{crm_agent => crm_user}/__init__.py (100%) rename crm/fcrm/doctype/{crm_agent/crm_agent.js => crm_user/crm_user.js} (81%) rename crm/fcrm/doctype/{crm_agent/crm_agent.json => crm_user/crm_user.json} (92%) rename crm/fcrm/doctype/{crm_agent/crm_agent.py => crm_user/crm_user.py} (78%) rename crm/fcrm/doctype/{crm_agent/test_crm_agent.py => crm_user/test_crm_user.py} (80%) rename frontend/src/components/Settings/{InviteAgentPage.vue => InviteUserPage.vue} (100%) rename frontend/src/components/Settings/{Agents.vue => Users.vue} (67%) diff --git a/crm/fcrm/doctype/crm_agent/__init__.py b/crm/fcrm/doctype/crm_user/__init__.py similarity index 100% rename from crm/fcrm/doctype/crm_agent/__init__.py rename to crm/fcrm/doctype/crm_user/__init__.py diff --git a/crm/fcrm/doctype/crm_agent/crm_agent.js b/crm/fcrm/doctype/crm_user/crm_user.js similarity index 81% rename from crm/fcrm/doctype/crm_agent/crm_agent.js rename to crm/fcrm/doctype/crm_user/crm_user.js index 042c06ea..71b91b59 100644 --- a/crm/fcrm/doctype/crm_agent/crm_agent.js +++ b/crm/fcrm/doctype/crm_user/crm_user.js @@ -1,7 +1,7 @@ // Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -// frappe.ui.form.on("CRM Agent", { +// frappe.ui.form.on("CRM User", { // refresh(frm) { // }, diff --git a/crm/fcrm/doctype/crm_agent/crm_agent.json b/crm/fcrm/doctype/crm_user/crm_user.json similarity index 92% rename from crm/fcrm/doctype/crm_agent/crm_agent.json rename to crm/fcrm/doctype/crm_user/crm_user.json index c765290d..5ba7f5e0 100644 --- a/crm/fcrm/doctype/crm_agent/crm_agent.json +++ b/crm/fcrm/doctype/crm_user/crm_user.json @@ -13,7 +13,7 @@ "middle_name", "last_name", "column_break_kpoq", - "agent_name", + "user_name", "image" ], "fields": [ @@ -34,11 +34,6 @@ "fieldname": "section_break_qdxc", "fieldtype": "Section Break" }, - { - "fieldname": "agent_name", - "fieldtype": "Data", - "label": "Full Name" - }, { "fieldname": "column_break_kpoq", "fieldtype": "Column Break" @@ -66,16 +61,21 @@ "fieldname": "last_name", "fieldtype": "Data", "label": "Last Name" + }, + { + "fieldname": "user_name", + "fieldtype": "Data", + "label": "Full Name" } ], "grid_page_length": 50, "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2025-05-21 16:35:07.667954", + "modified": "2025-06-17 12:08:16.616216", "modified_by": "Administrator", "module": "FCRM", - "name": "CRM Agent", + "name": "CRM User", "naming_rule": "By fieldname", "owner": "Administrator", "permissions": [ @@ -96,5 +96,5 @@ "sort_field": "creation", "sort_order": "DESC", "states": [], - "title_field": "agent_name" + "title_field": "user_name" } diff --git a/crm/fcrm/doctype/crm_agent/crm_agent.py b/crm/fcrm/doctype/crm_user/crm_user.py similarity index 78% rename from crm/fcrm/doctype/crm_agent/crm_agent.py rename to crm/fcrm/doctype/crm_user/crm_user.py index 21ddb800..98c74d51 100644 --- a/crm/fcrm/doctype/crm_agent/crm_agent.py +++ b/crm/fcrm/doctype/crm_user/crm_user.py @@ -5,7 +5,7 @@ import frappe from frappe.model.document import Document -class CRMAgent(Document): +class CRMUser(Document): def validate(self): if self.user: user = frappe.get_doc("User", self.user) @@ -15,16 +15,16 @@ class CRMAgent(Document): self.middle_name = user.middle_name if not self.last_name: self.last_name = user.last_name - if not self.agent_name: - self.agent_name = user.full_name + if not self.user_name: + self.user_name = user.full_name if not self.image: self.image = user.user_image @frappe.whitelist() -def update_agent_role(user, new_role): +def update_user_role(user, new_role): """ - Update the role of the user to Agent + Update the role of the user to Sales Manager, Sales User, or System Manager. :param user: The name of the user :param new_role: The new role to assign (Sales Manager or Sales User) """ @@ -49,12 +49,12 @@ def update_agent_role(user, new_role): @frappe.whitelist() -def update_agent_status(agent, status): +def update_user_status(user, status): """ - Activate or deactivate the agent - :param agent: The name of the agent + Activate or deactivate the user + :param user: The name of the user :param status: The status to set (1 for active, 0 for inactive) """ frappe.only_for("Sales Manager") - frappe.db.set_value("CRM Agent", agent, "is_active", status) + frappe.db.set_value("CRM User", user, "is_active", status) diff --git a/crm/fcrm/doctype/crm_agent/test_crm_agent.py b/crm/fcrm/doctype/crm_user/test_crm_user.py similarity index 80% rename from crm/fcrm/doctype/crm_agent/test_crm_agent.py rename to crm/fcrm/doctype/crm_user/test_crm_user.py index ebc29c58..f368fa88 100644 --- a/crm/fcrm/doctype/crm_agent/test_crm_agent.py +++ b/crm/fcrm/doctype/crm_user/test_crm_user.py @@ -11,18 +11,18 @@ EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] -class UnitTestCRMAgent(UnitTestCase): +class UnitTestCRMUser(UnitTestCase): """ - Unit tests for CRMAgent. + Unit tests for CRMUser. Use this class for testing individual functions and methods. """ pass -class IntegrationTestCRMAgent(IntegrationTestCase): +class IntegrationTestCRMUser(IntegrationTestCase): """ - Integration tests for CRMAgent. + Integration tests for CRMUser. Use this class for testing interactions between multiple components. """ diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 7faf480d..4c5b3699 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -138,6 +138,7 @@ declare module 'vue' { IndicatorIcon: typeof import('./src/components/Icons/IndicatorIcon.vue')['default'] InviteAgentPage: typeof import('./src/components/Settings/InviteAgentPage.vue')['default'] InviteIcon: typeof import('./src/components/Icons/InviteIcon.vue')['default'] + InviteUserPage: typeof import('./src/components/Settings/InviteUserPage.vue')['default'] KanbanIcon: typeof import('./src/components/Icons/KanbanIcon.vue')['default'] KanbanSettings: typeof import('./src/components/Kanban/KanbanSettings.vue')['default'] KanbanView: typeof import('./src/components/Kanban/KanbanView.vue')['default'] @@ -229,6 +230,7 @@ declare module 'vue' { UnpinIcon: typeof import('./src/components/Icons/UnpinIcon.vue')['default'] UserAvatar: typeof import('./src/components/UserAvatar.vue')['default'] UserDropdown: typeof import('./src/components/UserDropdown.vue')['default'] + Users: typeof import('./src/components/Settings/Users.vue')['default'] ViewBreadcrumbs: typeof import('./src/components/ViewBreadcrumbs.vue')['default'] ViewControls: typeof import('./src/components/ViewControls.vue')['default'] ViewModal: typeof import('./src/components/Modals/ViewModal.vue')['default'] diff --git a/frontend/src/components/Settings/InviteAgentPage.vue b/frontend/src/components/Settings/InviteUserPage.vue similarity index 100% rename from frontend/src/components/Settings/InviteAgentPage.vue rename to frontend/src/components/Settings/InviteUserPage.vue diff --git a/frontend/src/components/Settings/Settings.vue b/frontend/src/components/Settings/Settings.vue index 5ced2f05..c20984e8 100644 --- a/frontend/src/components/Settings/Settings.vue +++ b/frontend/src/components/Settings/Settings.vue @@ -46,9 +46,9 @@ import ERPNextIcon from '@/components/Icons/ERPNextIcon.vue' import PhoneIcon from '@/components/Icons/PhoneIcon.vue' import InviteIcon from '@/components/Icons/InviteIcon.vue' import Email2Icon from '@/components/Icons/Email2Icon.vue' -import Agents from '@/components/Settings/Agents.vue' +import Users from '@/components/Settings/Users.vue' import GeneralSettings from '@/components/Settings/GeneralSettings.vue' -import InviteAgentPage from '@/components/Settings/InviteAgentPage.vue' +import InviteUserPage from '@/components/Settings/InviteUserPage.vue' import ProfileSettings from '@/components/Settings/ProfileSettings.vue' import WhatsAppSettings from '@/components/Settings/WhatsAppSettings.vue' import ERPNextSettings from '@/components/Settings/ERPNextSettings.vue' @@ -84,21 +84,21 @@ const tabs = computed(() => { }), component: markRaw(ProfileSettings), }, - { - label: __('Users'), - icon: 'user', - component: markRaw(Agents), - }, { label: __('General'), icon: 'settings', component: markRaw(GeneralSettings), condition: () => isManager(), }, + { + label: __('Users'), + icon: 'user', + component: markRaw(Users), + }, { label: __('Invite User'), icon: InviteIcon, - component: markRaw(InviteAgentPage), + component: markRaw(InviteUserPage), condition: () => isManager(), }, { diff --git a/frontend/src/components/Settings/Agents.vue b/frontend/src/components/Settings/Users.vue similarity index 67% rename from frontend/src/components/Settings/Agents.vue rename to frontend/src/components/Settings/Users.vue index df77688f..684ee726 100644 --- a/frontend/src/components/Settings/Agents.vue +++ b/frontend/src/components/Settings/Users.vue @@ -31,15 +31,15 @@ :label="__('Add User')" icon-left="plus" variant="solid" - @click="$emit('add-agent')" + @click="$emit('add-user')" /> -
+