UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

122 lines 5.75 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 { Component, Input } from '@angular/core'; import { CollectionViewState } from '../route-data'; import { CollectionViewModel } from '../view-models/collection-view-model'; import { UrlManagerService } from '../url-manager.service'; import { safeUnsubscribe } from '../helpers-components'; var CollectionComponent = (function () { function CollectionComponent(urlManager) { var _this = this; this.urlManager = urlManager; this.isSummary = function () { return _this.collection.currentState === CollectionViewState.Summary; }; this.isList = function () { return _this.collection.currentState === CollectionViewState.List; }; this.isTable = function () { return _this.collection.currentState === CollectionViewState.Table; }; this.showActions = function () { return !_this.disableActions() && (_this.isTable() || _this.isList()); }; this.showSummary = function () { return (_this.mayHaveItems || !_this.disableActions()) && (_this.isList() || _this.isTable()); }; this.showList = function () { return (_this.mayHaveItems || !_this.disableActions()) && (_this.isTable() || _this.isSummary()); }; this.showTable = function () { return _this.mayHaveItems && (_this.isList() || _this.isSummary()); }; this.doSummary = function () { return _this.collection.doSummary(); }; this.doList = function () { return _this.collection.doList(); }; this.doTable = function () { return _this.collection.doTable(); }; this.disableActions = function () { return _this.collection.noActions(); }; this.hasTableData = function () { return _this.collection.hasTableData(); }; } Object.defineProperty(CollectionComponent.prototype, "currentState", { get: function () { return this.collection.currentState; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "state", { get: function () { return CollectionViewState[this.currentState].toString().toLowerCase(); }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "title", { get: function () { return this.collection.title; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "details", { get: function () { return this.collection.details; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "mayHaveItems", { get: function () { return this.collection.mayHaveItems; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "header", { get: function () { return this.collection.header; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "items", { get: function () { return this.collection.items; }, enumerable: true, configurable: true }); Object.defineProperty(CollectionComponent.prototype, "message", { get: function () { return this.collection.getMessage(); }, enumerable: true, configurable: true }); CollectionComponent.prototype.ngOnInit = function () { var _this = this; this.paneRouteDataSub = this.urlManager.getPaneRouteDataObservable(this.collection.onPaneId) .subscribe(function (paneRouteData) { if (!paneRouteData.isEqual(_this.lastPaneRouteData)) { _this.lastPaneRouteData = paneRouteData; _this.currentOid = _this.currentOid || paneRouteData.objectId; // ignore if different object if (_this.currentOid === paneRouteData.objectId) { _this.collection.reset(paneRouteData, false); _this.collection.resetMessage(); } _this.selectedDialogId = paneRouteData.dialogId; } }); }; CollectionComponent.prototype.ngOnDestroy = function () { safeUnsubscribe(this.paneRouteDataSub); }; return CollectionComponent; }()); __decorate([ Input(), __metadata("design:type", CollectionViewModel) ], CollectionComponent.prototype, "collection", void 0); CollectionComponent = __decorate([ Component({ selector: 'nof-collection', template: require('./collection.component.html'), styles: [require('./collection.component.css')] }), __metadata("design:paramtypes", [UrlManagerService]) ], CollectionComponent); export { CollectionComponent }; //# sourceMappingURL=collection.component.js.map