diff --git a/client/modules/crm/src/views/campaign/fields/int-with-percentage.js b/client/modules/crm/src/views/campaign/fields/int-with-percentage.js index 1cdea1990f..ca593aaca0 100644 --- a/client/modules/crm/src/views/campaign/fields/int-with-percentage.js +++ b/client/modules/crm/src/views/campaign/fields/int-with-percentage.js @@ -26,20 +26,40 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('crm:views/campaign/fields/int-with-percentage', ['views/fields/int'], function (Dep) { +import IntFieldView from 'views/fields/int'; - return Dep.extend({ +// noinspection JSUnusedGlobalSymbols +export default class extends IntFieldView { - getValueForDisplay: function () { - var percentageFieldName = this.name.substr(0, this.name.length - 5) + 'Percentage'; - var value = this.model.get(this.name) ; - var percentageValue = this.model.get(percentageFieldName); + setup() { + this.percentageField = this.name.substr(0, this.name.length - 5) + 'Percentage'; - if (percentageValue !== null && typeof percentageValue !== 'undefined' && percentageValue) { - value += ' ' + '(' + this.model.get(percentageFieldName) + '%)'; - } + super.setup(); + } - return value; - }, - }); -}); + getAttributeList() { + const list = super.getAttributeList(); + + if (this.model.hasField(this.percentageField)) { + list.push(this.percentageField); + } + + return list; + } + + getValueForDisplay() { + const percentageFieldName = this.percentageField; + + let value = this.model.get(this.name); + const percentageValue = this.model.get(percentageFieldName); + + if ( + percentageValue != null && + percentageValue + ) { + value += ' ' + '(' + this.model.get(percentageFieldName) + '%)'; + } + + return value; + } +}