[IMP] owl: update to v0.23.0

This commit is contained in:
Géry Debongnie
2019-10-18 16:03:25 +02:00
parent 1571a16cfd
commit d6e0a9dcba
3 changed files with 24 additions and 30 deletions
+5 -5
View File
@@ -1195,7 +1195,7 @@
* *
* - whenReady * - whenReady
* - loadJS * - loadJS
* - loadTemplates * - loadFile
* - escape * - escape
* - debounce * - debounce
*/ */
@@ -1230,7 +1230,7 @@
loadedScripts[url] = promise; loadedScripts[url] = promise;
return promise; return promise;
} }
async function loadTemplates(url) { async function loadFile(url) {
const result = await fetch(url); const result = await fetch(url);
if (!result.ok) { if (!result.ok) {
throw new Error("Error while fetching xml templates"); throw new Error("Error while fetching xml templates");
@@ -1290,7 +1290,7 @@
var _utils = /*#__PURE__*/Object.freeze({ var _utils = /*#__PURE__*/Object.freeze({
whenReady: whenReady, whenReady: whenReady,
loadJS: loadJS, loadJS: loadJS,
loadTemplates: loadTemplates, loadFile: loadFile,
escape: escape, escape: escape,
debounce: debounce, debounce: debounce,
shallowEqual: shallowEqual shallowEqual: shallowEqual
@@ -4319,8 +4319,8 @@
exports.utils = utils; exports.utils = utils;
exports.__info__.version = '0.23.0'; exports.__info__.version = '0.23.0';
exports.__info__.date = '2019-10-16T20:31:22.370Z'; exports.__info__.date = '2019-10-18T14:02:51.841Z';
exports.__info__.hash = '9e65b06'; exports.__info__.hash = '1bb4577';
exports.__info__.url = 'https://github.com/odoo/owl'; exports.__info__.url = 'https://github.com/odoo/owl';
}(this.owl = this.owl || {})); }(this.owl = this.owl || {}));
+2 -2
View File
@@ -127,7 +127,7 @@ async function makeApp(js, css, xml) {
const JS = ` const JS = `
async function loadTemplates() { async function loadTemplates() {
try { try {
return owl.utils.loadTemplates('app.xml'); return owl.utils.loadFile('app.xml');
} catch(e) { } catch(e) {
console.error(\`This app requires a static server. If you have python installed, try 'python app.py'\`); console.error(\`This app requires a static server. If you have python installed, try 'python app.py'\`);
} }
@@ -430,7 +430,7 @@ App.components = { TabbedEditor };
async function start() { async function start() {
document.title = `${document.title} (v${owl.__info__.version})`; document.title = `${document.title} (v${owl.__info__.version})`;
const [templates] = await Promise.all([ const [templates] = await Promise.all([
owl.utils.loadTemplates("templates.xml"), owl.utils.loadFile("templates.xml"),
owl.utils.whenReady() owl.utils.whenReady()
]); ]);
const qweb = new owl.QWeb(templates); const qweb = new owl.QWeb(templates);
+17 -23
View File
@@ -11,9 +11,9 @@ class Greeter extends Component {
// Main root component // Main root component
class App extends Component { class App extends Component {
static components = { Greeter };
state = useState({ name: 'World'}); state = useState({ name: 'World'});
} }
App.components = { Greeter };
// Application setup // Application setup
// Note that the xml templates are injected into the global TEMPLATES variable. // Note that the xml templates are injected into the global TEMPLATES variable.
@@ -58,7 +58,6 @@ class Counter extends Component {
class App extends Component { class App extends Component {
state = useState({ flag: false, componentFlag: false, numbers: [] }); state = useState({ flag: false, componentFlag: false, numbers: [] });
static components = { Counter };
toggle(key) { toggle(key) {
this.state[key] = !this.state[key]; this.state[key] = !this.state[key];
@@ -68,8 +67,8 @@ class App extends Component {
const n = this.state.numbers.length + 1; const n = this.state.numbers.length + 1;
this.state.numbers.push(n); this.state.numbers.push(n);
} }
} }
App.components = { Counter };
const qweb = new owl.QWeb(TEMPLATES); const qweb = new owl.QWeb(TEMPLATES);
const app = new App({qweb}); const app = new App({qweb});
@@ -217,7 +216,6 @@ class DemoComponent extends Component {
} }
class App extends Component { class App extends Component {
static components = { DemoComponent };
state = useState({ n: 0, flag: true }); state = useState({ n: 0, flag: true });
increment() { increment() {
@@ -228,6 +226,7 @@ class App extends Component {
this.state.flag = !this.state.flag; this.state.flag = !this.state.flag;
} }
} }
App.components = { DemoComponent };
const qweb = new owl.QWeb(TEMPLATES); const qweb = new owl.QWeb(TEMPLATES);
const app = new App({ qweb }); const app = new App({ qweb });
@@ -332,20 +331,18 @@ class ToolbarButton extends Component {
} }
} }
class Toolbar extends Component { class Toolbar extends Component {}
static components = { ToolbarButton }; Toolbar.components = { ToolbarButton };
}
// Main root component // Main root component
class App extends Component { class App extends Component {
static components = { Toolbar };
toggleTheme() { toggleTheme() {
const { background, foreground } = this.env.themeContext.state; const { background, foreground } = this.env.themeContext.state;
this.env.themeContext.state.background = foreground; this.env.themeContext.state.background = foreground;
this.env.themeContext.state.foreground = background; this.env.themeContext.state.foreground = background;
} }
} }
App.components = { Toolbar };
// Application setup // Application setup
const themeContext = new Context({ const themeContext = new Context({
@@ -497,7 +494,6 @@ class TodoItem extends Component {
// TodoApp // TodoApp
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
class TodoApp extends Component { class TodoApp extends Component {
static components = { TodoItem };
state = useState({ filter: "all" }); state = useState({ filter: "all" });
todos = useStore(state => state.todos); todos = useStore(state => state.todos);
dispatch = useDispatch(); dispatch = useDispatch();
@@ -537,6 +533,7 @@ class TodoApp extends Component {
this.state.filter = filter; this.state.filter = filter;
} }
} }
TodoApp.components = { TodoItem };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// App Initialization // App Initialization
@@ -1014,23 +1011,20 @@ class Navbar extends owl.Component {}
class MobileSearchView extends owl.Component {} class MobileSearchView extends owl.Component {}
class ControlPanel extends owl.Component { class ControlPanel extends owl.Component {}
static components = { MobileSearchView }; ControlPanel.components = { MobileSearchView };
}
class AdvancedComponent extends owl.Component {} class AdvancedComponent extends owl.Component {}
class FormView extends owl.Component { class FormView extends owl.Component {}
static components = { AdvancedComponent }; FormView.components = { AdvancedComponent };
}
class Chatter extends owl.Component { class Chatter extends owl.Component {
messages = Array.from(Array(100).keys()); messages = Array.from(Array(100).keys());
} }
class App extends owl.Component { class App extends owl.Component {}
static components = { Navbar, ControlPanel, FormView, Chatter }; App.components = { Navbar, ControlPanel, FormView, Chatter };
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Responsive plugin // Responsive plugin
@@ -1188,13 +1182,13 @@ class Counter extends Component {
// Main root component // Main root component
class App extends Component { class App extends Component {
static components = {Card, Counter};
state = useState({a: 1, b: 3}); state = useState({a: 1, b: 3});
inc(key, delta) { inc(key, delta) {
this.state[key] += delta; this.state[key] += delta;
} }
} }
App.components = {Card, Counter};
// Application setup // Application setup
const qweb = new owl.QWeb(TEMPLATES); const qweb = new owl.QWeb(TEMPLATES);
@@ -1298,7 +1292,6 @@ class SlowComponent extends Component {
class NotificationList extends Component {} class NotificationList extends Component {}
class App extends Component { class App extends Component {
static components = {SlowComponent, NotificationList};
state = useState({ value: 0, notifs: [] }); state = useState({ value: 0, notifs: [] });
increment() { increment() {
@@ -1311,6 +1304,7 @@ class App extends Component {
}, 3000); }, 3000);
} }
} }
App.components = {SlowComponent, NotificationList};
const qweb = new owl.QWeb(TEMPLATES); const qweb = new owl.QWeb(TEMPLATES);
const app = new App({ qweb }); const app = new App({ qweb });
@@ -1492,7 +1486,6 @@ class Window extends Component {
} }
class WindowManager extends Component { class WindowManager extends Component {
static components = { Window };
windows = []; windows = [];
nextId = 1; nextId = 1;
currentZindex = 1; currentZindex = 1;
@@ -1538,15 +1531,16 @@ class WindowManager extends Component {
ev.target.style["z-index"] = w.zindex; ev.target.style["z-index"] = w.zindex;
} }
} }
WindowManager.components = { Window };
class App extends Component { class App extends Component {
static components = { WindowManager };
wmRef = useRef("wm"); wmRef = useRef("wm");
addWindow(name) { addWindow(name) {
this.wmRef.comp.addWindow(name); this.wmRef.comp.addWindow(name);
} }
} }
App.components = { WindowManager };
const qweb = new owl.QWeb(TEMPLATES); const qweb = new owl.QWeb(TEMPLATES);
const windows = [ const windows = [