From c15a1bc991e2510d11d3f0e97d4e07fd2513282e Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 17:24:37 +0530 Subject: [PATCH 1/9] fix: added datepicker & daterangepicker control from insights --- .../src/components/Controls/DatePicker.vue | 265 +++++++++++++++ .../components/Controls/DateRangePicker.vue | 313 ++++++++++++++++++ 2 files changed, 578 insertions(+) create mode 100644 frontend/src/components/Controls/DatePicker.vue create mode 100644 frontend/src/components/Controls/DateRangePicker.vue diff --git a/frontend/src/components/Controls/DatePicker.vue b/frontend/src/components/Controls/DatePicker.vue new file mode 100644 index 00000000..5ffc45d4 --- /dev/null +++ b/frontend/src/components/Controls/DatePicker.vue @@ -0,0 +1,265 @@ + + + diff --git a/frontend/src/components/Controls/DateRangePicker.vue b/frontend/src/components/Controls/DateRangePicker.vue new file mode 100644 index 00000000..64a00fd6 --- /dev/null +++ b/frontend/src/components/Controls/DateRangePicker.vue @@ -0,0 +1,313 @@ + + + From 714233a86271f4aa10b8cb55c3fffece44b9d371 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 17:26:36 +0530 Subject: [PATCH 2/9] fix: added date & datetime field in allowed fieldtypes --- crm/api/doc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crm/api/doc.py b/crm/api/doc.py index a9fc2237..14e94a9a 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -46,6 +46,8 @@ def get_filterable_fields(doctype: str): "Small Text", "Text Editor", "Text", + "Date", + "Datetime", ] c = get_controller(doctype) @@ -84,6 +86,8 @@ def get_filterable_fields(doctype: str): {"fieldname": "_liked_by", "fieldtype": "Data", "label": "Liked By"}, {"fieldname": "_comments", "fieldtype": "Text", "label": "Comments"}, {"fieldname": "_assign", "fieldtype": "Text", "label": "Assigned To"}, + {"fieldname": "creation", "fieldtype": "Datetime", "label": "Created On"}, + {"fieldname": "modified", "fieldtype": "Datetime", "label": "Last Updated On"}, ] for field in standard_fields: if ( From 31ab117e8f7d9854ad856ee7612512c9c3bacffd Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 17:32:34 +0530 Subject: [PATCH 3/9] fix: allow datetime filtering --- frontend/src/components/Filter.vue | 183 +++++++++++++++++++++++++---- 1 file changed, 163 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index 5d982598..d5281901 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -44,19 +44,10 @@ />
-
@@ -103,6 +94,8 @@ From 91b7407aa5e15c9b31d99351d6269aed42b0e1b8 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 18:03:55 +0530 Subject: [PATCH 4/9] fix: do not show % for like operator --- frontend/src/components/Filter.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index d5281901..7af510d4 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -175,6 +175,10 @@ function convertFilters(data, allFilters) { value = ['equals', value[1] ? 'Yes' : 'No'] } } + if (value[0] === 'LIKE') { + value[1] = value[1].replace(/%/g, '') + } + if (field) { f.push({ field, @@ -408,8 +412,8 @@ function apply() { } function parseFilters(filters) { - const l__ = Array.from(filters) - const obj = l__.map(transformIn).reduce((p, c) => { + const filtersArray = Array.from(filters) + const obj = filtersArray.map(transformIn).reduce((p, c) => { if (['equals', '='].includes(c.operator)) { p[c.fieldname] = c.value == 'Yes' ? true : c.value == 'No' ? false : c.value From d21f41288b45866599b290a22931e7a6b833a840 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 18:06:50 +0530 Subject: [PATCH 5/9] fix: also consider Not Like --- frontend/src/components/Filter.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index 7af510d4..d7eecb9f 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -175,7 +175,7 @@ function convertFilters(data, allFilters) { value = ['equals', value[1] ? 'Yes' : 'No'] } } - if (value[0] === 'LIKE') { + if (value[0] === 'LIKE' || value[0] === 'NOT LIKE') { value[1] = value[1].replace(/%/g, '') } @@ -200,6 +200,7 @@ function getOperators(fieldtype, fieldname) { { label: 'Not Equals', value: 'not equals' }, { label: 'Like', value: 'like' }, { label: 'Not Like', value: 'not like' }, + { label: 'Is', value: 'is' }, ] ) } @@ -390,7 +391,7 @@ function updateOperator(event, filter) { } function isSameTypeOperator(oldOperator, newOperator) { - let textOperators = ['equals', 'not equals', '>', '<', '>=', '<='] + let textOperators = ['like', 'not like', 'equals', 'not equals', '>', '<', '>=', '<='] if ( textOperators.includes(oldOperator) && textOperators.includes(newOperator) From 4175371708f03f459bb3660d15bdc65be245ab2a Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 18:57:56 +0530 Subject: [PATCH 6/9] fix: made read only field editable in lead doctype --- crm/fcrm/doctype/crm_lead/crm_lead.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.json b/crm/fcrm/doctype/crm_lead/crm_lead.json index a314c941..127cdfde 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.json +++ b/crm/fcrm/doctype/crm_lead/crm_lead.json @@ -134,15 +134,13 @@ "fieldname": "no_of_employees", "fieldtype": "Select", "label": "No. of Employees", - "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+", - "read_only": 1 + "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+" }, { "fetch_from": "organization.annual_revenue", "fieldname": "annual_revenue", "fieldtype": "Currency", - "label": "Annual Revenue", - "read_only": 1 + "label": "Annual Revenue" }, { "fieldname": "lead_owner", @@ -294,7 +292,7 @@ "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-22 14:33:21.980634", + "modified": "2024-01-28 18:35:02.604536", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead", From 322f9d7dda2052b27db22b53966cb63d4c011a38 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 18:58:59 +0530 Subject: [PATCH 7/9] fix: allow is operator in Select & Link also like, not like in Select field --- frontend/src/components/Filter.vue | 51 ++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index d7eecb9f..41c10059 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -223,11 +223,23 @@ function getOperators(fieldtype, fieldname) { ] ) } - if (typeSelect.includes(fieldtype) || typeLink.includes(fieldtype)) { + if (typeSelect.includes(fieldtype)) { options.push( ...[ { label: 'Equals', value: 'equals' }, { label: 'Not Equals', value: 'not equals' }, + { label: 'Is', value: 'is' }, + ] + ) + } + if (typeLink.includes(fieldtype)) { + options.push( + ...[ + { label: 'Equals', value: 'equals' }, + { label: 'Not Equals', value: 'not equals' }, + { label: 'Is', value: 'is' }, + { label: 'Like', value: 'like' }, + { label: 'Not Like', value: 'not like' }, ] ) } @@ -253,17 +265,7 @@ function getOperators(fieldtype, fieldname) { function getValSelect(f) { const { field, operator } = f const { fieldtype, options } = field - if (typeSelect.includes(fieldtype) || typeCheck.includes(fieldtype)) { - const _options = - fieldtype == 'Check' ? ['Yes', 'No'] : getSelectOptions(options) - return h(FormControl, { - type: 'select', - options: _options.map((o) => ({ - label: o, - value: o, - })), - }) - } else if (operator == 'is') { + if (operator == 'is') { return h(FormControl, { type: 'select', options: [ @@ -282,6 +284,18 @@ function getValSelect(f) { type: 'select', options: timespanOptions, }) + } else if (operator == 'like') { + return h(FormControl, { type: 'text' }) + } else if (typeSelect.includes(fieldtype) || typeCheck.includes(fieldtype)) { + const _options = + fieldtype == 'Check' ? ['Yes', 'No'] : getSelectOptions(options) + return h(FormControl, { + type: 'select', + options: _options.map((o) => ({ + label: o, + value: o, + })), + }) } else if (typeLink.includes(fieldtype)) { return h(Link, { class: 'form-control', doctype: options }) } else if (typeNumber.includes(fieldtype)) { @@ -309,7 +323,7 @@ function getDefaultValue(field) { } function getDefaultOperator(fieldtype) { - if (typeSelect.includes(fieldtype) || typeLink.includes(fieldtype)) { + if (typeSelect.includes(fieldtype)) { return 'equals' } if (typeCheck.includes(fieldtype) || typeNumber.includes(fieldtype)) { @@ -391,7 +405,16 @@ function updateOperator(event, filter) { } function isSameTypeOperator(oldOperator, newOperator) { - let textOperators = ['like', 'not like', 'equals', 'not equals', '>', '<', '>=', '<='] + let textOperators = [ + 'like', + 'not like', + 'equals', + 'not equals', + '>', + '<', + '>=', + '<=', + ] if ( textOperators.includes(oldOperator) && textOperators.includes(newOperator) From 2780bc7b40dfcd7f31f0e5c8227601df585cfae2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 20:02:46 +0530 Subject: [PATCH 8/9] fix: allow currency fieldtype in filter --- crm/api/doc.py | 1 + frontend/src/components/Filter.vue | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 14e94a9a..9273fef7 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -40,6 +40,7 @@ def get_filterable_fields(doctype: str): "Data", "Float", "Int", + "Currency", "Link", "Long Text", "Select", diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index 41c10059..fb03e688 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -104,7 +104,7 @@ import { h, defineModel, computed } from 'vue' const typeCheck = ['Check'] const typeLink = ['Link'] -const typeNumber = ['Float', 'Int'] +const typeNumber = ['Float', 'Int', 'Currency', 'Percent'] const typeSelect = ['Select'] const typeString = ['Data', 'Long Text', 'Small Text', 'Text Editor', 'Text'] const typeDate = ['Date', 'Datetime'] @@ -209,6 +209,7 @@ function getOperators(fieldtype, fieldname) { options = [ { label: 'Like', value: 'like' }, { label: 'Not Like', value: 'not like' }, + { label: 'Is', value: 'is' }, ] } if (typeNumber.includes(fieldtype)) { @@ -340,6 +341,7 @@ function getSelectOptions(options) { } function setfilter(data) { + if (!data) return filters.value.add({ field: { label: data.label, From d783b02dd8771331f1602b645e5b3744ba565f60 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sun, 28 Jan 2024 20:18:44 +0530 Subject: [PATCH 9/9] fix: also added duration fieldtype --- crm/api/doc.py | 1 + frontend/src/components/Filter.vue | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/crm/api/doc.py b/crm/api/doc.py index 9273fef7..ce611e15 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -47,6 +47,7 @@ def get_filterable_fields(doctype: str): "Small Text", "Text Editor", "Text", + "Duration", "Date", "Datetime", ] diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index fb03e688..11807885 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -247,6 +247,15 @@ function getOperators(fieldtype, fieldname) { if (typeCheck.includes(fieldtype)) { options.push(...[{ label: 'Equals', value: 'equals' }]) } + if (['Duration'].includes(fieldtype)) { + options.push( + ...[ + { label: 'Like', value: 'like' }, + { label: 'Not Like', value: 'not like' }, + { label: 'Is', value: 'is' }, + ] + ) + } if (typeDate.includes(fieldtype)) { options.push( ...[