diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index 614296bb82..de9e598cd2 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -210,8 +210,17 @@ class Base if (!empty($item['value'])) { $methodName = 'apply' . ucfirst($type); - if (method_exists($this, $methodName)) {; - $this->$methodName($item['field'], $item['value'], $result); + if (method_exists($this, $methodName)) { + $attribute = null; + if (isset($item['field'])) { + $attribute = $item['field']; + } + if (isset($item['attribute'])) { + $attribute = $item['attribute']; + } + if ($attribute) { + $this->$methodName($attribute, $item['value'], $result); + } } } } @@ -689,13 +698,20 @@ class Base protected function checkWhere($where) { foreach ($where as $w) { + $attribute = null; if (isset($w['field'])) { + $attribute = $w['field']; + } + if (isset($w['attribute'])) { + $attribute = $w['attribute']; + } + if ($attribute) { if (isset($w['type']) && $w['type'] === 'linkedWith') { - if (in_array($w['field'], $this->getAcl()->getScopeForbiddenFieldList($this->getEntityType()))) { + if (in_array($attribute, $this->getAcl()->getScopeForbiddenFieldList($this->getEntityType()))) { throw new Forbidden(); } } else { - if (in_array($w['field'], $this->getAcl()->getScopeForbiddenAttributeList($this->getEntityType()))) { + if (in_array($attribute, $this->getAcl()->getScopeForbiddenAttributeList($this->getEntityType()))) { throw new Forbidden(); } } @@ -728,7 +744,15 @@ class Base $value = null; $timeZone = 'UTC'; - if (empty($item['field'])) { + $attribute = null; + if (isset($item['field'])) { + $attribute = $item['field']; + } + if (isset($item['attribute'])) { + $attribute = $item['attribute']; + } + + if (!$attribute) { return null; } if (empty($item['type'])) { @@ -741,14 +765,13 @@ class Base $timeZone = $item['timeZone']; } $type = $item['type']; - $field = $item['field']; if (empty($value) && in_array($type, array('on', 'before', 'after'))) { return null; } $where = array(); - $where['field'] = $field; + $where['attribute'] = $attribute; $dt = new \DateTime('now', new \DateTimeZone($timeZone)); @@ -875,8 +898,16 @@ class Base { $part = array(); - if (!empty($item['field']) && !empty($item['type'])) { - $methodName = 'getWherePart' . ucfirst($item['field']) . ucfirst($item['type']); + $attribute = null; + if (!empty($item['field'])) { // for backward compatibility + $attribute = $item['field']; + } + if (!empty($item['attribute'])) { + $attribute = $item['attribute']; + } + + if (!empty($attribute) && !empty($item['type'])) { + $methodName = 'getWherePart' . ucfirst($attribute) . ucfirst($item['type']); if (method_exists($this, $methodName)) { $value = null; if (!empty($item['value'])) { @@ -909,74 +940,74 @@ class Base } break; case 'like': - $part[$item['field'] . '*'] = $item['value']; + $part[$attribute . '*'] = $item['value']; break; case 'equals': case 'on': - $part[$item['field'] . '='] = $item['value']; + $part[$attribute . '='] = $item['value']; break; case 'startsWith': - $part[$item['field'] . '*'] = $item['value'] . '%'; + $part[$attribute . '*'] = $item['value'] . '%'; break; case 'endsWith': - $part[$item['field'] . '*'] = '%' . $item['value']; + $part[$attribute . '*'] = '%' . $item['value']; break; case 'contains': - $part[$item['field'] . '*'] = '%' . $item['value'] . '%'; + $part[$attribute . '*'] = '%' . $item['value'] . '%'; break; case 'notEquals': case 'notOn': - $part[$item['field'] . '!='] = $item['value']; + $part[$attribute . '!='] = $item['value']; break; case 'greaterThan': case 'after': - $part[$item['field'] . '>'] = $item['value']; + $part[$attribute . '>'] = $item['value']; break; case 'lessThan': case 'before': - $part[$item['field'] . '<'] = $item['value']; + $part[$attribute . '<'] = $item['value']; break; case 'greaterThanOrEquals': - $part[$item['field'] . '>='] = $item['value']; + $part[$attribute . '>='] = $item['value']; break; case 'lessThanOrEquals': - $part[$item['field'] . '<'] = $item['value']; + $part[$attribute . '<'] = $item['value']; break; case 'in': - $part[$item['field'] . '='] = $item['value']; + $part[$attribute . '='] = $item['value']; break; case 'notIn': - $part[$item['field'] . '!='] = $item['value']; + $part[$attribute . '!='] = $item['value']; break; case 'isNull': - $part[$item['field'] . '='] = null; + $part[$attribute . '='] = null; break; case 'isNotNull': case 'ever': - $part[$item['field'] . '!='] = null; + $part[$attribute . '!='] = null; break; case 'isTrue': - $part[$item['field'] . '='] = true; + $part[$attribute . '='] = true; break; case 'isFalse': - $part[$item['field'] . '='] = false; + $part[$attribute . '='] = false; break; case 'today': - $part[$item['field'] . '='] = date('Y-m-d'); + $part[$attribute . '='] = date('Y-m-d'); break; case 'past': - $part[$item['field'] . '<'] = date('Y-m-d'); + $part[$attribute . '<'] = date('Y-m-d'); break; case 'future': - $part[$item['field'] . '>='] = date('Y-m-d'); + $part[$attribute . '>='] = date('Y-m-d'); break; case 'lastSevenDays': $dt1 = new \DateTime(); $dt2 = clone $dt1; $dt2->modify('-7 days'); $part['AND'] = array( - $item['field'] . '>=' => $dt2->format('Y-m-d'), - $item['field'] . '<=' => $dt1->format('Y-m-d'), + $attribute . '>=' => $dt2->format('Y-m-d'), + $attribute . '<=' => $dt1->format('Y-m-d'), ); break; case 'lastXDays': @@ -986,8 +1017,8 @@ class Base $dt2->modify('-'.$number.' days'); $part['AND'] = array( - $item['field'] . '>=' => $dt2->format('Y-m-d'), - $item['field'] . '<=' => $dt1->format('Y-m-d'), + $attribute . '>=' => $dt2->format('Y-m-d'), + $attribute . '<=' => $dt1->format('Y-m-d'), ); break; case 'nextXDays': @@ -996,22 +1027,22 @@ class Base $number = strval(intval($item['value'])); $dt2->modify('+'.$number.' days'); $part['AND'] = array( - $item['field'] . '>=' => $dt1->format('Y-m-d'), - $item['field'] . '<=' => $dt2->format('Y-m-d'), + $attribute . '>=' => $dt1->format('Y-m-d'), + $attribute . '<=' => $dt2->format('Y-m-d'), ); break; case 'currentMonth': $dt = new \DateTime(); $part['AND'] = array( - $item['field'] . '>=' => $dt->modify('first day of this month')->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P1M'))->format('Y-m-d'), + $attribute . '>=' => $dt->modify('first day of this month')->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P1M'))->format('Y-m-d'), ); break; case 'lastMonth': $dt = new \DateTime(); $part['AND'] = array( - $item['field'] . '>=' => $dt->modify('first day of last month')->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P1M'))->format('Y-m-d'), + $attribute . '>=' => $dt->modify('first day of last month')->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P1M'))->format('Y-m-d'), ); break; case 'currentQuarter': @@ -1019,8 +1050,8 @@ class Base $quarter = ceil($dt->format('m') / 3); $dt->modify('first day of January this year'); $part['AND'] = array( - $item['field'] . '>=' => $dt->add(new \DateInterval('P'.(($quarter - 1) * 3).'M'))->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P3M'))->format('Y-m-d'), + $attribute . '>=' => $dt->add(new \DateInterval('P'.(($quarter - 1) * 3).'M'))->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P3M'))->format('Y-m-d'), ); break; case 'lastQuarter': @@ -1033,29 +1064,29 @@ class Base $dt->sub('P1Y'); } $part['AND'] = array( - $item['field'] . '>=' => $dt->add(new \DateInterval('P'.(($quarter - 1) * 3).'M'))->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P3M'))->format('Y-m-d'), + $attribute . '>=' => $dt->add(new \DateInterval('P'.(($quarter - 1) * 3).'M'))->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P3M'))->format('Y-m-d'), ); break; case 'currentYear': $dt = new \DateTime(); $part['AND'] = array( - $item['field'] . '>=' => $dt->modify('first day of January this year')->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P1Y'))->format('Y-m-d'), + $attribute . '>=' => $dt->modify('first day of January this year')->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P1Y'))->format('Y-m-d'), ); break; case 'lastYear': $dt = new \DateTime(); $part['AND'] = array( - $item['field'] . '>=' => $dt->modify('first day of January last year')->format('Y-m-d'), - $item['field'] . '<' => $dt->add(new \DateInterval('P1Y'))->format('Y-m-d'), + $attribute . '>=' => $dt->modify('first day of January last year')->format('Y-m-d'), + $attribute . '<' => $dt->add(new \DateInterval('P1Y'))->format('Y-m-d'), ); break; case 'between': if (is_array($item['value'])) { $part['AND'] = array( - $item['field'] . '>=' => $item['value'][0], - $item['field'] . '<=' => $item['value'][1], + $attribute . '>=' => $item['value'][0], + $attribute . '<=' => $item['value'][1], ); } break; diff --git a/application/Espo/Modules/Crm/SelectManagers/Meeting.php b/application/Espo/Modules/Crm/SelectManagers/Meeting.php index 97f4bc8c92..9722a50bbf 100644 --- a/application/Espo/Modules/Crm/SelectManagers/Meeting.php +++ b/application/Espo/Modules/Crm/SelectManagers/Meeting.php @@ -87,7 +87,7 @@ class Meeting extends \Espo\Core\SelectManagers\Base { $result['whereClause'][] = $this->convertDateTimeWhere(array( 'type' => 'today', - 'field' => 'dateStart', + 'attribute' => 'dateStart', 'timeZone' => $this->getUserTimeZone() )); } diff --git a/application/Espo/Modules/Crm/SelectManagers/Task.php b/application/Espo/Modules/Crm/SelectManagers/Task.php index e62d63398b..0b50bdc894 100644 --- a/application/Espo/Modules/Crm/SelectManagers/Task.php +++ b/application/Espo/Modules/Crm/SelectManagers/Task.php @@ -64,12 +64,12 @@ class Task extends \Espo\Core\SelectManagers\Base 'OR' => array( $this->convertDateTimeWhere(array( 'type' => 'past', - 'field' => 'dateStart', + 'attribute' => 'dateStart', 'timeZone' => $this->getUserTimeZone() )), $this->convertDateTimeWhere(array( 'type' => 'today', - 'field' => 'dateStart', + 'attribute' => 'dateStart', 'timeZone' => $this->getUserTimeZone() )) ) @@ -91,7 +91,7 @@ class Task extends \Espo\Core\SelectManagers\Base $result['whereClause'][] = [ $this->convertDateTimeWhere(array( 'type' => 'past', - 'field' => 'dateEnd', + 'attribute' => 'dateEnd', 'timeZone' => $this->getUserTimeZone() )), [ @@ -106,7 +106,7 @@ class Task extends \Espo\Core\SelectManagers\Base { $result['whereClause'][] = $this->convertDateTimeWhere(array( 'type' => 'today', - 'field' => 'dateEnd', + 'attribute' => 'dateEnd', 'timeZone' => $this->getUserTimeZone() )); } @@ -118,16 +118,22 @@ class Task extends \Espo\Core\SelectManagers\Base if (empty($result)) { return null; } - $field = $item['field']; + $attribute = null; + if (!empty($item['field'])) { // for backward compatibility + $attribute = $item['field']; + } + if (!empty($item['attribute'])) { + $attribute = $item['attribute']; + } - if ($field != 'dateStart' && $field != 'dateEnd') { + if ($attribute != 'dateStart' && $attribute != 'dateEnd') { return $result; } - $fieldDate = $field . 'Date'; + $attributeDate = $attribute . 'Date'; $dateItem = array( - 'field' => $fieldDate, + 'attribute' => $attributeDate, 'type' => $item['type'] ); if (!empty($item['value'])) { @@ -138,7 +144,7 @@ class Task extends \Espo\Core\SelectManagers\Base 'OR' => array( 'AND' => [ $result, - $fieldDate . '=' => null + $attributeDate . '=' => null ], $this->getWherePart($dateItem) ) diff --git a/client/res/templates/fields/date/search.tpl b/client/res/templates/fields/date/search.tpl index c177d5ba0e..d6a7681c08 100644 --- a/client/res/templates/fields/date/search.tpl +++ b/client/res/templates/fields/date/search.tpl @@ -1,6 +1,6 @@
diff --git a/client/res/templates/fields/int/search.tpl b/client/res/templates/fields/int/search.tpl index bf5e882c77..c4baa8e443 100644 --- a/client/res/templates/fields/int/search.tpl +++ b/client/res/templates/fields/int/search.tpl @@ -1,6 +1,6 @@ diff --git a/client/res/templates/fields/link-parent/search.tpl b/client/res/templates/fields/link-parent/search.tpl index baf1fc77a0..3e7580789f 100644 --- a/client/res/templates/fields/link-parent/search.tpl +++ b/client/res/templates/fields/link-parent/search.tpl @@ -1,5 +1,5 @@
- {{options searchData.typeOptions searchParams.typeFront field='searchRanges'}} + {{options searchTypeList searchType field='searchRanges'}}
@@ -23,5 +23,3 @@
- - diff --git a/client/res/templates/fields/user/search.tpl b/client/res/templates/fields/user/search.tpl index d372b13a71..645337cdbe 100644 --- a/client/res/templates/fields/user/search.tpl +++ b/client/res/templates/fields/user/search.tpl @@ -1,5 +1,5 @@
diff --git a/client/src/search-manager.js b/client/src/search-manager.js index 08037d8528..d22c9b61f2 100644 --- a/client/src/search-manager.js +++ b/client/src/search-manager.js @@ -122,7 +122,7 @@ Espo.define('search-manager', [], function () { }, getWherePart: function (name, defs) { - var field = name; + var attribute = name; if ('where' in defs) { return defs.where; @@ -140,13 +140,16 @@ Espo.define('search-manager', [], function () { value: a }; } - if ('field' in defs) { - field = defs.field; + if ('field' in defs) { // for backward compatibility + attribute = defs.field; + } + if ('attribute' in defs) { + attribute = defs.attribute; } if (defs.dateTime) { return { type: type, - field: field, + attribute: attribute, value: defs.value, dateTime: true, timeZone: this.dateTime.timeZone || 'UTC' @@ -155,8 +158,8 @@ Espo.define('search-manager', [], function () { value = defs.value; return { type: type, - field: field, - value: value, + attribute: attribute, + value: value }; } } diff --git a/client/src/views/fields/base.js b/client/src/views/fields/base.js index 57bd0e8518..0571b29c5a 100644 --- a/client/src/views/fields/base.js +++ b/client/src/views/fields/base.js @@ -159,6 +159,7 @@ Espo.define('views/fields/base', 'view', function (Dep) { data.searchData = this.searchData; data.searchValues = this.getSearchValues(); data.searchType = this.getSearchType(); + data.searchTypeList = this.getSearchTypeList(); } return data; }, @@ -300,12 +301,20 @@ Espo.define('views/fields/base', 'view', function (Dep) { } }, + getSearchParamsData: function () { + return this.searchParams.data || {}; + }, + getSearchValues: function () { - return (this.searchParams.data || {}).values || {}; + return this.getSearchParamsData().values || {}; }, getSearchType: function () { - return (this.searchParams.data || {}).type || this.searchParams.type; + return this.getSearchParamsData().type || this.searchParams.type; + }, + + getSearchTypeList: function () { + return this.searchTypeList; }, initInlineEdit: function () { diff --git a/client/src/views/fields/date.js b/client/src/views/fields/date.js index f1a31ea76d..1dd02ed79e 100644 --- a/client/src/views/fields/date.js +++ b/client/src/views/fields/date.js @@ -38,7 +38,7 @@ Espo.define('views/fields/date', 'views/fields/base', function (Dep) { validations: ['required', 'date', 'after', 'before'], - searchTypeOptions: ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'on', 'after', 'before', 'between'], + searchTypeList: ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'on', 'after', 'before', 'between'], setup: function () { Dep.prototype.setup.call(this); @@ -49,13 +49,11 @@ Espo.define('views/fields/date', 'views/fields/base', function (Dep) { if (this.mode === 'search') { this.searchData.dateValue = this.getDateTime().toDisplayDate(this.searchParams.dateValue); this.searchData.dateValueTo = this.getDateTime().toDisplayDate(this.searchParams.dateValueTo); - data.searchType = this.searchParams.typeFront || this.searchParams.type; } return data; }, setupSearch: function () { - this.searchData.typeOptions = this.searchTypeOptions; this.events = _.extend({ 'change select.search-type': function (e) { var type = $(e.currentTarget).val(); @@ -250,8 +248,10 @@ Espo.define('views/fields/date', 'views/fields/base', function (Dep) { }; } else if (type === 'isEmpty') { data = { - typeFront: type, - type: 'isNull' + type: 'isNull', + data: { + type: type + } } } else { data = { @@ -261,6 +261,10 @@ Espo.define('views/fields/date', 'views/fields/base', function (Dep) { return data; }, + getSearchType: function () { + return this.getSearchParamsData().type || this.searchParams.typeFront || this.searchParams.type; + }, + validateRequired: function () { if (this.isRequired()) { if (this.model.get(this.name) === null) { diff --git a/client/src/views/fields/datetime.js b/client/src/views/fields/datetime.js index a0495166ca..60aa771f8b 100644 --- a/client/src/views/fields/datetime.js +++ b/client/src/views/fields/datetime.js @@ -36,7 +36,7 @@ Espo.define('views/fields/datetime', 'views/fields/date', function (Dep) { validations: ['required', 'datetime', 'after', 'before'], - searchTypeOptions: ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'on', 'after', 'before', 'between'], + searchTypeList: ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'on', 'after', 'before', 'between'], timeFormatMap: { 'HH:mm': 'H:i', diff --git a/client/src/views/fields/int.js b/client/src/views/fields/int.js index 9b36b59e85..f4703c8e5f 100644 --- a/client/src/views/fields/int.js +++ b/client/src/views/fields/int.js @@ -42,6 +42,8 @@ Espo.define('views/fields/int', 'views/fields/base', function (Dep) { thousandSeparator: ',', + searchTypeList: ['isNotEmpty', 'isEmpty', 'equals', 'notEquals', 'greaterThan', 'lessThan', 'greaterThanOrEquals', 'lessThanOrEquals', 'between'], + setup: function () { Dep.prototype.setup.call(this); this.defineMaxLength(); @@ -74,9 +76,6 @@ Espo.define('views/fields/int', 'views/fields/base', function (Dep) { if (this.model.get(this.name) !== null && typeof this.model.get(this.name) !== 'undefined') { data.isNotEmpty = true; } - if (this.mode === 'search') { - data.searchType = this.searchParams.typeFront || this.searchParams.type; - } return data; }, @@ -98,7 +97,6 @@ Espo.define('views/fields/int', 'views/fields/base', function (Dep) { }, setupSearch: function () { - this.searchData.typeOptions = [, 'isNotEmpty', 'isEmpty', 'equals', 'notEquals', 'greaterThan', 'lessThan', 'greaterThanOrEquals', 'lessThanOrEquals', 'between']; this.events = _.extend({ 'change select.search-type': function (e) { this.handleSearchType($(e.currentTarget).val()); @@ -247,6 +245,10 @@ Espo.define('views/fields/int', 'views/fields/base', function (Dep) { return data; }, + getSearchType: function () { + return this.searchParams.typeFront || this.searchParams.type; + } + }); }); diff --git a/client/src/views/fields/link-parent.js b/client/src/views/fields/link-parent.js index 61c28b890d..2abb72cde3 100644 --- a/client/src/views/fields/link-parent.js +++ b/client/src/views/fields/link-parent.js @@ -54,6 +54,8 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { createDisabled: false, + searchTypeList: ['is', 'isEmpty', 'isNotEmpty'], + data: function () { return _.extend({ idName: this.idName, @@ -142,7 +144,6 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { }, setupSearch: function () { - this.searchData.typeOptions = ['is', 'isEmpty', 'isNotEmpty']; this.events = _.extend({ 'change select.search-type': function (e) { @@ -301,15 +302,19 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { if (type == 'isEmpty') { var data = { type: 'isNull', - typeFront: type, - field: this.idName + field: this.idName, + data: { + type: type + } }; return data; } else if (type == 'isNotEmpty') { var data = { type: 'isNotNull', - typeFront: type, - field: this.idName + field: this.idName, + data: { + type: type + } }; return data; } @@ -326,7 +331,6 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { var data; if (entityId) { data = { - frontType: 'is', type: 'and', field: this.idName, @@ -345,10 +349,12 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { valueId: entityId, valueName: entityName, valueType: entityType, + data: { + type: 'is' + } }; } else { data = { - frontType: 'is', type: 'and', field: this.idName, value: [ @@ -362,10 +368,17 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) { value: entityType, } ], - valueType: entityType + valueType: entityType, + data: { + type: 'is' + } }; } return data; + }, + + getSearchType: function () { + return this.getSearchParamsData().type || this.searchParams.typeFront; } }); }); diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.js index cfe5507641..cdb1392ee6 100644 --- a/client/src/views/fields/link.js +++ b/client/src/views/fields/link.js @@ -54,6 +54,8 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) { createDisabled: false, + searchTypeList: ['is', 'isEmpty', 'isNotEmpty', 'isOneOf'], + data: function () { return _.extend({ idName: this.idName, @@ -161,7 +163,6 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) { }, setupSearch: function () { - this.searchData.typeOptions = ['is', 'isEmpty', 'isNotEmpty', 'isOneOf']; this.searchData.oneOfIdList = this.searchParams.oneOfIdList || []; this.searchData.oneOfNameHash = this.searchParams.oneOfNameHash || {}; @@ -395,25 +396,31 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) { if (type == 'isEmpty') { var data = { type: 'isNull', - typeFront: type, - field: this.idName + field: this.idName, + data: { + type: type + } }; return data; } else if (type == 'isNotEmpty') { var data = { type: 'isNotNull', - typeFront: type, - field: this.idName + field: this.idName, + data: { + type: type + } }; return data; } else if (type == 'isOneOf') { var data = { type: 'in', - typeFront: type, field: this.idName, value: this.searchData.oneOfIdList, oneOfIdList: this.searchData.oneOfIdList, - oneOfNameHash: this.searchData.oneOfNameHash + oneOfNameHash: this.searchData.oneOfNameHash, + data: { + type: type + } }; return data; @@ -423,14 +430,21 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) { } var data = { type: 'equals', - typeFront: type, field: this.idName, value: value, valueName: this.$el.find('[name="' + this.nameName + '"]').val(), + data: { + type: type + } }; return data; } + }, + + getSearchType: function () { + return this.getSearchParamsData().type || this.searchParams.typeFront || this.searchParams.frontType; } + }); }); diff --git a/client/src/views/fields/user.js b/client/src/views/fields/user.js index 1c86c2ef86..fe84e397e5 100644 --- a/client/src/views/fields/user.js +++ b/client/src/views/fields/user.js @@ -35,7 +35,9 @@ Espo.define('views/fields/user', 'views/fields/link', function (Dep) { setupSearch: function () { Dep.prototype.setupSearch.call(this); - this.searchData.typeOptions.push('isFromTeams'); + this.searchTypeList = Espo.Utils.clone(this.searchTypeList); + this.searchTypeList.push('isFromTeams'); + this.searchData.teamIdList = this.searchParams.teamIdList || []; this.searchData.teamNameHash = this.searchParams.teamNameHash || {}; @@ -177,11 +179,13 @@ Espo.define('views/fields/user', 'views/fields/link', function (Dep) { if (type == 'isFromTeams') { var data = { type: 'isUserFromTeams', - typeFront: type, field: this.name, value: this.searchData.teamIdList, teamIdList: this.searchData.teamIdList, - teamNameHash: this.searchData.teamNameHash + teamNameHash: this.searchData.teamNameHash, + data: { + type: type + } }; return data; }