diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-06-24 18:38:12 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-06-25 00:26:31 +0200 |
| commit | a3041949364141eaa66b22ab0d72227b675df324 (patch) | |
| tree | 6fd5ca7333bbcc908e35baee6acbd1040b2a9592 /addons/web/static/src/js/framework | |
| parent | 07efacb5785434361608e22d43bab492a5102de4 (diff) | |
| parent | 81b5c601f9466e5e48e337c0d270ea4955cf181c (diff) | |
[MERGE] forward port of branch saas-6 up to 81b5c60
Diffstat (limited to 'addons/web/static/src/js/framework')
| -rw-r--r-- | addons/web/static/src/js/framework/cordova.js | 83 | ||||
| -rw-r--r-- | addons/web/static/src/js/framework/view.js | 2 |
2 files changed, 84 insertions, 1 deletions
diff --git a/addons/web/static/src/js/framework/cordova.js b/addons/web/static/src/js/framework/cordova.js new file mode 100644 index 00000000000..8eb22dd182d --- /dev/null +++ b/addons/web/static/src/js/framework/cordova.js @@ -0,0 +1,83 @@ +odoo.define('web.Cordova', function(require) { +"use strict"; + +var core = require('web.core'); + +// The Android/iPhone App is a JS/HTML app that launches the +// Odoo webclient in an iframe, using the Cordova framework. +// +// This class acts as a link between the webclient and the +// Odoo Android/iPhone App implemented with cordova. + +var Cordova = core.Class.extend({}, core.mixins.PropertiesMixin, { + init: function(parent) { + var self = this; + core.mixins.PropertiesMixin.init.call(this, parent); + + window.addEventListener('message', function(event) { + self.receive(event); + }, false); + + }, + // odoo.send('foobar') in cordova will call messages.foobar() + messages: { + // launch the POS ! + pos: function() { + if (window.location.href.indexOf('/pos/web') < 0) { + window.location.href = "/pos/web"; + } + }, + }, + // what happens when we receive an event from cordova + // -> call messages[event.data]() + // -> selfs trigger(event.data) + receive: function(event) { + if (event.origin !== 'file://') { + return; + } + + if (typeof event.data === 'string') { + this.trigger(event.data); + if (this.messages[event.data]) { + this.messages[event.data].call(this); + } + } + }, + // send a message to cordova + send: function(message) { + function inIframe(){ + try { + return window.self !== window.top; + } catch (e) { + return true; + } + } + if (inIframe()) { + window.parent.postMessage(message,'file://'); + } + }, + + + // notifies cordova that the webclient is ready. + ready: function() { this.send('ready'); }, + // notifies cordova that we want to exit the app. + logout: function() { this.send('logout'); }, + // notifies cordova that the point of sale is ready. + posready: function() { this.send('posready'); }, + // notifies cordova that we want to exit the point of sale. + poslogout: function() { this.send('poslogout'); }, + // asks cordova to emit a beep. + beep: function() { this.send('beep'); }, + // ask cordova to vibrate the phone. + vibrate: function() { this.send('vibrate'); }, +}); + +return Cordova; +}); + +// Singleton module +odoo.define('web.cordova', function(require) { +"use strict"; +var Cordova = require('web.Cordova'); +return new Cordova(); +}); diff --git a/addons/web/static/src/js/framework/view.js b/addons/web/static/src/js/framework/view.js index f8791c6bf4f..8eee01d414d 100644 --- a/addons/web/static/src/js/framework/view.js +++ b/addons/web/static/src/js/framework/view.js @@ -105,7 +105,7 @@ var View = Widget.extend({ // Wrong group_by values will simply fail and forbid rendering of the destination view var ncontext = new data.CompoundContext( _.object(_.reject(_.pairs(dataset.get_context().eval()), function(pair) { - return pair[0].match('^(?:(?:default_|search_default_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null; + return pair[0].match('^(?:(?:default_|search_default_|show_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null; })) ); ncontext.add(action_data.context || {}); |
