diff --git a/application/Espo/Modules/Crm/Entities/Lead.php b/application/Espo/Modules/Crm/Entities/Lead.php index 8ed65c1a37..6634a7c947 100644 --- a/application/Espo/Modules/Crm/Entities/Lead.php +++ b/application/Espo/Modules/Crm/Entities/Lead.php @@ -25,12 +25,25 @@ * * 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. - ************************************************************************/ + ************************************************************************/ namespace Espo\Modules\Crm\Entities; class Lead extends \Espo\Core\Entities\Person { + protected function _getName() + { + if (!array_key_exists('name', $this->valuesContainer) || !$this->valuesContainer['name']) { + if ($this->get('accountName')) { + return $this->get('accountName'); + } else if ($this->get('emailAddress')) { + return $this->get('emailAddress'); + } else if ($this->get('phoneNumber')) { + return $this->get('phoneNumber'); + } + } + return $this->valuesContainer['name']; + } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json index 7b8614c83a..c57b1e14db 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json @@ -122,5 +122,27 @@ "style": "success" } ], - "boolFilterList": ["onlyMy"] + "boolFilterList": ["onlyMy"], + "dynamicLogic": { + "fields": { + "name": { + "required": { + "conditionGroup": [ + { + "type": "isEmpty", + "attribute": "accountName" + }, + { + "type": "isEmpty", + "attribute": "emailAddress" + }, + { + "type": "isEmpty", + "attribute": "phoneNumber" + } + ] + } + } + } + } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index 4ec060913b..115b734c92 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -15,7 +15,6 @@ "lastName": { "type": "varchar", "maxLength": 100, - "required": true, "default":"" }, "title": { diff --git a/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json b/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json index 15dfa5a2c3..9334299d35 100644 --- a/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json +++ b/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json @@ -98,6 +98,14 @@ "view": "views/admin/dynamic-logic/conditions/field-types/base", "typeList": ["equals", "notEquals", "isEmpty", "isNotEmpty"] }, + "email": { + "view": "views/admin/dynamic-logic/conditions/field-types/base", + "typeList": ["isEmpty", "isNotEmpty"] + }, + "phone": { + "view": "views/admin/dynamic-logic/conditions/field-types/base", + "typeList": ["isEmpty", "isNotEmpty"] + }, "text": { "view": "views/admin/dynamic-logic/conditions/field-types/base", "typeList": ["isEmpty", "isNotEmpty"] diff --git a/client/src/views/fields/base.js b/client/src/views/fields/base.js index b05ed6d7f9..93d19ca2ed 100644 --- a/client/src/views/fields/base.js +++ b/client/src/views/fields/base.js @@ -262,13 +262,13 @@ Espo.define('views/fields/base', 'view', function (Dep) { this.on('after:render', function () { if (this.mode === 'edit') { - if (this.isRequired()) { + if (this.hasRequiredMarker()) { this.showRequiredSign(); } else { this.hideRequiredSign(); } } else { - if (this.isRequired()) { + if (!this.hasRequiredMarker()) { this.hideRequiredSign(); } } @@ -580,6 +580,10 @@ Espo.define('views/fields/base', 'view', function (Dep) { } }, + hasRequiredMarker: function () { + return this.isRequired(); + }, + fetchToModel: function () { this.model.set(this.fetch(), {silent: true}); }, diff --git a/client/src/views/fields/person-name.js b/client/src/views/fields/person-name.js index 65f8da62d6..17e4f4cf4e 100644 --- a/client/src/views/fields/person-name.js +++ b/client/src/views/fields/person-name.js @@ -82,7 +82,7 @@ Espo.define('views/fields/person-name', 'views/fields/varchar', function (Dep) { }, validateRequired: function () { - var isRequired = this.model.getFieldParam(this.name, 'required'); + var isRequired = this.isRequired(); var validate = function (name) { if (this.model.isRequired(name)) { @@ -109,11 +109,11 @@ Espo.define('views/fields/person-name', 'views/fields/varchar', function (Dep) { return result; }, - isRequired: function () { + hasRequiredMarker: function () { + if (this.isRequired()) return true; return this.model.getFieldParam(this.salutationField, 'required') || this.model.getFieldParam(this.firstField, 'required') || - this.model.getFieldParam(this.lastField, 'required') || - this.model.getFieldParam(this.name, 'required'); + this.model.getFieldParam(this.lastField, 'required'); }, fetch: function (form) {