diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..ff5300ef481 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.languageServer": "None" +} \ No newline at end of file diff --git a/awesome_tshirt/static/src/card/card.js b/awesome_tshirt/static/src/card/card.js new file mode 100644 index 00000000000..f83a0e779a9 --- /dev/null +++ b/awesome_tshirt/static/src/card/card.js @@ -0,0 +1,16 @@ +/** @odoo-module */ + +const { Component } = owl; + +export class Card extends Component {} + +Card.template = "awesome_tshirt.Card"; +Card.props = { + slots: { + type: Object, + shape: { + default: Object, + title: { type: Object, optional: true }, + }, + }, +}; \ No newline at end of file diff --git a/awesome_tshirt/static/src/card/card.xml b/awesome_tshirt/static/src/card/card.xml new file mode 100644 index 00000000000..3ed89946930 --- /dev/null +++ b/awesome_tshirt/static/src/card/card.xml @@ -0,0 +1,14 @@ + + + + +
+
+ +
+
+

+
+
+
+
\ No newline at end of file diff --git a/awesome_tshirt/static/src/dashboard.js b/awesome_tshirt/static/src/dashboard.js index ee1c7728e48..cceb72ea1a0 100644 --- a/awesome_tshirt/static/src/dashboard.js +++ b/awesome_tshirt/static/src/dashboard.js @@ -1,11 +1,42 @@ /** @odoo-module **/ - -import { Component } from "@odoo/owl"; +import { Component,useSubEnv, onWillStart } from "@odoo/owl"; import { registry } from "@web/core/registry"; +import { Layout } from "@web/search/layout"; +import {getDefaultConfig} from "@web/views/view"; +import {useService} from "@web/core/utils/hooks"; +import { Card } from "./card/card"; + +class AwesomeDashboard extends Component { + setup() { + useSubEnv({ + config: { + ...getDefaultConfig(), + ...this.env.config, + }, + }); + this.display = { + controlPanel: { "top-right": false, "bottom-right": false }, + }; + this.action = useService("action"); + this.rpc = useService("rpc"); -class AwesomeDashboard extends Component {} + this.keyToString = { + average_quantity: "Average amount of t-shirt by order this month", + average_time: "Average time for an order to go from 'new' to 'sent' or 'cancelled'", + nb_cancelled_orders: "Number of cancelled orders this month", + nb_new_orders: "Number of new orders this month", + total_amount: "Total amount of new orders this month", + }; + onWillStart(async () => { + this.statistics = await this.rpc("/awesome_tshirt/statistics"); + }); + } -AwesomeDashboard.components = {}; + openCustomerView() { + this.action.doAction("base.action_partner_form"); + } +} +AwesomeDashboard.components = { Layout, Card }; AwesomeDashboard.template = "awesome_tshirt.clientaction"; registry.category("actions").add("awesome_tshirt.dashboard", AwesomeDashboard); diff --git a/awesome_tshirt/static/src/dashboard.xml b/awesome_tshirt/static/src/dashboard.xml index b3dce0b6261..ca6012aba13 100644 --- a/awesome_tshirt/static/src/dashboard.xml +++ b/awesome_tshirt/static/src/dashboard.xml @@ -1,8 +1,25 @@ - + + + + + + + + + +
+
+ + +

+
+
+
+
-
+ \ No newline at end of file diff --git a/awesome_tshirt/static/src/image_preview_field/image_preview_field.js b/awesome_tshirt/static/src/image_preview_field/image_preview_field.js new file mode 100644 index 00000000000..6ed863fa32c --- /dev/null +++ b/awesome_tshirt/static/src/image_preview_field/image_preview_field.js @@ -0,0 +1,14 @@ +/** @odoo-module */ + +import { registry } from "@web/core/registry"; +import { CharField } from "@web/views/fields/char/char_field"; + +const { Component } = owl; + +class ImagePreviewField extends Component {} + +ImagePreviewField.template = "awesome_tshirt.ImagePreviewField"; +ImagePreviewField.components = { CharField }; +ImagePreviewField.supportedTypes = ["char"]; + +registry.category("fields").add("image_preview", ImagePreviewField); \ No newline at end of file diff --git a/awesome_tshirt/static/src/image_preview_field/image_preview_field.xml b/awesome_tshirt/static/src/image_preview_field/image_preview_field.xml new file mode 100644 index 00000000000..858a79558b8 --- /dev/null +++ b/awesome_tshirt/static/src/image_preview_field/image_preview_field.xml @@ -0,0 +1,10 @@ + + + + + +

MISSING TSHIRT DESIGN

+
+ +
+
\ No newline at end of file diff --git a/awesome_tshirt/views/views.xml b/awesome_tshirt/views/views.xml index 292a4811325..d7b42842ffa 100644 --- a/awesome_tshirt/views/views.xml +++ b/awesome_tshirt/views/views.xml @@ -22,7 +22,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/owl_playground/static/src/card/card.js b/owl_playground/static/src/card/card.js new file mode 100644 index 00000000000..969204a7087 --- /dev/null +++ b/owl_playground/static/src/card/card.js @@ -0,0 +1,16 @@ +/** @odoo-module **/ + +import { Component } from "@odoo/owl"; +export class Card extends Component { + + static template = "owl_playground.card" + static props = { + slots: { + type: Object, + shape: { + title: { type: Object, optional: true }, + default: Object + }, + }, + }; +} \ No newline at end of file diff --git a/owl_playground/static/src/card/card.xml b/owl_playground/static/src/card/card.xml new file mode 100644 index 00000000000..9a9145efe5a --- /dev/null +++ b/owl_playground/static/src/card/card.xml @@ -0,0 +1,17 @@ + + + + +
+
+
+ +
+
+

+ +
+
+
+
+
\ No newline at end of file diff --git a/owl_playground/static/src/counter/counter.js b/owl_playground/static/src/counter/counter.js new file mode 100644 index 00000000000..de082e907bd --- /dev/null +++ b/owl_playground/static/src/counter/counter.js @@ -0,0 +1,19 @@ +/** @odoo-module **/ + +import { Component, useState } from "@odoo/owl"; + +export class Counter extends Component { + static template = "owl_playground.counter"; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + } + restart() { + this.state.value = 0; + } +} + diff --git a/owl_playground/static/src/counter/counter.xml b/owl_playground/static/src/counter/counter.xml new file mode 100644 index 00000000000..2436f3dc428 --- /dev/null +++ b/owl_playground/static/src/counter/counter.xml @@ -0,0 +1,12 @@ + + + + +
+

Counter:

+ + +
+
+ +
\ No newline at end of file diff --git a/owl_playground/static/src/playground.js b/owl_playground/static/src/playground.js index 97dbc86e580..86edb132a90 100644 --- a/owl_playground/static/src/playground.js +++ b/owl_playground/static/src/playground.js @@ -1,7 +1,16 @@ /** @odoo-module **/ -import { Component } from "@odoo/owl"; - +import { Component, useState } from "@odoo/owl"; +import { Counter } from "./counter/counter"; +import { Todo } from "./todo/todo"; +import {Todolist} from "./todolist/todolist"; +import { Card } from "./card/card"; export class Playground extends Component { + static components = { Counter,Todo,Todolist,Card }; static template = "owl_playground.playground"; + + setup() { + this.todo = { id: 3, description: "buy milk", done: true }; + } } + diff --git a/owl_playground/static/src/playground.xml b/owl_playground/static/src/playground.xml index 75ce13a2c1e..f95da3d4e24 100644 --- a/owl_playground/static/src/playground.xml +++ b/owl_playground/static/src/playground.xml @@ -1,10 +1,17 @@ + -
- hello world +
+ +
+
+ - - + \ No newline at end of file diff --git a/owl_playground/static/src/todo/todo.js b/owl_playground/static/src/todo/todo.js new file mode 100644 index 00000000000..1b8cf89c677 --- /dev/null +++ b/owl_playground/static/src/todo/todo.js @@ -0,0 +1,15 @@ +/** @odoo-module **/ + +import { Component } from "@odoo/owl"; + +export class Todo extends Component { + static template = "owl_playground.todo"; +} +Todo.props = { + id: {type:Number}, + description: {type:String}, + done: {type:Boolean}, + toggleState: { type:Function }, + removeTodo: { type:Function }, +}; + diff --git a/owl_playground/static/src/todo/todo.xml b/owl_playground/static/src/todo/todo.xml new file mode 100644 index 00000000000..cc6b45ab308 --- /dev/null +++ b/owl_playground/static/src/todo/todo.xml @@ -0,0 +1,12 @@ + + + + +

+ + . + + +

+
+
\ No newline at end of file diff --git a/owl_playground/static/src/todolist/todolist.js b/owl_playground/static/src/todolist/todolist.js new file mode 100644 index 00000000000..40c6f089dd6 --- /dev/null +++ b/owl_playground/static/src/todolist/todolist.js @@ -0,0 +1,45 @@ +/** @odoo-module **/ + +import { Component, useState } from "@odoo/owl"; +import { Todo } from "../todo/todo"; +import { useAutofocus } from "../utils"; + + +export class Todolist extends Component { + static components = { Todo }; + static template = "owl_playground.todolist"; + + setup() { + this.todoList = []; + this.todoList = useState([{ id: 1, description: "Task 1", done: false },{ id: 2, description: "Task 2", done: false },{ id: 3, description: "Task 3", done: false }]); + this.nextId = this.todoList.length+1; + this.inputred = useAutofocus("inputElement"); + } + + addTodo(ev) { + if(ev.keyCode === 13){ + if (ev.target.value.trim() != "") { + this.todoList.push({ id: this.nextId++, description: ev.target.value, done: false }); + } + ev.target.value = ""; + } + } + + toggleState(todoId) { + + const todo = this.todoList.find((todo) => todo.id === todoId); + if (todo) { + todo.done = !todo.done; + } + } + removeTodo(todoId) { + const index = this.todoList.findIndex((todo) => todo.id === todoId); + if (index >= 0) { + this.todoList.splice(index, 1); + } + } + + resetList(){ + this.todoList.splice(0); + } +} diff --git a/owl_playground/static/src/todolist/todolist.xml b/owl_playground/static/src/todolist/todolist.xml new file mode 100644 index 00000000000..6d9b7124363 --- /dev/null +++ b/owl_playground/static/src/todolist/todolist.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/owl_playground/static/src/utils.js b/owl_playground/static/src/utils.js new file mode 100644 index 00000000000..5dd3e515126 --- /dev/null +++ b/owl_playground/static/src/utils.js @@ -0,0 +1,9 @@ +/** @odoo-module **/ + + +import { onMounted, useRef } from "@odoo/owl"; + +export function useAutofocus(Input) { + const inputRef = useRef(Input); + onMounted(() => inputRef.el.focus()); +} \ No newline at end of file diff --git a/owl_playground/views/templates.xml b/owl_playground/views/templates.xml index e3ccdda4b99..31b1f7b9318 100644 --- a/owl_playground/views/templates.xml +++ b/owl_playground/views/templates.xml @@ -1,6 +1,6 @@ -