diff --git a/.gitignore b/.gitignore index 7da14593..7420f900 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -package-lock.json \ No newline at end of file +package-lock.json +.vscode \ No newline at end of file diff --git a/web/static/src/scss/app.scss b/web/static/src/scss/app.scss index e4069162..f609be12 100644 --- a/web/static/src/scss/app.scss +++ b/web/static/src/scss/app.scss @@ -1,56 +1,54 @@ $navbar-height: 40px; -$main-color: #875A7B; +$main-color: #875a7b; html { - height: 100%; + height: 100%; } body { - height: 100%; - margin: 0; + height: 100%; + margin: 0; } /* Web Client */ .o_web_client { - font-family: sans-serif; - height: 100%; - display: grid; - grid-template-rows: $navbar-height auto; + font-family: sans-serif; + height: 100%; + display: grid; + grid-template-rows: $navbar-height auto; } /* Navbar */ .o_navbar { - background-color: $main-color; + background-color: $main-color; + color: white; + display: flex; + line-height: $navbar-height; + + span.title { + font-size: 24px; + font-weight: bold; + padding: 0 16px; + } + + ul { + list-style-type: none; + display: inline-flex; + height: 100%; + margin: 0; + } + + li { + margin: 0 4px; + font-size: 20px; + &:hover { + background-color: darken($main-color, 10); + } + } + + a { color: white; - display: flex; - line-height: $navbar-height; - - span.title { - font-size: 24px; - font-weight: bold; - padding: 0 16px; - } - - ul { - list-style-type: none; - display: inline-flex; - height: 100%; - margin: 0; - } - - li { - margin: 0 4px; - font-size: 20px; - &:hover { - background-color: darken($main-color, 10); - } - } - - a { - color: white; - text-decoration: none; - padding: 0 5px; - - } + text-decoration: none; + padding: 0 5px; + } } - diff --git a/web/static/src/ts/core/qweb_vdom.ts b/web/static/src/ts/core/qweb_vdom.ts index 5f1ba7e5..e97f6c90 100644 --- a/web/static/src/ts/core/qweb_vdom.ts +++ b/web/static/src/ts/core/qweb_vdom.ts @@ -649,7 +649,7 @@ const onDirective: Directive = { }); ctx.addLine( `p${nodeID}.on = {${eventName}: context['${handler}'].bind(context${ - extraArgs ? ", " + qweb._formatExpression(extraArgs) : "" + extraArgs ? ", " + qweb._formatExpression(extraArgs) : "" })}` ); } diff --git a/web/static/src/ts/core/utils.ts b/web/static/src/ts/core/utils.ts index c65dd8aa..29bdb568 100644 --- a/web/static/src/ts/core/utils.ts +++ b/web/static/src/ts/core/utils.ts @@ -18,11 +18,11 @@ export function escape(str: string | number | undefined): string { */ export function htmlTrim(s: string): string { let result = s.replace(/(^\s+|\s+$)/g, ""); - if (s[0] === ' ') { - result = ' ' + result; + if (s[0] === " ") { + result = " " + result; } - if (result !== ' ' && s[s.length - 1] === ' ') { - result = result + ' '; + if (result !== " " && s[s.length - 1] === " ") { + result = result + " "; } return result; } diff --git a/web/static/src/ts/env.ts b/web/static/src/ts/env.ts index be36a0e4..54a5be58 100644 --- a/web/static/src/ts/env.ts +++ b/web/static/src/ts/env.ts @@ -26,4 +26,3 @@ export function makeEnvironment(): Env { actions }; } - diff --git a/web/static/src/ts/main.ts b/web/static/src/ts/main.ts index 0b09e01c..b72cd74d 100644 --- a/web/static/src/ts/main.ts +++ b/web/static/src/ts/main.ts @@ -1,7 +1,7 @@ /// import RootWidget from "./widgets/root_widget"; -import {makeEnvironment} from "./env"; +import { makeEnvironment } from "./env"; document.addEventListener("DOMContentLoaded", async function() { const env = makeEnvironment(); diff --git a/web/static/src/ts/services/action_manager.ts b/web/static/src/ts/services/action_manager.ts index aa686685..00cbad53 100644 --- a/web/static/src/ts/services/action_manager.ts +++ b/web/static/src/ts/services/action_manager.ts @@ -12,13 +12,11 @@ import { Action } from "./actions"; // { id: 2, title: "CRM", Widget: CRM } // ]; - - export default class ActionManager { - doAction(action: Action) { - console.log(action); - // load data (??) - // trigger action somewhere - // upload url with router - } -} \ No newline at end of file + doAction(action: Action) { + console.log(action); + // load data (??) + // trigger action somewhere + // upload url with router + } +} diff --git a/web/static/src/ts/services/ajax.ts b/web/static/src/ts/services/ajax.ts index c5214afa..df8c9ee0 100644 --- a/web/static/src/ts/services/ajax.ts +++ b/web/static/src/ts/services/ajax.ts @@ -1,2 +1 @@ - -export default class Ajax{} \ No newline at end of file +export default class Ajax {} diff --git a/web/static/src/ts/services/router.ts b/web/static/src/ts/services/router.ts index bba7da5b..fb75598f 100644 --- a/web/static/src/ts/services/router.ts +++ b/web/static/src/ts/services/router.ts @@ -16,11 +16,14 @@ export default class Router { constructor() { window.addEventListener("popstate", this.onUrlChange.bind(this)); - window.onhashchange = function () { console.log('aaaa'); debugger; } + window.onhashchange = function() { + console.log("aaaa"); + debugger; + }; } onUrlChange(event: PopStateEvent) { - debugger + debugger; event.preventDefault(); const info = this.getRoute(); for (let listener of this.listeners) { diff --git a/web/static/src/ts/widgets/Counter.ts b/web/static/src/ts/widgets/Counter.ts index 8c10202b..9023270b 100644 --- a/web/static/src/ts/widgets/Counter.ts +++ b/web/static/src/ts/widgets/Counter.ts @@ -16,7 +16,7 @@ export default class Counter extends Widget { counter: 0 }; - constructor(parent: Widget, props: {initialState?: number}) { + constructor(parent: Widget, props: { initialState?: number }) { super(parent); this.state.counter = props.initialState || 0; } diff --git a/web/static/tests/qweb_vdom.test.ts b/web/static/tests/qweb_vdom.test.ts index 4c2294da..ed46b971 100644 --- a/web/static/tests/qweb_vdom.test.ts +++ b/web/static/tests/qweb_vdom.test.ts @@ -1,4 +1,4 @@ -import QWeb, {EvalContext} from "../src/ts/core/qweb_vdom"; +import QWeb, { EvalContext } from "../src/ts/core/qweb_vdom"; import { init } from "../libs/snabbdom/src/snabbdom"; import sdAttributes from "../libs/snabbdom/src/modules/attributes"; import sdListeners from "../libs/snabbdom/src/modules/eventlisteners"; @@ -551,13 +551,18 @@ describe("foreach", () => { test("iterate, dict param", () => { const qweb = new QWeb(); - qweb.addTemplate('test',` + qweb.addTemplate( + "test", + `
[: - ] -
`); - const result = trim(renderToString(qweb, "test", { value: { a: 1, b: 2, c: 3 } })); + ` + ); + const result = trim( + renderToString(qweb, "test", { value: { a: 1, b: 2, c: 3 } }) + ); const expected = `
[0:a1-even][1:b2-odd][2:c3-even]
`; expect(result).toBe(expected); }); @@ -594,7 +599,7 @@ describe("misc", () => { ` ); - const result = trim(renderToString(qweb, "caller")) + const result = trim(renderToString(qweb, "caller")); const expected = trim(`
4 @@ -655,26 +660,28 @@ describe("t-on", () => { test("can bind handlers with loop variable as argument", () => { expect.assertions(1); const qweb = new QWeb(); - qweb.addTemplate("test", ` + qweb.addTemplate( + "test", + ` `); + ` + ); const node = renderToDOM(qweb, "test", { activate(action) { - expect(action).toBe('someval'); + expect(action).toBe("someval"); } }); - (node).getElementsByTagName('a')[0].click(); + (node).getElementsByTagName("a")[0].click(); }); }); - describe("t-ref", () => { test("can get a ref on a node", () => { const qweb = new QWeb(); qweb.addTemplate("test", `
`); let refs: any = {}; - renderToDOM(qweb, "test", { refs}); - expect(refs.myspan.tagName).toBe('SPAN'); + renderToDOM(qweb, "test", { refs }); + expect(refs.myspan.tagName).toBe("SPAN"); }); }); diff --git a/web/static/tests/widget.test.ts b/web/static/tests/widget.test.ts index d35557fe..d1d447ba 100644 --- a/web/static/tests/widget.test.ts +++ b/web/static/tests/widget.test.ts @@ -1,17 +1,16 @@ -import Widget, {WEnv} from "../src/ts/core/widget"; +import Widget, { WEnv } from "../src/ts/core/widget"; import QWeb from "../src/ts/core/qweb_vdom"; - interface Type extends Function { new (...args: any[]): T; } type TestEnv = WEnv; -type TestWidget = Widget +type TestWidget = Widget; function makeWidget(W: Type): TestWidget { const env = { - qweb: new QWeb(), + qweb: new QWeb() }; const w = new W(env); return w; @@ -120,7 +119,7 @@ describe("lifecycle hooks", () => { let parentMounted = false; let childMounted = false; class ParentWidget extends Widget { - name="a"; + name = "a"; template = `
Hello
`; widgets = { child: ChildWidget }; async mounted() {