[FIX] examples: adapt todoapp to new owl structure

This commit is contained in:
Géry Debongnie
2019-04-16 17:17:44 +02:00
parent a22dcdaddf
commit e5e6c50fff
4 changed files with 4 additions and 5 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
import { TodoItem } from "./TodoItem.js"; import { TodoItem } from "./TodoItem.js";
const { Component } = owl.core; const { Component, connect } = owl;
const { connect } = owl.extras;
const ENTER_KEY = 13; const ENTER_KEY = 13;
+1 -1
View File
@@ -1,7 +1,7 @@
const ENTER_KEY = 13; const ENTER_KEY = 13;
const ESC_KEY = 27; const ESC_KEY = 27;
export class TodoItem extends owl.core.Component { export class TodoItem extends owl.Component {
template = "todoitem"; template = "todoitem";
state = { isEditing: false }; state = { isEditing: false };
+1 -1
View File
@@ -8,7 +8,7 @@ async function makeEnv() {
} }
let templates = await result.text(); let templates = await result.text();
templates = templates.replace(/<!--[\s\S]*?-->/g, ""); templates = templates.replace(/<!--[\s\S]*?-->/g, "");
const qweb = new owl.core.QWeb(); const qweb = new owl.QWeb();
qweb.loadTemplates(templates); qweb.loadTemplates(templates);
return { return {
qweb, qweb,
+1 -1
View File
@@ -66,7 +66,7 @@ export function makeStore() {
); );
const nextId = Math.max(0, ...todos.map(t => t.id || 0)) + 1; const nextId = Math.max(0, ...todos.map(t => t.id || 0)) + 1;
const state = { todos, nextId }; const state = { todos, nextId };
const store = new owl.extras.Store({ state, actions, mutations }); const store = new owl.Store({ state, actions, mutations });
store.on("update", null, () => { store.on("update", null, () => {
const state = JSON.stringify(store.state.todos); const state = JSON.stringify(store.state.todos);
window.localStorage.setItem(LOCALSTORAGE_KEY, state); window.localStorage.setItem(LOCALSTORAGE_KEY, state);