From dd5fabdfa4ef55ee4b22bed8e1586c2e24c692ea Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 5 Aug 2014 11:44:10 +0300 Subject: [PATCH] contacts select in meetings --- .../Resources/metadata/entityDefs/Call.json | 3 +- .../metadata/entityDefs/Meeting.json | 3 +- .../crm/src/views/meeting/fields/contacts.js | 40 +++++++++++++++++++ .../client/src/views/fields/link-parent.js | 6 ++- .../client/src/views/record/panels/side.js | 3 +- 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 frontend/client/modules/crm/src/views/meeting/fields/contacts.js diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json index 8e58a5235d..6106cc7bbc 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json @@ -52,7 +52,8 @@ }, "contacts": { "type": "linkMultiple", - "disabled": true + "disabled": true, + "view": "Crm:Meeting.Fields.Contacts" }, "leads": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json index 2d6b57a976..b0a6e1b7aa 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json @@ -47,7 +47,8 @@ }, "contacts": { "type": "linkMultiple", - "disabled": true + "disabled": true, + "view": "Crm:Meeting.Fields.Contacts" }, "leads": { "type": "linkMultiple", diff --git a/frontend/client/modules/crm/src/views/meeting/fields/contacts.js b/frontend/client/modules/crm/src/views/meeting/fields/contacts.js new file mode 100644 index 0000000000..7f903419b5 --- /dev/null +++ b/frontend/client/modules/crm/src/views/meeting/fields/contacts.js @@ -0,0 +1,40 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014 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/. + ************************************************************************/ + +Espo.define('Crm:Views.Meeting.Fields.Contacts', 'Views.Fields.LinkMultiple', function (Dep) { + + return Dep.extend({ + + getSelectFilters: function () { + if (this.model.get('parentType') == 'Account' && this.model.get('parentId')) { + return { + 'account': { + type: 'equals', + field: 'accountId', + value: this.model.get('parentId'), + valueName: this.model.get('parentName'), + } + }; + } + }, + }); + +}); diff --git a/frontend/client/src/views/fields/link-parent.js b/frontend/client/src/views/fields/link-parent.js index fbb9f669ab..55b0852ec9 100644 --- a/frontend/client/src/views/fields/link-parent.js +++ b/frontend/client/src/views/fields/link-parent.js @@ -74,7 +74,7 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) { if (this.mode != 'list') { this.addActionHandler('selectLink', function () { - Espo.Ui.notify('Loading...'); + this.notify('Loading...'); this.createView('dialog', 'Modals.SelectRecords', { scope: this.foreignScope, createButton: this.mode != 'search' @@ -84,12 +84,14 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) { dialog.once('select', function (model) { self.$elementName.val(model.get('name')); self.$elementId.val(model.get('id')); + self.trigger('change'); }); }); }); this.addActionHandler('clearLink', function () { this.$elementName.val(''); - this.$elementId.val(''); + this.$elementId.val(''); + this.trigger('change'); }); this.events['change select[name="' + this.typeName + '"]'] = function (e) { diff --git a/frontend/client/src/views/record/panels/side.js b/frontend/client/src/views/record/panels/side.js index 949ccbdf9a..94c0c5eaf9 100644 --- a/frontend/client/src/views/record/panels/side.js +++ b/frontend/client/src/views/record/panels/side.js @@ -62,7 +62,8 @@ Espo.define('Views.Record.Panels.Side', 'View', function (Dep) { createField: function (field, readOnly) { var type = this.model.getFieldType(field) || 'base'; - this.createView(field, 'Fields.' + Espo.Utils.upperCaseFirst(type), { + var viewName = this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type); + this.createView(field, viewName, { model: this.model, el: this.options.el + ' .field-' + field, defs: {