diff --git a/crm/api/doc.py b/crm/api/doc.py index 576127a1a..07285e9e0 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -551,7 +551,9 @@ def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False): fields_meta = {} for field in fields: fields_meta[field.get('fieldname')] = field - + if field.get('fieldtype') == "Table": + _fields = frappe.get_meta(field.get('options')).fields + fields_meta[field.get('fieldname')] = {"df": field, "fields": _fields} return fields_meta @frappe.whitelist() diff --git a/crm/fcrm/doctype/crm_deal/api.py b/crm/fcrm/doctype/crm_deal/api.py index 76a764aed..2ca217ed9 100644 --- a/crm/fcrm/doctype/crm_deal/api.py +++ b/crm/fcrm/doctype/crm_deal/api.py @@ -1,33 +1,12 @@ import frappe -from frappe import _ from crm.api.doc import get_fields_meta, get_assigned_users from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script @frappe.whitelist() def get_deal(name): - Deal = frappe.qb.DocType("CRM Deal") + deal = frappe.get_doc("CRM Deal", name).as_dict() - query = ( - frappe.qb.from_(Deal) - .select("*") - .where(Deal.name == name) - .limit(1) - ) - - deal = query.run(as_dict=True) - if not len(deal): - frappe.throw(_("Deal not found"), frappe.DoesNotExistError) - deal = deal.pop() - - - deal["contacts"] = frappe.get_all( - "CRM Contacts", - filters={"parenttype": "CRM Deal", "parent": deal.name}, - fields=["contact", "is_primary"], - ) - - deal["doctype"] = "CRM Deal" deal["fields_meta"] = get_fields_meta("CRM Deal") deal["_form_script"] = get_form_script('CRM Deal') deal["_assign"] = get_assigned_users("CRM Deal", deal.name, deal.owner) diff --git a/crm/fcrm/doctype/crm_lead/api.py b/crm/fcrm/doctype/crm_lead/api.py index e1bb4a4f5..160710684 100644 --- a/crm/fcrm/doctype/crm_lead/api.py +++ b/crm/fcrm/doctype/crm_lead/api.py @@ -6,16 +6,8 @@ @frappe.whitelist() def get_lead(name): - Lead = frappe.qb.DocType("CRM Lead") + lead = frappe.get_doc("CRM Lead", name).as_dict() - query = frappe.qb.from_(Lead).select("*").where(Lead.name == name).limit(1) - - lead = query.run(as_dict=True) - if not len(lead): - frappe.throw(_("Lead not found"), frappe.DoesNotExistError) - lead = lead.pop() - - lead["doctype"] = "CRM Lead" lead["fields_meta"] = get_fields_meta("CRM Lead") lead["_form_script"] = get_form_script('CRM Lead') lead["_assign"] = get_assigned_users("CRM Lead", lead.name, lead.owner) diff --git a/frontend/src/components/Activities/Activities.vue b/frontend/src/components/Activities/Activities.vue index 2a3f3dd67..89205f3c8 100644 --- a/frontend/src/components/Activities/Activities.vue +++ b/frontend/src/components/Activities/Activities.vue @@ -366,6 +366,9 @@ +
+ +
+ + diff --git a/frontend/src/components/DocFields.vue b/frontend/src/components/DocFields.vue new file mode 100644 index 000000000..83d863e1e --- /dev/null +++ b/frontend/src/components/DocFields.vue @@ -0,0 +1,148 @@ + + + diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index 116963914..c3575464f 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -36,7 +36,12 @@
- + { label: __('Comments'), icon: CommentIcon, }, + { + name: 'Data', + label: __('Data'), + icon: DetailsIcon, + }, { name: 'Calls', label: __('Calls'), diff --git a/frontend/src/pages/Lead.vue b/frontend/src/pages/Lead.vue index 57918033b..0ec6aa311 100644 --- a/frontend/src/pages/Lead.vue +++ b/frontend/src/pages/Lead.vue @@ -41,7 +41,12 @@
- + { label: __('Comments'), icon: CommentIcon, }, + { + name: 'Data', + label: __('Data'), + icon: DetailsIcon, + }, { name: 'Calls', label: __('Calls'), diff --git a/frontend/src/types/controls.ts b/frontend/src/types/controls.ts new file mode 100644 index 000000000..9d27299e0 --- /dev/null +++ b/frontend/src/types/controls.ts @@ -0,0 +1,49 @@ +export type FieldTypes = + | 'Data' + | 'Int' + | 'Float' + | 'Currency' + | 'Check' + | 'Text' + | 'Small Text' + | 'Long Text' + | 'Code' + | 'Text Editor' + | 'Date' + | 'Datetime' + | 'Time' + | 'HTML' + | 'Image' + | 'Attach' + | 'Select' + | 'Read Only' + | 'Section Break' + | 'Column Break' + | 'Table' + | 'Button' + | 'Link' + | 'Dynamic Link' + | 'Password' + | 'Signature' + | 'Color' + | 'Barcode' + | 'Geolocation' + | 'Duration' + | 'Percent' + | 'Rating' + | 'Icon' + +// Grid / Child Table +export interface GridColumn { + label: string + fieldname: string + fieldtype: FieldTypes + options?: string | string[] + width?: number + onChange?: (value: string, index: number) => void +} + +export interface GridRow { + name: string + [fieldname: string]: string | number | boolean +} diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index be5abbe47..00787134f 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -291,3 +291,14 @@ export function isImage(extention) { extention.toLowerCase(), ) } + +export function getRandom(len) { + let text = '' + const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + + Array.from({ length: len }).forEach(() => { + text += possible.charAt(Math.floor(Math.random() * possible.length)) + }) + + return text +}