all files / grid/renderer/ date-filter-ui.js

100% Statements 41/41
85% Branches 17/20
100% Functions 8/8
100% Lines 41/41
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   13× 13× 13× 13× 13× 13× 13×                                                      
define(["require", "exports", "@syncfusion/ej2-calendars", "@syncfusion/ej2-base", "../base/util", "../base/constant", "../base/string-literals"], function (require, exports, ej2_calendars_1, ej2_base_1, util_1, events, literals) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DateFilterUI = (function () {
        function DateFilterUI(parent, serviceLocator, filterSettings) {
            this.dpOpen = this.openPopup.bind(this);
            this.parent = parent;
            this.locator = serviceLocator;
            this.fltrSettings = filterSettings;
            Eif (this.parent) {
                this.parent.on(events.filterMenuClose, this.destroy, this);
                this.parent.on(events.destroy, this.destroy, this);
            }
        }
        DateFilterUI.prototype.create = function (args) {
            var format = util_1.getCustomDateFormat(args.column.format, args.column.type);
            this.dialogObj = args.dialogObj;
            this.inputElem = this.parent.createElement('input', { className: 'e-flmenu-input', id: 'dateui-' + args.column.uid });
            args.target.appendChild(this.inputElem);
            if (args.column.type === 'date' || args.column.type === 'dateonly') {
                this.datePickerObj = new ej2_calendars_1.DatePicker(ej2_base_1.extend({
                    format: format,
                    cssClass: this.parent.cssClass ? 'e-popup-flmenu' + ' ' + this.parent.cssClass : 'e-popup-flmenu',
                    placeholder: args.localizeText.getConstant('ChooseDate'),
                    width: '100%',
                    locale: this.parent.locale,
                    enableRtl: this.parent.enableRtl
                }, args.column.filter.params));
            }
            else Eif (args.column.type === 'datetime') {
                this.datePickerObj = new ej2_calendars_1.DateTimePicker(ej2_base_1.extend({
                    format: format,
                    cssClass: this.parent.cssClass ? 'e-popup-flmenu' + ' ' + this.parent.cssClass : 'e-popup-flmenu',
                    placeholder: args.localizeText.getConstant('ChooseDate'),
                    width: '100%',
                    locale: this.parent.locale,
                    enableRtl: this.parent.enableRtl
                }, args.column.filter.params));
            }
            this.datePickerObj.addEventListener(literals['open'], this.dpOpen);
            this.datePickerObj.appendTo(this.inputElem);
        };
        DateFilterUI.prototype.write = function (args) {
            var dateuiObj = document.querySelector('#dateui-' + args.column.uid).ej2_instances[0];
            dateuiObj.value = !ej2_base_1.isNullOrUndefined(args.filteredValue) ? new Date(args.filteredValue) : null;
        };
        DateFilterUI.prototype.read = function (element, column, filterOptr, filterObj) {
            var dateuiObj = document.querySelector('#dateui-' + column.uid).ej2_instances[0];
            var filterValue = dateuiObj.value;
            filterValue = ej2_base_1.isNullOrUndefined(filterValue) ? null : filterValue;
            filterObj.filterByColumn(column.field, filterOptr, filterValue, 'and', true);
        };
        DateFilterUI.prototype.openPopup = function (args) {
            args.popup.element.style.zIndex = (this.dialogObj.zIndex + 1).toString();
        };
        DateFilterUI.prototype.destroy = function () {
            this.parent.off(events.filterMenuClose, this.destroy);
            this.parent.off(events.destroy, this.destroy);
            if (ej2_base_1.isNullOrUndefined(this.datePickerObj) || this.datePickerObj.isDestroyed) {
                return;
            }
            this.datePickerObj.removeEventListener(literals['open'], this.dpOpen);
            this.datePickerObj.destroy();
        };
        return DateFilterUI;
    }());
    exports.DateFilterUI = DateFilterUI;
});