diff --git a/awesome_owl/controllers/controllers.py b/awesome_owl/controllers/controllers.py index bccfd6fe283..aeac8137f0e 100644 --- a/awesome_owl/controllers/controllers.py +++ b/awesome_owl/controllers/controllers.py @@ -8,3 +8,10 @@ def show_playground(self): Renders the owl playground page """ return request.render('awesome_owl.playground') + + @http.route(['/counter'], type='http', auth='public') + def show_Counter(self): + """ + Renders the owl playground page + """ + return request.render('awesome_owl.counter') diff --git a/awesome_owl/static/src/counter.js b/awesome_owl/static/src/counter.js new file mode 100644 index 00000000000..91a799af6e1 --- /dev/null +++ b/awesome_owl/static/src/counter.js @@ -0,0 +1,25 @@ +import { Component, useState } from "@odoo/owl"; + +export class Counter extends Component { + static template = "awesome_owl.counter"; + + setup() { + this.state = useState({ value: 0 , sum: 0}); + this.newstate = useState({ newval: 1 }); + + } + + increment() { + this.state.value++; + console.log(this.state.value); + } + + multiple() { + this.newstate.newval = this.newstate.newval*2; + console.log(this.newstate.newval); + } + + sum() { + this.state.sum = this.state.value + this.newstate.newval + } +} diff --git a/awesome_owl/static/src/counter.xml b/awesome_owl/static/src/counter.xml new file mode 100644 index 00000000000..da013f0a870 --- /dev/null +++ b/awesome_owl/static/src/counter.xml @@ -0,0 +1,11 @@ + + + +

SUM:

+

Counter:


+

Multiplex2:

+ + + +
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..46a7d966607 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,7 @@ import { Component } from "@odoo/owl"; +import { Counter } from "./counter"; export class Playground extends Component { static template = "awesome_owl.playground"; + static components = { Counter } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..878b4e66460 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -2,9 +2,13 @@ -
+
hello world +
+
+
+ diff --git a/awesome_owl/views/templates.xml b/awesome_owl/views/templates.xml index aa54c1a7241..dd2ded73fac 100644 --- a/awesome_owl/views/templates.xml +++ b/awesome_owl/views/templates.xml @@ -3,6 +3,11 @@