nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
74 lines • 4.03 kB
JavaScript
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 { Injectable } from '@angular/core';
import { CustomComponentConfigService } from './custom-component-config.service';
import { ObjectComponent } from './object/object.component';
import * as Models from './models';
import { ViewType } from './route-data';
import { ListComponent } from './list/list.component';
import { TypeResultCache } from './type-result-cache';
import { ContextService } from './context.service';
import { ErrorComponent } from './error/error.component';
var CustomComponentCache = (function (_super) {
__extends(CustomComponentCache, _super);
function CustomComponentCache(context, def) {
var _this = _super.call(this, context) || this;
_this.setDefault(def);
return _this;
}
return CustomComponentCache;
}(TypeResultCache));
var CustomComponentService = (function () {
function CustomComponentService(context, config) {
this.context = context;
this.config = config;
this.customComponentCaches = [];
this.customComponentCaches = [];
this.customComponentCaches[ViewType.Object] = new CustomComponentCache(context, ObjectComponent);
this.customComponentCaches[ViewType.List] = new CustomComponentCache(context, ListComponent);
this.customComponentCaches[ViewType.Error] = new CustomComponentCache(context, ErrorComponent);
config.configureCustomObjects(this.customComponentCaches[ViewType.Object]);
config.configureCustomLists(this.customComponentCaches[ViewType.List]);
config.configureCustomErrors(this);
}
CustomComponentService.prototype.getErrorKey = function (rc, code) {
var key = Models.ErrorCategory[rc] + "-" + (rc === Models.ErrorCategory.ClientError ? Models.ClientErrorCode[code] : Models.HttpStatusCode[code]);
return key;
};
CustomComponentService.prototype.getCustomComponent = function (domainType, viewType) {
return this.customComponentCaches[viewType].getResult(domainType);
};
CustomComponentService.prototype.getCustomErrorComponent = function (rc, code) {
var key = this.getErrorKey(rc, code);
return this.customComponentCaches[ViewType.Error].getResult(key);
};
CustomComponentService.prototype.addError = function (rc, code, result) {
var key = this.getErrorKey(rc, code);
this.customComponentCaches[ViewType.Error].addType(key, result);
};
return CustomComponentService;
}());
CustomComponentService = __decorate([
Injectable(),
__metadata("design:paramtypes", [ContextService,
CustomComponentConfigService])
], CustomComponentService);
export { CustomComponentService };
//# sourceMappingURL=custom-component.service.js.map