UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

165 lines 6.55 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 { ContextService } from '../context.service'; import { Component, Input, ElementRef, ViewChild, Renderer } from '@angular/core'; import { FieldViewModel } from '../view-models/field-view-model'; import { FormGroup } from '@angular/forms'; import { BehaviorSubject } from 'rxjs'; import { safeUnsubscribe, accept, dropOn, paste, focus } from '../helpers-components'; var AutoCompleteComponent = (function () { function AutoCompleteComponent(context, renderer) { this.context = context; this.renderer = renderer; this.canDrop = false; this.choiceName = function (choice) { return choice.name; }; this.currentIndex = -1; } Object.defineProperty(AutoCompleteComponent.prototype, "model", { get: function () { return this.fieldViewModel; }, set: function (m) { this.fieldViewModel = m; }, enumerable: true, configurable: true }); Object.defineProperty(AutoCompleteComponent.prototype, "modelPaneId", { get: function () { return this.model.paneArgId; }, enumerable: true, configurable: true }); Object.defineProperty(AutoCompleteComponent.prototype, "modelId", { get: function () { return this.model.id; }, enumerable: true, configurable: true }); Object.defineProperty(AutoCompleteComponent.prototype, "control", { get: function () { return this.form.controls[this.model.id]; }, enumerable: true, configurable: true }); Object.defineProperty(AutoCompleteComponent.prototype, "choices", { get: function () { return this.model.choices; }, enumerable: true, configurable: true }); AutoCompleteComponent.prototype.accept = function (droppableVm) { return accept(droppableVm, this); }; ; AutoCompleteComponent.prototype.drop = function (draggableVm) { dropOn(draggableVm, this.model, this); }; AutoCompleteComponent.prototype.classes = function () { return _a = {}, _a[this.model.color] = true, _a["candrop"] = this.canDrop, _a; var _a; }; Object.defineProperty(AutoCompleteComponent.prototype, "description", { get: function () { return this.model.description; }, enumerable: true, configurable: true }); AutoCompleteComponent.prototype.paste = function (event) { var _this = this; paste(event, this.model, this, function () { return _this.context.getCopyViewModel(); }, function () { return _this.context.setCopyViewModel(null); }); }; AutoCompleteComponent.prototype.clear = function () { this.model.clear(); this.control.reset(); }; AutoCompleteComponent.prototype.select = function (item) { this.model.choices = []; this.model.selectedChoice = item; this.control.reset(item); }; Object.defineProperty(AutoCompleteComponent.prototype, "subject", { get: function () { var _this = this; if (!this.bSubject) { var initialValue = this.control.value; this.bSubject = new BehaviorSubject(initialValue); this.sub = this.control.valueChanges.subscribe(function (data) { _this.bSubject.next(data); _this.currentIndex = -1; }); } return this.bSubject; }, enumerable: true, configurable: true }); AutoCompleteComponent.prototype.isSelected = function (i) { return { "selected": i === this.currentIndex }; }; AutoCompleteComponent.prototype.onArrowUp = function () { this.currentIndex--; this.currentIndex = this.currentIndex < -1 ? -1 : this.currentIndex; return false; }; AutoCompleteComponent.prototype.onArrowDown = function () { this.currentIndex++; var maxIndex = this.choices.length - 1; this.currentIndex = this.currentIndex > maxIndex ? maxIndex : this.currentIndex; return false; }; AutoCompleteComponent.prototype.selectCurrent = function () { var maxIndex = this.choices.length - 1; if (this.currentIndex >= 0 && this.currentIndex <= maxIndex) { this.select(this.choices[this.currentIndex]); return false; } return true; }; AutoCompleteComponent.prototype.ngOnDestroy = function () { safeUnsubscribe(this.sub); }; AutoCompleteComponent.prototype.focus = function () { return focus(this.renderer, this.inputField); }; return AutoCompleteComponent; }()); __decorate([ Input(), __metadata("design:type", FieldViewModel), __metadata("design:paramtypes", [FieldViewModel]) ], AutoCompleteComponent.prototype, "model", null); __decorate([ Input(), __metadata("design:type", FormGroup) ], AutoCompleteComponent.prototype, "form", void 0); __decorate([ ViewChild("focus"), __metadata("design:type", ElementRef) ], AutoCompleteComponent.prototype, "inputField", void 0); AutoCompleteComponent = __decorate([ Component({ selector: 'nof-auto-complete', template: require('./auto-complete.component.html'), styles: [require('./auto-complete.component.css')] }), __metadata("design:paramtypes", [ContextService, Renderer]) ], AutoCompleteComponent); export { AutoCompleteComponent }; //# sourceMappingURL=auto-complete.component.js.map