-
Notifications
You must be signed in to change notification settings - Fork 2k
[IMP] awesome_owl: add counter component as sub component to playground #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Conversation
@msho-odoo |
0a27663
to
1d61c05
Compare
And for the XML files as well :) |
108f182
to
c387d41
Compare
awesome_owl/static/src/todoitem.xml
Outdated
@@ -2,6 +2,7 @@ | |||
<templates xml:space="preserve"> | |||
|
|||
<t t-name="awesome_owl.todoitem"> | |||
<input type="checkbox" t-on-change="()=> props.onToggleState(props.todo.id)"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<input type="checkbox" t-on-change="()=> props.onToggleState(props.todo.id)"/> | |
<input type="checkbox" t-on-change="() => props.onToggleState(props.todo.id)"/> |
awesome_owl/static/src/todolist.js
Outdated
@@ -23,4 +23,9 @@ export class TodoList extends Component { | |||
ev.target.value = ""; | |||
} | |||
}; | |||
|
|||
toggleState(todoId) { | |||
let todo = this.state.todos.find(todo => todo.id === todoId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let todo = this.state.todos.find(todo => todo.id === todoId); | |
const todo = this.state.todos.find(todo => todo.id === todoId); |
awesome_owl/static/src/todolist.xml
Outdated
@@ -7,7 +7,7 @@ | |||
<t t-foreach="state.todos" t-as="i" t-key="i.id"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention: foreach -> plural, t-as -> singular.
<t t-foreach="state.todos" t-as="i" t-key="i.id"> | |
<t t-foreach="state.todos" t-as="todo" t-key="todo.id"> |
awesome_owl/static/src/todolist.xml
Outdated
@@ -7,7 +7,7 @@ | |||
<t t-foreach="state.todos" t-as="i" t-key="i.id"> | |||
<div style="border: 1px solid black"> | |||
<div t-att-class="{'text-muted': i.isCompleted, 'text-decoration-line-through': i.isCompleted}"> | |||
<TodoItem todo= "i"/> | |||
<TodoItem todo= "i" onToggleState.bind="toggleState"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<TodoItem todo= "i" onToggleState.bind="toggleState"/> | |
<TodoItem todo="todo" onToggleState.bind="toggleState"/> |
awesome_owl/static/src/todoitem.xml
Outdated
@@ -2,6 +2,7 @@ | |||
<templates xml:space="preserve"> | |||
|
|||
<t t-name="awesome_owl.todoitem"> | |||
<input type="checkbox" t-on-change="()=> props.onToggleState(props.todo.id)"/> | |||
<t t-out="props.todo.id+'. '+props.todo.description"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<t t-out="props.todo.id+'. '+props.todo.description"/> | |
<t t-out="props.todo.id + '. ' + props.todo.description"/> |
awesome_owl/static/src/todolist.js
Outdated
@@ -28,4 +28,11 @@ export class TodoList extends Component { | |||
let todo = this.state.todos.find(todo => todo.id === todoId); | |||
todo.isCompleted = !todo.isCompleted; | |||
} | |||
|
|||
removeTodo(todoId) { | |||
let index = this.state.todos.findIndex(todo => todo.id === todoId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const :)
c1b4817
to
383d906
Compare
@SergeBayet |
awesome_owl/static/src/todolist.js
Outdated
if (ev.keyCode === 13) { | ||
this.state.idCounter++ | ||
this.state.todos.push({ | ||
'id': this.state.idCounter, 'description': ev.target.value, 'isCompleted': false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double quotes :)
awesome_owl/static/src/todolist.js
Outdated
setup() { | ||
this.state = useState({ | ||
todos: [], | ||
idCounter: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idCounter: 0 | |
idCounter: 0, |
name: ('Leads'), | ||
target: 'current', | ||
res_model: 'crm.lead', | ||
views: [[false, 'list'], [false, 'form']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double quotes :)
|
||
class AwesomeDashboard extends Component { | ||
static template = "awesome_dashboard.AwesomeDashboard"; | ||
static components = { Layout } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static components = { Layout } | |
static components = { Layout }; |
|
||
class AwesomeDashboard extends Component { | ||
static template = "awesome_dashboard.AwesomeDashboard"; | ||
static components = { Layout } | ||
static components = { Layout, DashboardItem } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget the semi-colon :)
static components = { Layout, DashboardItem } | |
static components = { Layout, DashboardItem }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I pushed and then saw the review, the update is on the way :)
7952511
to
d91de1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! ;)
<t t-esc="props.title"/> | ||
<button style="border:0.5px solid purple;" class="btn btn-primary" t-on-click="toggleState">Hide/Show</button> | ||
</h5> | ||
<p class="card-text" t-if="state.isOpen"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better practice to have t-if
first
<p class="card-text" t-if="state.isOpen"> | |
<p t-if="state.isOpen" class="card-text"> |
@@ -0,0 +1,12 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<templates xml:space="preserve"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
<templates xml:space="preserve"> | |
<templates> |
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.counter"> | ||
<div style="border:1px solid black; width: 10rem;">Hello World |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline styles are not encouraged. You may either use Bootstrap classes directly or create your custom classes and use them.
@@ -0,0 +1,12 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed as this xml is parsed by either Owl or Qweb which already use UTF-8
<?xml version="1.0" encoding="UTF-8" ?> | |
<?xml version="1.0" ?> |
No description provided.