From 149fa41e2b5808b10bedda5d3d3dd7b4e9be63b5 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 29 Jul 2014 17:19:00 +0300 Subject: [PATCH] textFilter --- application/Espo/Core/SelectManagers/Base.php | 17 ++++++++++ .../metadata/entityDefs/Account.json | 3 +- .../Resources/metadata/entityDefs/Call.json | 3 +- .../metadata/entityDefs/Contact.json | 3 +- .../Resources/metadata/entityDefs/Lead.json | 3 +- .../metadata/entityDefs/Meeting.json | 3 +- .../metadata/entityDefs/Opportunity.json | 3 +- .../Resources/metadata/entityDefs/Target.json | 3 +- .../Resources/metadata/entityDefs/Task.json | 3 +- .../client/res/templates/record/search.tpl | 4 +-- frontend/client/src/search-manager.js | 31 +++++++------------ frontend/client/src/views/record/search.js | 29 ++++++----------- 12 files changed, 47 insertions(+), 58 deletions(-) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index a7cb2c1c82..74c73a6fff 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -82,6 +82,11 @@ class Base } } } + + protected function getTextFilterFields() + { + return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name')); + } protected function where($params, &$result) { @@ -96,6 +101,18 @@ class Base $params['where'][] = $p; } } + } else if ($item['type'] == 'textFilter' && !empty($item['value'])) { + if (!empty($item['value'])) { + if (empty($result['whereClause'])) { + $result['whereClause'] = array(); + } + $fieldList = $this->getTextFilterFields(); + $d = array(); + foreach ($fieldList as $field) { + $d[$field . '*'] = $item['value'] . '%'; + } + $where['OR'] = $d; + } } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index 10ab1881dd..af9b9610f9 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -155,7 +155,6 @@ }, "collection": { "sortBy": "name", - "asc": true, - "boolFilters": ["onlyMy"] + "asc": true } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json index 5dd8ed6797..8e58a5235d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json @@ -148,7 +148,6 @@ }, "collection": { "sortBy": "dateStart", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index dec63d2b35..cbae898ba2 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -183,7 +183,6 @@ }, "collection": { "sortBy": "name", - "asc": true, - "boolFilters": ["onlyMy"] + "asc": true } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index dfe5755c82..a9178832a3 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -189,7 +189,6 @@ }, "collection": { "sortBy": "createdAt", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json index 69a1eaf423..2d6b57a976 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json @@ -143,7 +143,6 @@ }, "collection": { "sortBy": "dateStart", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json index f31c43c239..864182c730 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json @@ -125,7 +125,6 @@ }, "collection": { "sortBy": "createdAt", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json index 4398cab884..c1cd05f74f 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json @@ -108,7 +108,6 @@ }, "collection": { "sortBy": "createdAt", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json index c08c1a621e..18b2227153 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json @@ -87,7 +87,6 @@ }, "collection": { "sortBy": "createdAt", - "asc": false, - "boolFilters": ["onlyMy"] + "asc": false } } diff --git a/frontend/client/res/templates/record/search.tpl b/frontend/client/res/templates/record/search.tpl index ad12dc3b4d..6c32a1b496 100644 --- a/frontend/client/res/templates/record/search.tpl +++ b/frontend/client/res/templates/record/search.tpl @@ -7,7 +7,7 @@ -