index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import VueModal from 'vue-js-modal'
  4. import store from '@/store'
  5. import currency from '@@/filters/currency'
  6. import absolute from '@@/filters/absolute'
  7. Vue.filter('currency', currency)
  8. Vue.filter('absolute', absolute)
  9. Vue.use(VueModal)
  10. Vue.config.productionTip = false
  11. Vue.config.silent = true
  12. Vue.config.devTools = true
  13. openerp.eiru_pos = (instance, local) => {
  14. local.PosWidget = instance.Widget.extend({
  15. init(parent, action) {
  16. this._super(parent)
  17. this.mode = action.params.mode
  18. },
  19. start() {
  20. this.sidebarFold()
  21. this.vm = new Vue({
  22. store,
  23. el: this.el,
  24. template: '<App />',
  25. components: {
  26. App
  27. },
  28. data: {
  29. mode: this.mode
  30. },
  31. created() {
  32. // if ('serviceWorker' in navigator) {
  33. // navigator.serviceWorker.register('./sw.js').then(ok => {
  34. // console.log(ok)
  35. // }).then(e => {
  36. // console.log(e)
  37. // })
  38. // }
  39. }
  40. });
  41. },
  42. destroy() {
  43. this.vm.$destroy()
  44. $(this.vm.$el).remove()
  45. this.vm = null
  46. this.sidebarUnfold()
  47. this._super.apply(this, arguments)
  48. },
  49. sidebarFold() {
  50. if (!instance.eiru_sidebar_toggler) return
  51. instance.eiru_sidebar_toggler.sidebar_fold()
  52. },
  53. sidebarUnfold() {
  54. if (!instance.eiru_sidebar_toggler) return
  55. instance.eiru_sidebar_toggler.sidebar_unfold()
  56. }
  57. })
  58. instance.web.client_actions.add('eiru_pos.action_launch', 'instance.eiru_pos.PosWidget')
  59. }