diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/point_of_sale/static/src/js/main.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/point_of_sale/static/src/js/main.js')
| -rw-r--r-- | addons/point_of_sale/static/src/js/main.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/addons/point_of_sale/static/src/js/main.js b/addons/point_of_sale/static/src/js/main.js new file mode 100644 index 00000000..346a6167 --- /dev/null +++ b/addons/point_of_sale/static/src/js/main.js @@ -0,0 +1,49 @@ +odoo.define('web.web_client', function (require) { + 'use strict'; + + const AbstractService = require('web.AbstractService'); + const env = require('web.env'); + const WebClient = require('web.AbstractWebClient'); + const Chrome = require('point_of_sale.Chrome'); + const Registries = require('point_of_sale.Registries'); + const { configureGui } = require('point_of_sale.Gui'); + + owl.config.mode = env.isDebug() ? 'dev' : 'prod'; + owl.Component.env = env; + + Registries.Component.add(owl.misc.Portal); + + function setupResponsivePlugin(env) { + const isMobile = () => window.innerWidth <= 768; + env.isMobile = isMobile(); + const updateEnv = owl.utils.debounce(() => { + if (env.isMobile !== isMobile()) { + env.isMobile = !env.isMobile; + env.qweb.forceUpdate(); + } + }, 15); + window.addEventListener("resize", updateEnv); + } + + setupResponsivePlugin(owl.Component.env); + + async function startPosApp(webClient) { + Registries.Component.freeze(); + await env.session.is_bound; + env.qweb.addTemplates(env.session.owlTemplates); + env.bus = new owl.core.EventBus(); + await owl.utils.whenReady(); + await webClient.setElement(document.body); + await webClient.start(); + webClient.isStarted = true; + const chrome = new (Registries.Component.get(Chrome))(null, { webClient }); + await chrome.mount(document.querySelector('.o_action_manager')); + await chrome.start(); + configureGui({ component: chrome }); + } + + AbstractService.prototype.deployServices(env); + const webClient = new WebClient(); + startPosApp(webClient); + return webClient; +}); |
