import { ReflectiveInjector } from "@angular/core"; import { getMetadataStorage } from "../odoo/utils/metadata-storage"; export class BaseView { 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; } }