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/PosComponent.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/point_of_sale/static/src/js/PosComponent.js')
| -rw-r--r-- | addons/point_of_sale/static/src/js/PosComponent.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/addons/point_of_sale/static/src/js/PosComponent.js b/addons/point_of_sale/static/src/js/PosComponent.js new file mode 100644 index 00000000..ae2873ba --- /dev/null +++ b/addons/point_of_sale/static/src/js/PosComponent.js @@ -0,0 +1,59 @@ +odoo.define('point_of_sale.PosComponent', function (require) { + 'use strict'; + + const { Component } = owl; + + class PosComponent extends Component { + /** + * This function is available to all Components that inherit this class. + * The goal of this function is to show an awaitable dialog (popup) that + * returns a response after user interaction. See the following for quick + * demonstration: + * + * ``` + * async getUserName() { + * const userResponse = await this.showPopup( + * 'TextInputPopup', + * { title: 'What is your name?' } + * ); + * // at this point, the TextInputPopup is displayed. Depending on how the popup is defined, + * // say the input contains the name, the result of the interaction with the user is + * // saved in `userResponse`. + * console.log(userResponse); // logs { confirmed: true, payload: <name> } + * } + * ``` + * + * @param {String} name Name of the popup component + * @param {Object} props Object that will be used to render to popup + */ + showPopup(name, props) { + return new Promise((resolve) => { + this.trigger('show-popup', { name, props, resolve }); + }); + } + showTempScreen(name, props) { + return new Promise((resolve) => { + this.trigger('show-temp-screen', { name, props, resolve }); + }); + } + showScreen(name, props) { + this.trigger('show-main-screen', { name, props }); + } + /** + * @param {String} name 'bell' | 'error' + */ + playSound(name) { + this.trigger('play-sound', name); + } + /** + * Control the SyncNotification component. + * @param {String} status 'connected' | 'connecting' | 'disconnected' | 'error' + * @param {String} pending number of pending orders to sync + */ + setSyncStatus(status, pending) { + this.trigger('set-sync-status', { status, pending }); + } + } + + return PosComponent; +}); |
