all files / pivotfieldlist/renderer/ axis-field-renderer.js

100% Statements 32/32
93.1% Branches 27/29
100% Functions 5/5
100% Lines 32/32
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   198×   482× 99×   482×   482× 482× 482× 482× 482× 482× 482× 482×   482× 464×   482× 474×   482× 466×   482×             405× 405× 1620× 1620×       1620×              
define(["require", "exports", "../../common/base/css-constant", "../../common/base/constant", "../../common/actions/pivot-button", "@syncfusion/ej2-data"], function (require, exports, cls, events, pivot_button_1, ej2_data_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AxisFieldRenderer = (function () {
        function AxisFieldRenderer(parent) {
            this.parent = parent;
        }
        AxisFieldRenderer.prototype.render = function () {
            if (!this.parent.pivotButtonModule || (this.parent.pivotButtonModule && this.parent.pivotButtonModule.isDestroyed)) {
                new pivot_button_1.PivotButton(this.parent);
            }
            this.createPivotButtons();
        };
        AxisFieldRenderer.prototype.createPivotButtons = function () {
            var rows = this.parent.dataSourceSettings.rows;
            var columns = this.parent.dataSourceSettings.columns;
            var values = this.parent.dataSourceSettings.values;
            var filters = this.parent.dataSourceSettings.filters;
            var fields = [rows, columns, values, filters];
            var parentElement = this.parent.dialogRenderer.parentElement;
            Eif (parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-filters')) {
                parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-filters').querySelector('.' + cls.AXIS_CONTENT_CLASS).innerHTML = '';
            }
            if (parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-rows')) {
                parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-rows').querySelector('.' + cls.AXIS_CONTENT_CLASS).innerHTML = '';
            }
            if (parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-columns')) {
                parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-columns').querySelector('.' + cls.AXIS_CONTENT_CLASS).innerHTML = '';
            }
            if (parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-values')) {
                parentElement.querySelector('.' + cls.FIELD_LIST_CLASS + '-values').querySelector('.' + cls.AXIS_CONTENT_CLASS).innerHTML = '';
            }
            if ((this.parent.dataType === 'pivot' && this.parent.dataSourceSettings.dataSource &&
                ((!(this.parent.dataSourceSettings.dataSource instanceof ej2_data_1.DataManager) &&
                    (this.parent.dataSourceSettings.dataSource.length > 0)) ||
                    (this.parent.dataSourceSettings.dataSource instanceof ej2_data_1.DataManager && this.parent.engineModule.data &&
                        this.parent.engineModule.data.length > 0))) ||
                (this.parent.dataType === 'olap' && this.parent.dataSourceSettings.url && this.parent.dataSourceSettings.url !== '') ||
                (this.parent.dataSourceSettings.mode === 'Server' && this.parent.dataSourceSettings.url !== '')) {
                var axis = ['rows', 'columns', 'values', 'filters'];
                for (var len = 0, lnt = fields.length; len < lnt; len++) {
                    Eif (fields[len]) {
                        var args = {
                            field: fields[len],
                            axis: axis[len].toString()
                        };
                        this.parent.notify(events.pivotButtonUpdate, args);
                    }
                }
            }
        };
        return AxisFieldRenderer;
    }());
    exports.AxisFieldRenderer = AxisFieldRenderer;
});