rename templates, rename Action to ActionContainer

This commit is contained in:
Géry Debongnie
2019-02-03 14:07:25 +01:00
parent 14ef31483f
commit e1bdce57ee
10 changed files with 30 additions and 35 deletions
+1 -1
View File
@@ -2,5 +2,5 @@ import { Widget } from "../core/widget";
import { Env } from "../env";
export class CRM extends Widget<Env, {}> {
template = "crm";
template = "web.crm";
}
+6 -1
View File
@@ -6,7 +6,12 @@ interface Props {
}
export class Counter extends Widget<Env, Props> {
template = "counter";
inlineTemplate = `
<div t-name="counter">
<button t-on-click="increment(-1)">-</button>
<span style="font-weight:bold">Value: <t t-esc="state.counter"/></span>
<button t-on-click="increment(1)">+</button>
</div>`;
state = {
counter: 0
};
+6 -2
View File
@@ -4,7 +4,7 @@ import { Clock } from "./clock";
import { Counter } from "./counter";
export class Discuss extends Widget<Env, {}> {
template = "discuss";
template = "web.discuss";
widgets = { Clock, Counter, ColorWidget };
state = { validcounter: true, color: "red" };
@@ -39,5 +39,9 @@ export class Discuss extends Widget<Env, {}> {
}
class ColorWidget extends Widget<Env, { color: "red" | "blue" }> {
template = "colorwidget";
inlineTemplate = `
<div t-name="colorwidget">
<span>Current Color: </span>
<t t-esc="props.color"/>
</div>`;
}
+1 -1
View File
@@ -6,7 +6,7 @@ export interface Props {
}
export class Navbar extends Widget<Env, Props> {
template = "navbar";
template = "web.navbar";
getUrl(menu: Menu) {
const action_id = String(menu.actionID);
@@ -6,8 +6,8 @@ export interface Props {
stack: ActionStack;
}
export class Action extends Widget<Env, Props> {
template = "action";
export class ActionContainer extends Widget<Env, Props> {
template = "web.action_container";
currentWidget: any;
shouldUpdate(nextProps: Props) {
+1 -1
View File
@@ -2,7 +2,7 @@ import { Widget } from "../core/widget";
import { Env } from "../env";
export class Clock extends Widget<Env, {}> {
template = "clock";
inlineTemplate = `<div class="o_clock"><t t-esc="state.currentTime"/></div>`;
timeout: any | undefined;
state = {
+1 -1
View File
@@ -2,5 +2,5 @@ import { Widget } from "../core/widget";
import { Env } from "../env";
export class HomeMenu extends Widget<Env, {}> {
template = "home";
template = "web.home_menu";
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { Env } from "../env";
import { INotification } from "../core/notifications";
export class Notification extends Widget<Env, INotification> {
template = "notification";
template = "web.notification";
close() {
this.env.notifications.close(this.props.id);
+3 -3
View File
@@ -2,7 +2,7 @@ import { Widget } from "../core/widget";
import { Env } from "../env";
import { ActionStack } from "../services/action_manager";
import { INotification } from "../core/notifications";
import { Action } from "./action";
import { ActionContainer } from "./action_container";
import { HomeMenu } from "./home_menu";
import { Navbar } from "./navbar";
import { Notification } from "./notification";
@@ -22,8 +22,8 @@ interface State {
//------------------------------------------------------------------------------
export class Root extends Widget<Env, {}> {
template = "web_client";
widgets = { Navbar, Notification, HomeMenu, Action };
template = "web.web_client";
widgets = { Navbar, Notification, HomeMenu, ActionContainer };
state: State = {
notifications: [],
+8 -22
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<div t-name="web_client" class="o_web_client">
<div t-name="web.web_client" class="o_web_client">
<t t-widget="Navbar" t-props="{inHome:state.inHome,app:state.currentApp}" t-on-toggle-home-menu="toggleHome"/>
<t t-if="state.inHome">
<t t-widget="HomeMenu" t-keep-alive="1" t-props="{apps:apps, openApp: openApp}"/>
</t>
<t t-else="1">
<t t-widget="Action" t-props="{stack:state.stack}" t-keep-alive="1"/>
<t t-widget="ActionContainer" t-props="{stack:state.stack}" t-keep-alive="1"/>
</t>
<div class="o_notification_container">
<t t-foreach="state.notifications" t-as="notif">
@@ -16,23 +16,13 @@
</div>
</div>
<div t-name="action" class="o_content"/>
<div t-name="clock" class="o_clock">
<t t-esc="state.currentTime"/>
</div>
<div t-name="web.action_container" class="o_content"/>
<div t-name="counter">
<button t-on-click="increment(-1)">-</button>
<span style="font-weight:bold">Value: <t t-esc="state.counter"/>
</span>
<button t-on-click="increment(1)">+</button>
</div>
<div t-name="crm" class="o_crm">
<div t-name="web.crm" class="o_crm">
<span>CRM!!!!</span>
</div>
<div t-name="discuss" class="o_discuss">
<div t-name="web.discuss" class="o_discuss">
<span>DISCUSS!!</span>
<button t-on-click="resetCounter">Reset first counter</button>
<button t-on-click="resetCounterAsync">Reset counter 2 in 3s</button>
@@ -52,11 +42,11 @@
<button t-on-click="addNotif(true)">Add sticky notif</button>
</div>
<div t-name="home" class="o_home_menu">
<div t-name="web.home_menu" class="o_home_menu">
<span>HOME MENU</span>
</div>
<div t-name="navbar" class="o_navbar">
<div t-name="web.navbar" class="o_navbar">
<a aria-label="Applications" class="o_title fa fa-th" href="#" title="Applications" accesskey="h" t-on-click="toggleHome"/>
<ul t-if="!props.inMenu">
<li t-foreach="env.menus" t-as="menu">
@@ -68,7 +58,7 @@
</ul>
</div>
<div t-name="notification" class="o_notification">
<div t-name="web.notification" class="o_notification">
<a t-if="props.sticky" class="fa fa-times o_close" href="#" title="Close" aria-label="Close" t-on-click="close"/>
<div class="o_notification_title">
<t t-raw="props.title"/>
@@ -79,8 +69,4 @@
</div>
<div t-name="colorwidget">
<span>Current Color: </span>
<t t-esc="props.color"/>
</div>
</templates>