UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

129 lines 6.24 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); 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, ComponentFactoryResolver, ViewChild, ViewContainerRef } from '@angular/core'; import { CustomComponentService } from '../custom-component.service'; import { ActivatedRoute } from '@angular/router'; import { ViewType } from '../route-data'; import { UrlManagerService } from '../url-manager.service'; import { PaneComponent } from '../pane/pane'; import { ContextService } from '../context.service'; import { ErrorService } from '../error.service'; import * as Models from '../models'; import { ConfigService } from '../config.service'; var DynamicListComponent = (function (_super) { __extends(DynamicListComponent, _super); function DynamicListComponent(activatedRoute, urlManager, context, error, componentFactoryResolver, customComponentService, configService) { var _this = _super.call(this, activatedRoute, urlManager, context) || this; _this.error = error; _this.componentFactoryResolver = componentFactoryResolver; _this.customComponentService = customComponentService; _this.configService = configService; _this.title = ""; _this.showPlaceholder = true; _this.reloadPlaceholderButton = { value: "Reload", doClick: function () { return _this.reload(); }, show: function () { return true; }, disabled: function () { return null; }, tempDisabled: function () { return null; }, title: function () { return ""; }, accesskey: null }; return _this; } DynamicListComponent.prototype.getActionExtensions = function (routeData) { return routeData.objectId ? this.context.getActionExtensionsFromObject(routeData.paneId, Models.ObjectIdWrapper.fromObjectId(routeData.objectId, this.configService.config.keySeparator), routeData.actionId) : this.context.getActionExtensionsFromMenu(routeData.menuId, routeData.actionId); }; DynamicListComponent.prototype.reload = function () { var _this = this; var recreate = function () { return _this.cachedRouteData.objectId ? _this.context.getListFromObject(_this.cachedRouteData) : _this.context.getListFromMenu(_this.cachedRouteData); }; recreate() .then(function () { return _this.setup(_this.cachedRouteData); }) .catch(function (reject) { _this.error.handleError(reject); }); }; Object.defineProperty(DynamicListComponent.prototype, "actionHolders", { get: function () { return [this.reloadPlaceholderButton]; }, enumerable: true, configurable: true }); DynamicListComponent.prototype.setup = function (routeData) { var _this = this; this.cachedRouteData = routeData; var cachedList = this.context.getCachedList(routeData.paneId, routeData.page, routeData.pageSize); if (cachedList) { this.showPlaceholder = false; var et = cachedList.extensions().elementType(); if (et && et !== this.lastOid) { this.lastOid = et; this.parent.clear(); this.customComponentService.getCustomComponent(et, ViewType.List).then(function (c) { var childComponent = _this.componentFactoryResolver.resolveComponentFactory(c); _this.parent.createComponent(childComponent); }); } } else { this.showPlaceholder = true; this.title = "List"; this.parent.clear(); this.lastOid = null; // so we recreate child after reload this.getActionExtensions(routeData) .then(function (ext) { return _this.title = ext.friendlyName(); }) .catch(function (reject) { return _this.error.handleError(reject); }); } }; DynamicListComponent.prototype.ngOnDestroy = function () { _super.prototype.ngOnDestroy.call(this); this.parent.clear(); }; return DynamicListComponent; }(PaneComponent)); __decorate([ ViewChild('parent', { read: ViewContainerRef }), __metadata("design:type", ViewContainerRef) ], DynamicListComponent.prototype, "parent", void 0); DynamicListComponent = __decorate([ Component({ selector: 'nof-dynamic-list', template: require('./dynamic-list.component.html'), styles: [require('./dynamic-list.component.css')] }), __metadata("design:paramtypes", [ActivatedRoute, UrlManagerService, ContextService, ErrorService, ComponentFactoryResolver, CustomComponentService, ConfigService]) ], DynamicListComponent); export { DynamicListComponent }; //# sourceMappingURL=dynamic-list.component.js.map