1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { ReflectiveInjector } from "@angular/core";
- import { getMetadataStorage } from "../odoo/utils/metadata-storage";
- export class BaseView<T> {
- type: T = {} as T;
- model: any = {};
- injector: any = {};
- title: string;
- constructor(c: { new (): T; }, ...injectables: any[]) {
- this.type = new c();
- this.model = getMetadataStorage().models.filterByTarget(this.type.constructor).items.shift();
- this.injector = ReflectiveInjector.resolveAndCreate(injectables);
- this.title = "Sin título";
- }
- /**
- *
- * @param injectable
- */
- getInjectable(injectable: any): any {
- return this.injector.get(injectable);
- }
- /**
- *
- */
- getTitle(): string {
- return this.title;
- }
- /**
- *
- * @param title
- */
- setTitle(title: string): void {
- this.title = title;
- }
- /**
- *
- */
- getType(): T {
- return this.type;
- }
- /**
- *
- */
- getModel(): any {
- return this.model;
- }
- /**
- *
- */
- getModelName(): string {
- return this.getModel().name;
- }
- /**
- *
- */
- getInjector(): any {
- return this.injector;
- }
- }
|