From 3fd00f72afde5580876f66ead5940bbb2168813f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 5 Feb 2019 14:16:51 +0100 Subject: [PATCH] rename base_widget -> component --- .../src/ts/core/{base_widget.ts => component.ts} | 16 ++++++++-------- web/static/src/ts/env.ts | 2 +- web/static/src/ts/services/action_manager.ts | 2 +- web/static/src/ts/widgets/widget.ts | 4 ++-- .../{base_widget.test.ts => component.test.ts} | 4 ++-- web/static/tests/helpers.ts | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) rename web/static/src/ts/core/{base_widget.ts => component.ts} (94%) rename web/static/tests/core/{base_widget.test.ts => component.test.ts} (99%) diff --git a/web/static/src/ts/core/base_widget.ts b/web/static/src/ts/core/component.ts similarity index 94% rename from web/static/src/ts/core/base_widget.ts rename to web/static/src/ts/core/component.ts index 31143000..d391a460 100644 --- a/web/static/src/ts/core/base_widget.ts +++ b/web/static/src/ts/core/component.ts @@ -23,8 +23,8 @@ interface Meta { isStarted: boolean; isMounted: boolean; isDestroyed: boolean; - parent: BaseWidget | null; - children: { [key: number]: BaseWidget }; + parent: Component | null; + children: { [key: number]: Component }; // children mapping: from templateID to widgetID // should it be a map number => Widget? cmap: { [key: number]: number }; @@ -40,7 +40,7 @@ export interface Type extends Function { // Widget //------------------------------------------------------------------------------ -export class BaseWidget< +export class Component< T extends WEnv, Props, State extends {} @@ -57,14 +57,14 @@ export class BaseWidget< state: State = {}; props: Props; refs: { - [key: string]: BaseWidget | HTMLElement | undefined; + [key: string]: Component | HTMLElement | undefined; } = {}; //-------------------------------------------------------------------------- // Lifecycle //-------------------------------------------------------------------------- - constructor(parent: BaseWidget | T, props?: Props) { + constructor(parent: Component | T, props?: Props) { super(); wl.push(this); @@ -74,8 +74,8 @@ export class BaseWidget< // Pro: but creating widget (by a template) is always unsafe anyway this.props = props; let id: number; - let p: BaseWidget | null = null; - if (parent instanceof BaseWidget) { + let p: Component | null = null; + if (parent instanceof Component) { p = parent; this.env = parent.env; id = this.env.getID(); @@ -259,7 +259,7 @@ export class BaseWidget< } } - private visitSubTree(callback: (w: BaseWidget) => boolean) { + private visitSubTree(callback: (w: Component) => boolean) { const shouldVisitChildren = callback(this); if (shouldVisitChildren) { const children = this.__widget__.children; diff --git a/web/static/src/ts/env.ts b/web/static/src/ts/env.ts index 7fedb321..4f61d77f 100644 --- a/web/static/src/ts/env.ts +++ b/web/static/src/ts/env.ts @@ -1,5 +1,5 @@ import { Ajax, IAjax } from "./core/ajax"; -import { WEnv } from "./core/base_widget"; +import { WEnv } from "./core/component"; import { INotificationManager, NotificationManager diff --git a/web/static/src/ts/services/action_manager.ts b/web/static/src/ts/services/action_manager.ts index d292ce3e..ee64e96a 100644 --- a/web/static/src/ts/services/action_manager.ts +++ b/web/static/src/ts/services/action_manager.ts @@ -1,4 +1,4 @@ -import { Type } from "../core/base_widget"; +import { Type } from "../core/component"; import { EventBus } from "../core/event_bus"; import { Registry } from "../core/registry"; import { Widget } from "../widgets/widget"; diff --git a/web/static/src/ts/widgets/widget.ts b/web/static/src/ts/widgets/widget.ts index 9f66e274..459e094d 100644 --- a/web/static/src/ts/widgets/widget.ts +++ b/web/static/src/ts/widgets/widget.ts @@ -1,7 +1,7 @@ -import { BaseWidget } from "../core/base_widget"; +import { Component } from "../core/component"; import { Env } from "../env"; -export class Widget extends BaseWidget {} +export class Widget extends Component {} // TODO: move this to PureComponent in core export class PureWidget extends Widget { diff --git a/web/static/tests/core/base_widget.test.ts b/web/static/tests/core/component.test.ts similarity index 99% rename from web/static/tests/core/base_widget.test.ts rename to web/static/tests/core/component.test.ts index 2b073856..f7338da5 100644 --- a/web/static/tests/core/base_widget.test.ts +++ b/web/static/tests/core/component.test.ts @@ -1,4 +1,4 @@ -import { BaseWidget, WEnv } from "../../src/ts/core/base_widget"; +import { Component, WEnv } from "../../src/ts/core/component"; import { makeTestFixture, makeTestWEnv, normalize } from "../helpers"; //------------------------------------------------------------------------------ @@ -33,7 +33,7 @@ function nextTick(): Promise { return Promise.resolve(); } -class Widget extends BaseWidget {} +class Widget extends Component {} function children(w: Widget): Widget[] { const childrenMap = w.__widget__.children; diff --git a/web/static/tests/helpers.ts b/web/static/tests/helpers.ts index 60e1173b..f6cf2044 100644 --- a/web/static/tests/helpers.ts +++ b/web/static/tests/helpers.ts @@ -1,6 +1,6 @@ import { QWeb } from "../src/ts/core/qweb_vdom"; import { idGenerator } from "../src/ts/core/utils"; -import { WEnv } from "../src/ts/core/base_widget"; +import { WEnv } from "../src/ts/core/component"; import { Env } from "../src/ts/env"; import { IAjax, RPCQuery } from "../src/ts/core/ajax"; import { Registry } from "../src/ts/core/registry";