all files / grid/renderer/ datepicker-edit-cell.js

95.24% Statements 40/42
87.1% Branches 27/31
91.67% Functions 11/12
94.87% Lines 37/39
11 statements, 6 functions, 9 branches Ignored     
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          69× 69× 69×   65× 65× 53× 53× 25× 25×     65× 12×   65×     65× 65× 65× 65× 65×                                
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-calendars", "../base/util", "./edit-cell-base"], function (require, exports, ej2_base_1, ej2_calendars_1, util_1, edit_cell_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DatePickerEditCell = (function (_super) {
        __extends(DatePickerEditCell, _super);
        function DatePickerEditCell(parent) {
            var _this = _super.call(this, parent) || this;
            _this.isMaskModuleInjected = true;
            return _this;
        }
        DatePickerEditCell.prototype.write = function (args) {
            this.edit = this.parent.editModule;
            if (args.column.editType === 'datepickeredit') {
                this.obj = new ej2_calendars_1.DatePicker(ej2_base_1.extend(dateanddatetimerender(args, this.parent.editSettings.mode, this.parent.enableRtl, this.parent.cssClass, this), args.column.edit.params));
                if (this.isMaskModuleInjected) {
                    ej2_calendars_1.DatePicker.Inject(ej2_calendars_1.MaskedDateTime);
                    this.isMaskModuleInjected = false;
                }
            }
            if (args.column.editType === 'datetimepickeredit') {
                this.obj = new ej2_calendars_1.DateTimePicker(ej2_base_1.extend(dateanddatetimerender(args, this.parent.editSettings.mode, this.parent.enableRtl, this.parent.cssClass, this), args.column.edit.params));
            }
            this.obj.appendTo(args.element);
        };
        return DatePickerEditCell;
    }(edit_cell_base_1.EditCellBase));
    exports.DatePickerEditCell = DatePickerEditCell;
    function dateanddatetimerender(args, mode, rtl, css, datePickerEditCell) {
        var isInline = mode !== 'Dialog';
        var format = util_1.getCustomDateFormat(args.column.format, args.column.type);
        var value = util_1.getObject(args.column.field, args.rowData);
        value = value ? new Date(value) : null;
        return {
            floatLabelType: isInline ? 'Never' : 'Always',
            value: value,
            format: format,
            placeholder: isInline ?
                '' : args.column.headerText, enableRtl: rtl,
            enabled: util_1.isEditable(args.column, args.requestType, args.element),
            cssClass: css ? css : null,
            close: datePickerClose.bind(datePickerEditCell)
        };
    }
    function datePickerClose(args) {
        if (args.event && args.event.action === 'escape') {
            this.edit.editCellDialogClose = true;
        }
    }
});