From 8330137c4e5768cc5b2955dc2f9276ab1ed94d8e Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 17 Sep 2015 13:18:05 +0300 Subject: [PATCH] fixes with assignment in mass update and autopopulate --- application/Espo/Core/SelectManagers/Base.php | 22 +--------------- application/Espo/Services/Record.php | 17 +++++++----- .../client/src/views/fields/link-multiple.js | 16 +++++++++--- .../client/src/views/fields/link-parent.js | 16 +++++++++--- frontend/client/src/views/fields/link.js | 26 ++++++++++++------- 5 files changed, 52 insertions(+), 45 deletions(-) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index 076b2e9d59..83960d78fc 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -299,27 +299,7 @@ class Base protected function q($params, &$result) { if (!empty($params['q'])) { - $fieldDefs = $this->getSeed()->getFields(); - - $value = $params['q']; - - $fieldList = $this->getTextFilterFields(); - $d = array(); - foreach ($fieldList as $field) { - if ( - strlen($value) >= self::MIN_LENGTH_FOR_CONTENT_SEARCH - && - !empty($fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'text' - ) { - $d[$field . '*'] = '%' . $value . '%'; - } else { - $d[$field . '*'] = $value . '%'; - } - } - - $result['whereClause'][] = array( - 'OR' => $d - ); + $this->textFilter($params['q'], $result); } } diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index a8576cd41e..6a5af03b2c 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -793,9 +793,11 @@ class Record extends \Espo\Core\Services\Base $entity = $this->getEntity($id); if ($this->getAcl()->check($entity, 'edit')) { $entity->set(get_object_vars($attributes)); - if ($repository->save($entity)) { - $idsUpdated[] = $id; - $count++; + if ($this->checkAssignment($entity)) { + if ($repository->save($entity)) { + $idsUpdated[] = $id; + $count++; + } } } } @@ -812,9 +814,11 @@ class Record extends \Espo\Core\Services\Base foreach ($collection as $entity) { if ($this->getAcl()->check($entity, 'edit')) { $entity->set(get_object_vars($attributes)); - if ($repository->save($entity)) { - $idsUpdated[] = $id; - $count++; + if ($this->checkAssignment($entity)) { + if ($repository->save($entity)) { + $idsUpdated[] = $id; + $count++; + } } } } @@ -822,7 +826,6 @@ class Record extends \Espo\Core\Services\Base return array( 'count' => $count ); - } return array( diff --git a/frontend/client/src/views/fields/link-multiple.js b/frontend/client/src/views/fields/link-multiple.js index 1f8ca7eb06..e1031a237e 100644 --- a/frontend/client/src/views/fields/link-multiple.js +++ b/frontend/client/src/views/fields/link-multiple.js @@ -129,14 +129,22 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) { getAutocompleteUrl: function () { var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT; var boolList = this.getSelectBoolFilterList(); + var where = []; if (boolList) { - boolList.forEach(function(item) { - url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item; - }, this); + where.push({ + type: 'bool', + value: boolList + }); } var primary = this.getSelectPrimaryFilterName(); if (primary) { - url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary; + where.push({ + type: 'primary', + value: primary + }); + } + if (where.length) { + url += '&' + $.param({'where': where}); } return url; }, diff --git a/frontend/client/src/views/fields/link-parent.js b/frontend/client/src/views/fields/link-parent.js index 248929d37a..56107937ec 100644 --- a/frontend/client/src/views/fields/link-parent.js +++ b/frontend/client/src/views/fields/link-parent.js @@ -132,14 +132,22 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) { getAutocompleteUrl: function () { var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT; var boolList = this.getSelectBoolFilterList(); + var where = []; if (boolList) { - boolList.forEach(function(item) { - url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item; - }, this); + where.push({ + type: 'bool', + value: boolList + }); } var primary = this.getSelectPrimaryFilterName(); if (primary) { - url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary; + where.push({ + type: 'primary', + value: primary + }); + } + if (where.length) { + url += '&' + $.param({'where': where}); } return url; }, diff --git a/frontend/client/src/views/fields/link.js b/frontend/client/src/views/fields/link.js index 2d1b1d7c37..8c4ec868db 100644 --- a/frontend/client/src/views/fields/link.js +++ b/frontend/client/src/views/fields/link.js @@ -25,13 +25,13 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) { type: 'link', - listTemplate: 'fields.link.list', + listTemplate: 'fields/link/list', - detailTemplate: 'fields.link.detail', + detailTemplate: 'fields/link/detail', - editTemplate: 'fields.link.edit', + editTemplate: 'fields/link/edit', - searchTemplate: 'fields.link.search', + searchTemplate: 'fields/link/search', nameName: null, @@ -41,7 +41,7 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) { AUTOCOMPLETE_RESULT_MAX_COUNT: 7, - selectRecordsViewName: 'Modals.SelectRecords', + selectRecordsViewName: 'views/modals/select-records', autocompleteDisabled: false, @@ -134,14 +134,22 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) { getAutocompleteUrl: function () { var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT; var boolList = this.getSelectBoolFilterList(); + var where = []; if (boolList) { - boolList.forEach(function(item) { - url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item; - }, this); + where.push({ + type: 'bool', + value: boolList + }); } var primary = this.getSelectPrimaryFilterName(); if (primary) { - url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary; + where.push({ + type: 'primary', + value: primary + }); + } + if (where.length) { + url += '&' + $.param({'where': where}); } return url; },