widget.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. function pos_customize_product_pack_widget(instance, module){
  2. var QWeb = instance.web.qweb;
  3. _t = instance.web._t;
  4. module.PosWidget.include({
  5. build_widgets: function() {
  6. var self = this;
  7. this._super();
  8. this.pack_popup = new module.PackPopUp(this,{});
  9. this.pack_popup.appendTo(this.$el);
  10. this.pack_popup.hide();
  11. this.screen_selector.popup_set['PackList'] = this.pack_popup;
  12. }
  13. });
  14. module.ClientListScreenWidget.include({
  15. show: function(){
  16. var self = this;
  17. this._super();
  18. this.$('.select-table').click(function(){
  19. self.pos_widget.screen_selector.show_popup('PackList');
  20. $('#floor-cancel').click(function(){
  21. self.pos_widget.screen_selector.set_current_screen('clientlist');
  22. });
  23. });
  24. }
  25. });
  26. module.PackPopUp = module.PopUpWidget.extend({
  27. template:'PackPopupWidget',
  28. start: function(){
  29. this._super();
  30. var self = this;
  31. this.floor_list_widget = new module.PackListScreenWidget(this,{});
  32. },
  33. show: function(){
  34. this._super();
  35. var self = this;
  36. this.floor_list_widget.replace($('.placeholder-PackListScreenWidget'));
  37. },
  38. });
  39. module.PackListScreenWidget = module.ScreenWidget.extend({
  40. template:'PackListScreenWidget',
  41. init: function(parent, options) {
  42. this._super(parent,options);
  43. },
  44. start: function() {
  45. this._super();
  46. var self = this;
  47. },
  48. renderElement: function() {
  49. this._super();
  50. var self = this;
  51. var pack_lines = this.pos.product_pack_lines || [];
  52. for(var i = 0; i < pack_lines.length; i++ ){
  53. var data = [];
  54. data.push({
  55. id:pack_lines[i].id,
  56. name:pack_lines[i].product_id[1],
  57. });
  58. data = data.shift();
  59. var product = new module.PackListWidget(this, {
  60. model_floor: data,
  61. });
  62. product.appendTo(this.$('.product_list'));
  63. }
  64. },
  65. }),
  66. module.PackListWidget = module.PosBaseWidget.extend({
  67. template: 'PackListWidget',
  68. init: function(parent, options){
  69. this._super(parent, options);
  70. this.model_floor = options.model_floor;
  71. },
  72. renderElement: function(){
  73. var self = this;
  74. this._super();
  75. }
  76. });
  77. };