all files / common/popups/ formatting-dialog.js

93.73% Statements 239/255
62.64% Branches 57/91
91.3% Functions 21/23
93.73% Lines 239/255
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458   10× 10× 10× 10× 10× 10×   1549×                                                                         23×           23×   31×   16×                                                                                           16×   16× 16×                                                                                             25×           10× 10× 10×     10× 10× 10× 10×                                   10× 10× 43×   10× 10× 10×                           15×                                                 24× 24× 24×         24× 24× 75× 26× 26×     24×   24× 24×   10×     10×   27×   20×   17×       17×        
define(["require", "exports", "@syncfusion/ej2-popups", "@syncfusion/ej2-base", "../../common/base/css-constant", "../../common/base/constant", "@syncfusion/ej2-dropdowns", "../../base/util"], function (require, exports, ej2_popups_1, ej2_base_1, cls, events, ej2_dropdowns_1, util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var NumberFormatting = (function () {
        function NumberFormatting(parent) {
            this.parent = parent;
            this.parent.numberFormattingModule = this;
            this.removeEventListener();
            this.addEventListener();
            this.newFormat = [];
            this.lastFormattedValue = [];
        }
        NumberFormatting.prototype.getModuleName = function () {
            return 'numberFormatting';
        };
        NumberFormatting.prototype.showNumberFormattingDialog = function () {
            var _this = this;
            var valueDialog = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatDialog',
                className: cls.FORMATTING_DIALOG
            });
            this.parent.element.appendChild(valueDialog);
            this.dialog = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: true,
                header: this.parent.localeObj.getConstant('numberFormat'),
                content: this.getDialogContent(),
                isModal: true,
                visible: true,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                locale: this.parent.locale,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                width: '320px',
                height: 'auto',
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        click: this.updateFormatting.bind(this),
                        isFlat: false,
                        buttonModel: { cssClass: cls.OK_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), content: this.parent.localeObj.getConstant('apply'), isPrimary: true }
                    },
                    {
                        click: function () {
                            _this.dialog.hide();
                        },
                        isFlat: false,
                        buttonModel: { cssClass: cls.CANCEL_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), content: this.parent.localeObj.getConstant('cancel') }
                    }
                ],
                closeOnEscape: true,
                cssClass: this.parent.cssClass,
                target: this.parent.element,
                close: this.removeDialog.bind(this)
            });
            this.dialog.isStringTemplate = true;
            this.dialog.appendTo(valueDialog);
            this.dialog.element.querySelector('.' + cls.DIALOG_HEADER).innerText = this.parent.localeObj.getConstant('numberFormat');
            var formatObject;
            this.newFormat = [{ name: this.parent.localeObj.getConstant('AllValues'), format: 'N0', useGrouping: true, type: undefined }];
            var format = [];
            for (var i = 0; i < this.parent.dataSourceSettings.formatSettings.length; i++) {
                formatObject = {
                    name: this.parent.dataSourceSettings.formatSettings[i].name,
                    format: this.parent.dataSourceSettings.formatSettings[i].format,
                    useGrouping: this.parent.dataSourceSettings.formatSettings[i].useGrouping,
                    type: this.parent.dataSourceSettings.formatSettings[i].type
                };
                this.newFormat.push(formatObject);
            }
            for (var i = 0; i < this.newFormat.length; i++) {
                format.push(this.newFormat[i].name);
            }
            for (var j = 0; j < this.parent.dataSourceSettings.values.length; j++) {
                if (format.indexOf(this.parent.dataSourceSettings.values[j].name) === -1) {
                    formatObject = {
                        name: this.parent.dataSourceSettings.values[j].name, format: 'N0',
                        useGrouping: true
                    };
                    this.newFormat.push(formatObject);
                }
            }
            this.renderControls();
        };
        NumberFormatting.prototype.getDialogContent = function () {
            var outerElement = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatDialogOuter',
                className: cls.FORMATTING_DIALOG_OUTER
            });
            var table = ej2_base_1.createElement('table', {
                id: this.parent.element.id + '_FormatTable',
                className: cls.FORMATTING_TABLE,
                attrs: { 'role': 'tableItems' }
            });
            var tRow = ej2_base_1.createElement('tr');
            var tValue = ej2_base_1.createElement('td');
            var valueLable = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatValueLable',
                className: cls.FORMATTING_VALUE_LABLE
            });
            valueLable.innerText = this.parent.localeObj.getConstant('values');
            var valueDrop = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatValueDrop'
            });
            tValue.appendChild(valueLable);
            tValue.appendChild(valueDrop);
            tRow.appendChild(tValue);
            table.appendChild(tRow);
            tRow = ej2_base_1.createElement('tr');
            tValue = ej2_base_1.createElement('td');
            var formatLable = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatLable',
                className: cls.FORMATTING_FORMAT_LABLE
            });
            formatLable.innerText = this.parent.localeObj.getConstant('formatType');
            var formatDrop = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_FormatDrop'
            });
            tValue.appendChild(formatLable);
            tValue.appendChild(formatDrop);
            tRow.appendChild(tValue);
            table.appendChild(tRow);
            tRow = ej2_base_1.createElement('tr');
            tValue = ej2_base_1.createElement('td');
            var groupingLable = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_GroupingLable',
                className: cls.FORMATTING_GROUPING_LABLE
            });
            groupingLable.innerText = this.parent.localeObj.getConstant('grouping');
            var groupingDrop = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_GroupingDrop'
            });
            tValue.appendChild(groupingLable);
            tValue.appendChild(groupingDrop);
            tRow.appendChild(tValue);
            table.appendChild(tRow);
            tRow = ej2_base_1.createElement('tr');
            tValue = ej2_base_1.createElement('td');
            var decimalLable = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_DecimalLable',
                className: cls.FORMATTING_DECIMAL_LABLE
            });
            decimalLable.innerText = this.parent.localeObj.getConstant('decimalPlaces');
            var decimalDrop = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_DecimalDrop'
            });
            tValue.appendChild(decimalLable);
            tValue.appendChild(decimalDrop);
            tRow.appendChild(tValue);
            table.appendChild(tRow);
            tRow = ej2_base_1.createElement('tr');
            tValue = ej2_base_1.createElement('td');
            this.customLable = ej2_base_1.createElement('div', {
                id: this.parent.element.id + '_CustomLable',
                className: cls.FORMATTING_CUSTOM_LABLE
            });
            this.customLable.innerText = this.parent.localeObj.getConstant('customFormatString');
            this.customText = ej2_base_1.createElement('input', {
                id: this.parent.element.id + '_CustomText',
                attrs: {
                    'type': 'text', 'tabindex': '0'
                },
                className: cls.INPUT + ' ' + cls.FORMATTING_CUSTOM_TEXT
            });
            tValue.appendChild(this.customLable);
            tValue.appendChild(this.customText);
            tRow.appendChild(tValue);
            table.appendChild(tRow);
            tRow = ej2_base_1.createElement('tr');
            table.appendChild(tRow);
            outerElement.appendChild(table);
            return outerElement;
        };
        NumberFormatting.prototype.renderControls = function () {
            var valuesDropDown;
            var formatDropDown;
            var groupingDropDown;
            Eif (ej2_base_1.select('#' + this.parent.element.id + '_FormatValueDrop', this.dialog.element)) {
                var valueFields = [];
                valueFields.push({
                    index: 0, name: this.parent.localeObj.getConstant('AllValues'), field: this.parent.localeObj.getConstant('AllValues')
                });
                for (var i = 0; i < this.parent.dataSourceSettings.values.length; i++) {
                    var caption = this.parent.dataSourceSettings.values[i].caption ||
                        this.parent.dataSourceSettings.values[i].name;
                    caption = this.parent.enableHtmlSanitizer ? ej2_base_1.SanitizeHtmlHelper.sanitize(caption) : caption;
                    valueFields.push({
                        index: i + 1, name: caption,
                        field: this.parent.dataSourceSettings.values[i].name
                    });
                }
                valuesDropDown = new ej2_dropdowns_1.DropDownList({
                    dataSource: valueFields, fields: { text: 'name', value: 'field' }, enableRtl: this.parent.enableRtl, locale: this.parent.locale,
                    index: 0, cssClass: cls.FORMATTING_VALUE_DROP + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), change: this.valueChange.bind(this), width: '100%',
                    open: this.customUpdate.bind(this)
                });
                valuesDropDown.isStringTemplate = true;
                valuesDropDown.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_FormatValueDrop', this.dialog.element));
            }
            Eif (ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.dialog.element)) {
                var fields = [
                    { index: 0, name: this.parent.localeObj.getConstant('number') },
                    { index: 1, name: this.parent.localeObj.getConstant('currency') },
                    { index: 2, name: this.parent.localeObj.getConstant('percentage') },
                    { index: 3, name: this.parent.localeObj.getConstant('Custom') }
                ];
                formatDropDown = new ej2_dropdowns_1.DropDownList({
                    dataSource: fields, fields: { text: 'name', value: 'name' },
                    index: 0, change: this.dropDownChange.bind(this), enableRtl: this.parent.enableRtl, locale: this.parent.locale,
                    cssClass: cls.FORMATTING_FORMAT_DROP + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), width: '100%'
                });
                formatDropDown.isStringTemplate = true;
                formatDropDown.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.dialog.element));
            }
            Eif (ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.dialog.element)) {
                var fields = [
                    { index: 0, name: this.parent.localeObj.getConstant('true') },
                    { index: 1, name: this.parent.localeObj.getConstant('false') }
                ];
                groupingDropDown = new ej2_dropdowns_1.DropDownList({
                    dataSource: fields, fields: { text: 'name', value: 'name' }, enableRtl: this.parent.enableRtl, locale: this.parent.locale,
                    index: 0, cssClass: cls.FORMATTING_GROUPING_DROP + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), width: '100%', change: this.groupingChange.bind(this)
                });
                groupingDropDown.isStringTemplate = true;
                groupingDropDown.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.dialog.element));
            }
            Eif (ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.dialog.element)) {
                var fields = [
                    { index: 0, name: 0 },
                    { index: 1, name: 1 },
                    { index: 2, name: 2 },
                    { index: 3, name: 3 },
                    { index: 4, name: 4 },
                    { index: 5, name: 5 },
                    { index: 6, name: 6 },
                    { index: 7, name: 7 },
                    { index: 8, name: 8 },
                    { index: 9, name: 9 },
                    { index: 10, name: 10 }
                ];
                var decimalDropDown = new ej2_dropdowns_1.DropDownList({
                    dataSource: fields, fields: { text: 'name', value: 'name' }, enableRtl: this.parent.enableRtl, locale: this.parent.locale,
                    index: 0, cssClass: cls.FORMATTING_DECIMAL_DROP + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), popupHeight: 150, width: '100%', change: this.decimalChange.bind(this)
                });
                decimalDropDown.isStringTemplate = true;
                decimalDropDown.appendTo(ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.dialog.element));
            }
            Eif (formatDropDown.value !== this.parent.localeObj.getConstant('Custom')) {
                this.customText.disabled = true;
            }
            if (this.lastFormattedValue.length !== 0) {
                valuesDropDown.value = this.lastFormattedValue[0].name;
                var fString = this.lastFormattedValue[0].format;
                var first = fString === '' ? '' : fString.split('')[0].toLowerCase();
                var group = this.lastFormattedValue[0].useGrouping ? this.parent.localeObj.getConstant('true') :
                    this.parent.localeObj.getConstant('false');
                this.updateFormattingDialog(fString, first, group);
            }
        };
        NumberFormatting.prototype.valueChange = function (args) {
            var format = this.newFormat;
            var isExist = false;
            for (var i = 0; i < format.length; i++) {
                if (format[i].name === args.value) {
                    var fString = format[i].format;
                    var first = fString === '' ? '' : fString.split('')[0].toLowerCase();
                    var group = format[i].useGrouping ? this.parent.localeObj.getConstant('true') :
                        this.parent.localeObj.getConstant('false');
                    this.updateFormattingDialog(fString, first, group);
                    isExist = true;
                    break;
                }
            }
            if (!isExist) {
                var formatDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
                formatDropDown.value = this.parent.localeObj.getConstant('number');
                var decimalDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
                decimalDropDown.value = 0;
                var groupingDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
                groupingDropDown.value = this.parent.localeObj.getConstant('true');
            }
        };
        NumberFormatting.prototype.updateFormattingDialog = function (fString, first, group) {
            var formatDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            Eif (fString.length === 2 && ['n', 'p', 'c'].indexOf(first) > -1) {
                formatDropDown.value = first === 'n' ? this.parent.localeObj.getConstant('number') : first === 'p' ?
                    this.parent.localeObj.getConstant('percentage') : first === 'c' ? this.parent.localeObj.getConstant('currency') :
                    this.parent.localeObj.getConstant('number');
                var decimalDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
                decimalDropDown.value = Number(fString.split('')[1]);
                var groupingDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
                groupingDropDown.value = group;
            }
            else {
                formatDropDown.value = this.parent.localeObj.getConstant('Custom');
                this.customText.value = fString;
            }
        };
        NumberFormatting.prototype.customUpdate = function () {
            var formatDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            if (formatDropDown.value === this.parent.localeObj.getConstant('Custom')) {
                var index = this.getIndexValue();
                this.newFormat[index].format = this.customText.value;
            }
        };
        NumberFormatting.prototype.dropDownChange = function (args) {
            var index = this.getIndexValue();
            var groupingDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            var decimalDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            if (args.value === this.parent.localeObj.getConstant('Custom')) {
                this.customText.disabled = false;
                groupingDropDown.enabled = false;
                decimalDropDown.enabled = false;
                this.newFormat[index].format = this.customText.value;
            }
            else {
                var text = this.formattedText();
                this.newFormat[index].format = text;
                this.customText.disabled = true;
                groupingDropDown.enabled = true;
                decimalDropDown.enabled = true;
                this.customText.value = '';
            }
        };
        NumberFormatting.prototype.groupingChange = function () {
            var index = this.getIndexValue();
            var groupingDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            this.newFormat[index].useGrouping = groupingDropDown.value === this.parent.localeObj.getConstant('true') ? true : false;
        };
        NumberFormatting.prototype.getIndexValue = function () {
            var format = [];
            for (var i = 0; i < this.newFormat.length; i++) {
                format.push(this.newFormat[i].name);
            }
            var valuesDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatValueDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            var index = format.indexOf(valuesDropDown.value.toString());
            return index;
        };
        NumberFormatting.prototype.decimalChange = function () {
            var index = this.getIndexValue();
            var text = this.formattedText();
            this.newFormat[index].format = text;
        };
        NumberFormatting.prototype.formattedText = function () {
            var text;
            var formatDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            var decimalDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_DecimalDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            Eif (formatDropDown.value === this.parent.localeObj.getConstant('number') ||
                formatDropDown.value === this.parent.localeObj.getConstant('percentage') ||
                formatDropDown.value === this.parent.localeObj.getConstant('currency')) {
                text = formatDropDown.value === this.parent.localeObj.getConstant('number') ? 'N' :
                    formatDropDown.value === this.parent.localeObj.getConstant('currency') ? 'C' : 'P';
                return text += decimalDropDown.value;
            }
            else {
                return text = this.customText.value;
            }
        };
        NumberFormatting.prototype.removeDialog = function () {
            Eif (this.dialog && !this.dialog.isDestroyed) {
                this.dialog.destroy();
            }
            Eif (document.getElementById(this.parent.element.id + '_FormatDialog')) {
                ej2_base_1.remove(document.getElementById(this.parent.element.id + '_FormatDialog'));
            }
        };
        NumberFormatting.prototype.updateFormatting = function () {
            var _this = this;
            var text = this.formattedText();
            var index = this.getIndexValue();
            this.newFormat.splice(index, 1);
            var format = ej2_base_1.extend([], this.newFormat, true);
            var formatSettings = this.parent.dataSourceSettings.formatSettings;
            for (var i = 0; i < formatSettings.length; i++) {
                this.insertFormat(formatSettings[i].name, formatSettings[i].format, formatSettings[i].type);
            }
            var valuesDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_FormatValueDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            if (valuesDropDown.value === this.parent.localeObj.getConstant('AllValues')) {
                for (var i = 0; i < this.parent.dataSourceSettings.values.length; i++) {
                    this.insertFormat(this.parent.dataSourceSettings.values[i].name, text);
                }
            }
            else {
                this.insertFormat(valuesDropDown.value.toString(), text);
            }
            var eventArgs = {
                formatSettings: util_1.PivotUtil.cloneFormatSettings(this.newFormat),
                formatName: valuesDropDown.value.toString(),
                cancel: false
            };
            this.parent.trigger(events.numberFormatting, eventArgs, function (observedArgs) {
                Eif (!observedArgs.cancel) {
                    _this.parent.setProperties({ dataSourceSettings: { formatSettings: observedArgs.formatSettings } }, true);
                    var actionInfo = {
                        numberFormattingInfo: _this.parent.dataSourceSettings.formatSettings
                    };
                    _this.parent.actionObj.actionInfo = actionInfo;
                    try {
                        _this.parent.updateDataSource();
                        _this.dialog.close();
                    }
                    catch (exception) {
                        _this.parent.setProperties({ dataSourceSettings: { formatSettings: format } }, true);
                        _this.parent.pivotCommon.errorDialog.createErrorDialog(_this.parent.localeObj.getConstant('error'), _this.parent.localeObj.getConstant('invalidFormat'), _this.dialog.element);
                        _this.parent.hideWaitingPopup();
                    }
                }
                else {
                    _this.dialog.close();
                    _this.parent.setProperties({ dataSourceSettings: { formatSettings: format } }, true);
                }
            });
        };
        NumberFormatting.prototype.insertFormat = function (fieldName, text, formatType) {
            var isExist = false;
            var groupingDropDown = ej2_base_1.getInstance(ej2_base_1.select('#' + this.parent.element.id + '_GroupingDrop', this.parent.element), ej2_dropdowns_1.DropDownList);
            var newFormat = {
                name: fieldName, format: text,
                useGrouping: groupingDropDown.value === this.parent.localeObj.getConstant('true') ? true : false,
                type: formatType
            };
            var format = this.newFormat;
            for (var i = 0; i < format.length; i++) {
                if (format[i].name === fieldName) {
                    format[i] = newFormat;
                    isExist = true;
                }
            }
            if (!isExist) {
                format.push(newFormat);
            }
            this.lastFormattedValue = [];
            this.lastFormattedValue.push(newFormat);
        };
        NumberFormatting.prototype.addEventListener = function () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.initFormatting, this.showNumberFormattingDialog, this);
        };
        NumberFormatting.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.initFormatting, this.showNumberFormattingDialog);
        };
        NumberFormatting.prototype.destroy = function () {
            Iif (this.dialog && !this.dialog.isDestroyed) {
                this.dialog.destroy();
                this.dialog = null;
            }
            this.removeEventListener();
        };
        return NumberFormatting;
    }());
    exports.NumberFormatting = NumberFormatting;
});