UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

130 lines 5.6 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { FieldViewModel } from '../view-models/field-view-model'; import { ViewChild } from '@angular/core'; import { Component, Input, EventEmitter } from '@angular/core'; import { AbstractControl, FormGroup } from '@angular/forms'; import { DatePickerComponent, DatePickerOptions } from "../date-picker/date-picker.component"; import { ConfigService } from '../config.service'; import * as Constants from '../constants'; import * as Msg from '../user-messages'; var DatePickerFacadeComponent = (function () { function DatePickerFacadeComponent(configService) { this.configService = configService; this.datePickerOptions = new DatePickerOptions(); this.inputEvents = new EventEmitter(); this.datePickerOptions.format = configService.config.dateInputFormat; } Object.defineProperty(DatePickerFacadeComponent.prototype, "id", { get: function () { return this.model.paneArgId; }, enumerable: true, configurable: true }); Object.defineProperty(DatePickerFacadeComponent.prototype, "description", { get: function () { return this.model.description; }, enumerable: true, configurable: true }); DatePickerFacadeComponent.prototype.setValueIfChanged = function (dateModel) { var oldValue = this.control.value; var newValue = dateModel ? dateModel.format(Constants.fixedDateFormat) : ""; if (newValue !== oldValue) { this.model.resetMessage(); this.model.clientValid = true; this.control.setValue(newValue); } }; DatePickerFacadeComponent.prototype.handleDefaultEvent = function (data) { if (this.control) { if (data === "closed") { var dateModel = this.datepicker.dateModel; this.setValueIfChanged(dateModel); } } }; DatePickerFacadeComponent.prototype.handleDateChangedEvent = function (dateModel) { if (this.control) { this.setValueIfChanged(dateModel); } }; DatePickerFacadeComponent.prototype.handleDateClearedEvent = function () { if (this.control) { this.model.resetMessage(); this.model.clientValid = true; this.control.setValue(""); } }; DatePickerFacadeComponent.prototype.handleInvalidDateEvent = function (data) { if (this.control) { this.model.setMessage(Msg.invalidDate); this.model.clientValid = false; this.control.setErrors((_a = {}, _a[Msg.invalidDate] = true, _a)); } var _a; }; DatePickerFacadeComponent.prototype.handleEvents = function (e) { switch (e.type) { case ("default"): this.handleDefaultEvent(e.data); break; case ("dateChanged"): this.handleDateChangedEvent(e.data); break; case ("dateCleared"): this.handleDateClearedEvent(); break; case ("dateInvalid"): this.handleInvalidDateEvent(e.data); break; default: //ignore } }; DatePickerFacadeComponent.prototype.ngAfterViewInit = function () { var _this = this; var existingValue = this.control && this.control.value; if (existingValue && (existingValue instanceof String || typeof existingValue === "string")) { setTimeout(function () { return _this.inputEvents.emit({ type: "setDate", data: existingValue, }); }); } }; DatePickerFacadeComponent.prototype.focus = function () { return this.datepicker.focus(); }; return DatePickerFacadeComponent; }()); __decorate([ Input(), __metadata("design:type", AbstractControl) ], DatePickerFacadeComponent.prototype, "control", void 0); __decorate([ Input(), __metadata("design:type", FormGroup) ], DatePickerFacadeComponent.prototype, "form", void 0); __decorate([ Input(), __metadata("design:type", FieldViewModel) ], DatePickerFacadeComponent.prototype, "model", void 0); __decorate([ ViewChild("dp"), __metadata("design:type", DatePickerComponent) ], DatePickerFacadeComponent.prototype, "datepicker", void 0); DatePickerFacadeComponent = __decorate([ Component({ selector: 'nof-date-picker-facade', template: require('./date-picker-facade.component.html'), styles: [require('./date-picker-facade.component.css')] }), __metadata("design:paramtypes", [ConfigService]) ], DatePickerFacadeComponent); export { DatePickerFacadeComponent }; //# sourceMappingURL=date-picker-facade.component.js.map