mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
linting
This commit is contained in:
+2
-1
@@ -13,4 +13,5 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
.vscode
|
||||||
@@ -1,56 +1,54 @@
|
|||||||
$navbar-height: 40px;
|
$navbar-height: 40px;
|
||||||
$main-color: #875A7B;
|
$main-color: #875a7b;
|
||||||
|
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Web Client */
|
/* Web Client */
|
||||||
.o_web_client {
|
.o_web_client {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: $navbar-height auto;
|
grid-template-rows: $navbar-height auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Navbar */
|
/* Navbar */
|
||||||
.o_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;
|
color: white;
|
||||||
display: flex;
|
text-decoration: none;
|
||||||
line-height: $navbar-height;
|
padding: 0 5px;
|
||||||
|
}
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -649,7 +649,7 @@ const onDirective: Directive = {
|
|||||||
});
|
});
|
||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(context${
|
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(context${
|
||||||
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
|
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
|
||||||
})}`
|
})}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ export function escape(str: string | number | undefined): string {
|
|||||||
*/
|
*/
|
||||||
export function htmlTrim(s: string): string {
|
export function htmlTrim(s: string): string {
|
||||||
let result = s.replace(/(^\s+|\s+$)/g, "");
|
let result = s.replace(/(^\s+|\s+$)/g, "");
|
||||||
if (s[0] === ' ') {
|
if (s[0] === " ") {
|
||||||
result = ' ' + result;
|
result = " " + result;
|
||||||
}
|
}
|
||||||
if (result !== ' ' && s[s.length - 1] === ' ') {
|
if (result !== " " && s[s.length - 1] === " ") {
|
||||||
result = result + ' ';
|
result = result + " ";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,3 @@ export function makeEnvironment(): Env {
|
|||||||
actions
|
actions
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
///<amd-module name="main" />
|
///<amd-module name="main" />
|
||||||
|
|
||||||
import RootWidget from "./widgets/root_widget";
|
import RootWidget from "./widgets/root_widget";
|
||||||
import {makeEnvironment} from "./env";
|
import { makeEnvironment } from "./env";
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async function() {
|
document.addEventListener("DOMContentLoaded", async function() {
|
||||||
const env = makeEnvironment();
|
const env = makeEnvironment();
|
||||||
|
|||||||
@@ -12,13 +12,11 @@ import { Action } from "./actions";
|
|||||||
// { id: 2, title: "CRM", Widget: CRM }
|
// { id: 2, title: "CRM", Widget: CRM }
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default class ActionManager {
|
export default class ActionManager {
|
||||||
doAction(action: Action) {
|
doAction(action: Action) {
|
||||||
console.log(action);
|
console.log(action);
|
||||||
// load data (??)
|
// load data (??)
|
||||||
// trigger action somewhere
|
// trigger action somewhere
|
||||||
// upload url with router
|
// upload url with router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
|
export default class Ajax {}
|
||||||
export default class Ajax{}
|
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ export default class Router {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
window.addEventListener("popstate", this.onUrlChange.bind(this));
|
window.addEventListener("popstate", this.onUrlChange.bind(this));
|
||||||
window.onhashchange = function () { console.log('aaaa'); debugger; }
|
window.onhashchange = function() {
|
||||||
|
console.log("aaaa");
|
||||||
|
debugger;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onUrlChange(event: PopStateEvent) {
|
onUrlChange(event: PopStateEvent) {
|
||||||
debugger
|
debugger;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const info = this.getRoute();
|
const info = this.getRoute();
|
||||||
for (let listener of this.listeners) {
|
for (let listener of this.listeners) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default class Counter extends Widget<Env> {
|
|||||||
counter: 0
|
counter: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(parent: Widget<Env>, props: {initialState?: number}) {
|
constructor(parent: Widget<Env>, props: { initialState?: number }) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.state.counter = props.initialState || 0;
|
this.state.counter = props.initialState || 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { init } from "../libs/snabbdom/src/snabbdom";
|
||||||
import sdAttributes from "../libs/snabbdom/src/modules/attributes";
|
import sdAttributes from "../libs/snabbdom/src/modules/attributes";
|
||||||
import sdListeners from "../libs/snabbdom/src/modules/eventlisteners";
|
import sdListeners from "../libs/snabbdom/src/modules/eventlisteners";
|
||||||
@@ -551,13 +551,18 @@ describe("foreach", () => {
|
|||||||
|
|
||||||
test("iterate, dict param", () => {
|
test("iterate, dict param", () => {
|
||||||
const qweb = new QWeb();
|
const qweb = new QWeb();
|
||||||
qweb.addTemplate('test',`
|
qweb.addTemplate(
|
||||||
|
"test",
|
||||||
|
`
|
||||||
<div>
|
<div>
|
||||||
<t t-foreach="value" t-as="item">
|
<t t-foreach="value" t-as="item">
|
||||||
[<t t-esc="item_index"/>: <t t-esc="item"/> <t t-esc="item_value"/> - <t t-esc="item_parity"/>]
|
[<t t-esc="item_index"/>: <t t-esc="item"/> <t t-esc="item_value"/> - <t t-esc="item_parity"/>]
|
||||||
</t>
|
</t>
|
||||||
</div>`);
|
</div>`
|
||||||
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 = `<div>[0:a1-even][1:b2-odd][2:c3-even]</div>`;
|
const expected = `<div>[0:a1-even][1:b2-odd][2:c3-even]</div>`;
|
||||||
expect(result).toBe(expected);
|
expect(result).toBe(expected);
|
||||||
});
|
});
|
||||||
@@ -594,7 +599,7 @@ describe("misc", () => {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
const result = trim(renderToString(qweb, "caller"))
|
const result = trim(renderToString(qweb, "caller"));
|
||||||
const expected = trim(`
|
const expected = trim(`
|
||||||
<div>
|
<div>
|
||||||
<span>4</span>
|
<span>4</span>
|
||||||
@@ -655,26 +660,28 @@ describe("t-on", () => {
|
|||||||
test("can bind handlers with loop variable as argument", () => {
|
test("can bind handlers with loop variable as argument", () => {
|
||||||
expect.assertions(1);
|
expect.assertions(1);
|
||||||
const qweb = new QWeb();
|
const qweb = new QWeb();
|
||||||
qweb.addTemplate("test", `
|
qweb.addTemplate(
|
||||||
|
"test",
|
||||||
|
`
|
||||||
<ul>
|
<ul>
|
||||||
<li t-foreach="['someval']" t-as="action"><a t-on-click="activate(action)">link</a></li>
|
<li t-foreach="['someval']" t-as="action"><a t-on-click="activate(action)">link</a></li>
|
||||||
</ul>`);
|
</ul>`
|
||||||
|
);
|
||||||
const node = renderToDOM(qweb, "test", {
|
const node = renderToDOM(qweb, "test", {
|
||||||
activate(action) {
|
activate(action) {
|
||||||
expect(action).toBe('someval');
|
expect(action).toBe("someval");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
(<HTMLElement>node).getElementsByTagName('a')[0].click();
|
(<HTMLElement>node).getElementsByTagName("a")[0].click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("t-ref", () => {
|
describe("t-ref", () => {
|
||||||
test("can get a ref on a node", () => {
|
test("can get a ref on a node", () => {
|
||||||
const qweb = new QWeb();
|
const qweb = new QWeb();
|
||||||
qweb.addTemplate("test", `<div><span t-ref="myspan"/></div>`);
|
qweb.addTemplate("test", `<div><span t-ref="myspan"/></div>`);
|
||||||
let refs: any = {};
|
let refs: any = {};
|
||||||
renderToDOM(qweb, "test", { refs});
|
renderToDOM(qweb, "test", { refs });
|
||||||
expect(refs.myspan.tagName).toBe('SPAN');
|
expect(refs.myspan.tagName).toBe("SPAN");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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";
|
import QWeb from "../src/ts/core/qweb_vdom";
|
||||||
|
|
||||||
|
|
||||||
interface Type<T> extends Function {
|
interface Type<T> extends Function {
|
||||||
new (...args: any[]): T;
|
new (...args: any[]): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestEnv = WEnv;
|
type TestEnv = WEnv;
|
||||||
type TestWidget = Widget<TestEnv>
|
type TestWidget = Widget<TestEnv>;
|
||||||
|
|
||||||
function makeWidget(W: Type<TestWidget>): TestWidget {
|
function makeWidget(W: Type<TestWidget>): TestWidget {
|
||||||
const env = {
|
const env = {
|
||||||
qweb: new QWeb(),
|
qweb: new QWeb()
|
||||||
};
|
};
|
||||||
const w = new W(env);
|
const w = new W(env);
|
||||||
return w;
|
return w;
|
||||||
@@ -120,7 +119,7 @@ describe("lifecycle hooks", () => {
|
|||||||
let parentMounted = false;
|
let parentMounted = false;
|
||||||
let childMounted = false;
|
let childMounted = false;
|
||||||
class ParentWidget extends Widget<TestEnv> {
|
class ParentWidget extends Widget<TestEnv> {
|
||||||
name="a";
|
name = "a";
|
||||||
template = `<div>Hello<t t-widget="child"/></div>`;
|
template = `<div>Hello<t t-widget="child"/></div>`;
|
||||||
widgets = { child: ChildWidget };
|
widgets = { child: ChildWidget };
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
|||||||
Reference in New Issue
Block a user