field manager: opporunity probabilities

This commit is contained in:
yuri
2016-12-27 12:42:45 +02:00
parent ab89b3c91b
commit f0dbe8b78b
6 changed files with 112 additions and 15 deletions

View File

@@ -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"]

View File

@@ -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 <strong>{version}</strong>. This can take some time.",

View File

@@ -0,0 +1,11 @@
<div class="list-group link-container">
{{#each stageList}}
<div class="list-group-item form-inline">
<div style="display: inline-block; width: 100%;">
<input class="role form-control input-sm pull-right" name="{{./this}}" value="{{prop ../values this}}">
<div>{{./this}}</div>
</div>
<br class="clear: both;">
</div>
{{/each}}
</div>

View File

@@ -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));
}
});
});

View File

@@ -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')) {

View File

@@ -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';