UNPKG

my-test123

Version:
91 lines 3.41 kB
import { Component, ViewEncapsulation, Input, Output, ViewChild, EventEmitter } from '@angular/core'; var InlineInputComponent = /** @class */ (function () { function InlineInputComponent() { this.readOnly = false; this.placeholder = 'Enter text here'; this.onLineClickEdit = true; this.onSave = new EventEmitter(); this.inputValue = ''; this.saving = false; this.editing = false; this.previousValue = ''; this.errorMessage = ''; } Object.defineProperty(InlineInputComponent.prototype, "input", { set: function (val) { this.inputValue = val; this.previousValue = val; }, enumerable: true, configurable: true }); InlineInputComponent.prototype.ngOnInit = function () { }; InlineInputComponent.prototype.startEditing = function (event, onLineClick) { this.errorMessage = ''; if (!this.readOnly || !this.editing && ((onLineClick && this.onLineClickEdit) || !onLineClick)) { this.editing = true; this.previousValue = this.inputField.nativeElement.value; this.inputField.nativeElement.focus(); } else { this.inputField.nativeElement.blur(); } }; InlineInputComponent.prototype.saveClick = function () { var _this = this; this.errorMessage = ''; this.saving = true; this.onSave.emit({ value: this.inputField.nativeElement.value, callBack: function (v, e) { if (v === void 0) { v = ''; } if (e === void 0) { e = ''; } return _this.handleSave(v, e); } }); }; InlineInputComponent.prototype.closeClick = function () { this.errorMessage = ''; this.inputValue = this.previousValue; this.inputField.nativeElement.value = this.previousValue; this.previousValue = ''; this.editing = false; }; InlineInputComponent.prototype.handleSave = function (value, error) { this.errorMessage = error; this.saving = false; if (this.errorMessage) { } else { this.editing = false; this.inputValue = value; } }; InlineInputComponent.prototype.submitOnEnter = function (event) { event.preventDefault(); this.saveClick(); this.inputField.nativeElement.blur(); }; InlineInputComponent.decorators = [ { type: Component, args: [{ encapsulation: ViewEncapsulation.None, selector: 'f8-inlineinput', template: require('./inlineinput.component.html'), styles: [require('./inlineinput.component.css').toString()] },] }, ]; /** @nocollapse */ InlineInputComponent.ctorParameters = function () { return []; }; InlineInputComponent.propDecorators = { 'inputField': [{ type: ViewChild, args: ['input',] },], 'readOnly': [{ type: Input, args: ['disabled',] },], 'input': [{ type: Input, args: ['value',] },], 'placeholder': [{ type: Input },], 'onLineClickEdit': [{ type: Input },], 'onSave': [{ type: Output },], }; return InlineInputComponent; }()); export { InlineInputComponent }; //# sourceMappingURL=inlineinput.component.js.map