mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 23:16:03 +00:00
search by hasOne link
This commit is contained in:
@@ -257,18 +257,21 @@ class Base
|
||||
|
||||
$defs = $relDefs[$link];
|
||||
if ($relationType == 'manyMany') {
|
||||
$this->addJoin($link, $result);
|
||||
$this->addJoin([$link, $link . 'Filter'], $result);
|
||||
$midKeys = $seed->getRelationParam($link, 'midKeys');
|
||||
|
||||
if (!empty($midKeys)) {
|
||||
$key = $midKeys[1];
|
||||
$part[$link . 'Middle.' . $key] = $idsValue;
|
||||
$part[$link . 'Filter' . 'Middle.' . $key] = $idsValue;
|
||||
}
|
||||
} else if ($relationType== 'belongsTo') {
|
||||
} else if ($relationType == 'belongsTo') {
|
||||
$key = $seed->getRelationParam($link, 'key');
|
||||
if (!empty($key)) {
|
||||
$part[$key] = $idsValue;
|
||||
}
|
||||
} else if ($relationType == 'hasOne') {
|
||||
$this->addJoin([$link, $link . 'Filter'], $result);
|
||||
$part[$link . 'Filter' . '.id'] = $idsValue;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,8 @@
|
||||
"type": "link",
|
||||
"layoutMassUpdateDisabled": true,
|
||||
"layoutListDisabled": true,
|
||||
"readOnly": true
|
||||
"readOnly": true,
|
||||
"view": "views/fields/link-one"
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
|
||||
@@ -182,13 +182,16 @@
|
||||
"type": "link",
|
||||
"layoutMassUpdateDisabled": true,
|
||||
"layoutListDisabled": true,
|
||||
"readOnly": true
|
||||
"readOnly": true,
|
||||
"notStorable": true,
|
||||
"view": "views/fields/link-one"
|
||||
},
|
||||
"originalLead": {
|
||||
"type": "link",
|
||||
"layoutMassUpdateDisabled": true,
|
||||
"layoutListDisabled": true,
|
||||
"readOnly": true
|
||||
"readOnly": true,
|
||||
"view": "views/fields/link-one"
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
"type": "link",
|
||||
"layoutMassUpdateDisabled": true,
|
||||
"layoutListDisabled": true,
|
||||
"readOnly": true
|
||||
"readOnly": true,
|
||||
"view": "views/fields/link-one"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
|
||||
73
client/src/views/fields/link-one.js
Normal file
73
client/src/views/fields/link-one.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/fields/link-one', 'views/fields/link', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
readOnly: true,
|
||||
|
||||
searchTypeList: ['is', 'isOneOf'],
|
||||
|
||||
fetchSearch: function () {
|
||||
var type = this.$el.find('select.search-type').val();
|
||||
var value = this.$el.find('[name="' + this.idName + '"]').val();
|
||||
|
||||
if (type == 'isOneOf') {
|
||||
var data = {
|
||||
type: 'linkedWith',
|
||||
field: this.name,
|
||||
value: this.searchData.oneOfIdList,
|
||||
oneOfIdList: this.searchData.oneOfIdList,
|
||||
oneOfNameHash: this.searchData.oneOfNameHash,
|
||||
data: {
|
||||
type: type
|
||||
}
|
||||
};
|
||||
return data;
|
||||
|
||||
} else {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
var data = {
|
||||
type: 'linkedWith',
|
||||
field: this.name,
|
||||
value: value,
|
||||
valueName: this.$el.find('[name="' + this.nameName + '"]').val(),
|
||||
data: {
|
||||
type: type
|
||||
}
|
||||
};
|
||||
return data;
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user