UNPKG

ng2-encrm-components

Version:
73 lines 3.05 kB
"use strict"; var core_1 = require('@angular/core'); var button_state_1 = require('./button-state'); var ButtonSaveComponent = (function () { // ------------------------------------------------------------------------- // constructor // ------------------------------------------------------------------------- function ButtonSaveComponent() { // ------------------------------------------------------------------------- // public properties // ------------------------------------------------------------------------- this.withError = false; this.type = 'primary'; this.state = button_state_1.ButtonState.NORMAL; this.buttonState = button_state_1.ButtonState; this.disabled = false; this.textSuccess = 'Saved...'; this.textError = 'Error...'; } // ------------------------------------------------------------------------- // methods // ------------------------------------------------------------------------- ButtonSaveComponent.prototype.ngOnInit = function () { if (!this.id) throw new Error('No id for compnent button save'); ButtonSaveComponent.instances[this.id] = this; }; ButtonSaveComponent.setState = function (id, state) { var d = ButtonSaveComponent.instances[id]; d.state = state; if (state === button_state_1.ButtonState.ERROR) { d.withError = true; } if (state === button_state_1.ButtonState.ERROR || state === button_state_1.ButtonState.FINISH) { setTimeout(function () { d.state = button_state_1.ButtonState.NORMAL; }, ButtonSaveComponent.timeoutMessages); } }; ButtonSaveComponent.prototype.onClick = function () { if (this.withError) this.withError = false; }; ButtonSaveComponent.timeoutMessages = 1000; ButtonSaveComponent.instances = {}; __decorate([ core_1.Input(), __metadata('design:type', String) ], ButtonSaveComponent.prototype, "id", void 0); __decorate([ core_1.Input(), __metadata('design:type', Boolean) ], ButtonSaveComponent.prototype, "disabled", void 0); __decorate([ core_1.Input(), __metadata('design:type', String) ], ButtonSaveComponent.prototype, "textSuccess", void 0); __decorate([ core_1.Input(), __metadata('design:type', String) ], ButtonSaveComponent.prototype, "textError", void 0); ButtonSaveComponent = __decorate([ core_1.Component({ selector: 'button-save', template: require('./button-save.component.html'), styles: [require('./button-save.component.scss')] }), __metadata('design:paramtypes', []) ], ButtonSaveComponent); return ButtonSaveComponent; }()); exports.ButtonSaveComponent = ButtonSaveComponent; //# sourceMappingURL=button-loader.component.js.map