diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json index c62c25e126..0733bc4247 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json @@ -45,7 +45,25 @@ "options": ["Prospecting", "Qualification", "Needs Analysis", "Value Proposition", "Id. Decision Makers", "Perception Analysis", "Proposal/Price Quote", "Negotiation/Review", "Closed Won", "Closed Lost"], "view": "crm:views/opportunity/fields/stage", "default": "Prospecting", - "audited": true + "audited": true, + "probabilityMap": { + "Prospecting": 10, + "Qualification": 10, + "Needs Analysis": 20, + "Value Proposition": 50, + "Id. Decision Makers": 60, + "Perception Analysis": 70, + "Proposal/Price Quote": 75, + "Negotiation/Review": 90, + "Closed Won": 100, + "Closed Lost": 0 + }, + "fieldManagerAdditionalParamList": [ + { + "name": "probabilityMap", + "view": "crm:views/opportunity/admin/field-manager/fields/probability-map" + } + ] }, "probability": { "type": "int", @@ -189,18 +207,6 @@ "sortBy": "createdAt", "asc": false }, - "probabilityMap": { - "Prospecting": 10, - "Qualification": 10, - "Needs Analysis": 20, - "Value Proposition": 50, - "Id. Decision Makers": 60, - "Perception Analysis": 70, - "Proposal/Price Quote": 75, - "Negotiation/Review": 90, - "Closed Won": 100, - "Closed Lost": 0 - }, "indexes": { "stage": { "columns": ["stage", "deleted"] diff --git a/application/Espo/Resources/i18n/en_US/Admin.json b/application/Espo/Resources/i18n/en_US/Admin.json index 0d06fa8b4f..63e7c8e6e9 100644 --- a/application/Espo/Resources/i18n/en_US/Admin.json +++ b/application/Espo/Resources/i18n/en_US/Admin.json @@ -145,7 +145,8 @@ "dynamicLogicVisible": "Conditions making field visible", "dynamicLogicReadOnly": "Conditions making field read-only", "dynamicLogicRequired": "Conditions making field required", - "dynamicLogicOptions": "Conditional options" + "dynamicLogicOptions": "Conditional options", + "probabilityMap": "Stage Probabilities (%)" }, "messages": { "upgradeVersion": "Your EspoCRM will be upgraded to version {version}. This can take some time.", diff --git a/client/modules/crm/res/templates/opportunity/admin/field-manager/fields/probability-map/edit.tpl b/client/modules/crm/res/templates/opportunity/admin/field-manager/fields/probability-map/edit.tpl new file mode 100644 index 0000000000..e791babc53 --- /dev/null +++ b/client/modules/crm/res/templates/opportunity/admin/field-manager/fields/probability-map/edit.tpl @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/client/modules/crm/src/views/opportunity/admin/field-manager/fields/probability-map.js b/client/modules/crm/src/views/opportunity/admin/field-manager/fields/probability-map.js new file mode 100644 index 0000000000..dfbfdb3980 --- /dev/null +++ b/client/modules/crm/src/views/opportunity/admin/field-manager/fields/probability-map.js @@ -0,0 +1,72 @@ +/************************************************************************ + * 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('crm:views/opportunity/admin/field-manager/fields/probability-map', 'views/fields/base', function (Dep) { + + return Dep.extend({ + + editTemplate: 'crm:opportunity/admin/field-manager/fields/probability-map/edit', + + setup: function () { + Dep.prototype.setup.call(this); + + this.listenTo(this.model, 'change:options', function () { + this.reRender(); + }, this); + }, + + data: function () { + var data = {}; + var values = this.model.get('probabilityMap') || {}; + data.stageList = this.model.get('options') || []; + data.values = values; + return data; + }, + + fetch: function () { + var data = { + probabilityMap: {} + }; + + (this.model.get('options') || []).forEach(function (item) { + data.probabilityMap[item] = parseInt(this.$el.find('input[name="'+item+'"]').val()); + + }, this); + + return data; + }, + + afterRender: function () { + this.$el.find('input').on('change', function () { + this.trigger('change') + }.bind(this)); + } + + }); + +}); diff --git a/client/modules/crm/src/views/opportunity/fields/stage.js b/client/modules/crm/src/views/opportunity/fields/stage.js index a9dc9c8046..a7d0cb555b 100644 --- a/client/modules/crm/src/views/opportunity/fields/stage.js +++ b/client/modules/crm/src/views/opportunity/fields/stage.js @@ -50,7 +50,7 @@ Espo.define('crm:views/opportunity/fields/stage', 'views/fields/enum', function setup: function () { Dep.prototype.setup.call(this); - this.probabilityMap = this.getMetadata().get('entityDefs.Opportunity.probabilityMap') || {}; + this.probabilityMap = this.getMetadata().get('entityDefs.Opportunity.fields.stage.probabilityMap') || {}; if (this.mode != 'list') { if (!this.model.has('probability') && this.model.has('stage')) { diff --git a/client/src/views/admin/field-manager/edit.js b/client/src/views/admin/field-manager/edit.js index eeefde889a..d58905712c 100644 --- a/client/src/views/admin/field-manager/edit.js +++ b/client/src/views/admin/field-manager/edit.js @@ -112,6 +112,13 @@ Espo.define('views/admin/field-manager/edit', ['view', 'model'], function (Dep, ]).then(function () { this.paramList = []; var paramList = this.getFieldManager().getParams(this.type) || []; + + if (!this.isNew) { + (this.getMetadata().get(['entityDefs', this.scope, 'fields', this.field, 'fieldManagerAdditionalParamList']) || []).forEach(function (item) { + paramList.push(item); + }, this); + } + paramList.forEach(function (o) { var item = o.name; var disableParamName = 'customization' + Espo.Utils.upperCaseFirst(item) + 'Disabled';