[IMP] point_of_sale: sane multi order workflow + remove existing tooltips when we load the pos
bzr revid: fva@openerp.com-20130905104357-xlf51euhnclymj7x
This commit is contained in:
parent
b183c50f3a
commit
71ae60324b
|
@ -175,10 +175,9 @@
|
|||
background: linear-gradient(#b2b3d7, #7f82ac);
|
||||
}
|
||||
|
||||
.point-of-sale #rightheader button.neworder-button {
|
||||
.point-of-sale #rightheader button.square{
|
||||
width: 32px;
|
||||
margin-left:4px;
|
||||
margin-right:4px;
|
||||
}
|
||||
|
||||
.point-of-sale div#order-selector {
|
||||
|
@ -186,12 +185,20 @@
|
|||
}
|
||||
.point-of-sale ol#orders {
|
||||
display: inline;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.point-of-sale li.order-selector-button {
|
||||
display: inline;
|
||||
}
|
||||
.point-of-sale li.selected-order button {
|
||||
font-weight: 900;
|
||||
background: #7174A8 !important;
|
||||
color: rgb(236, 237, 255) !important;
|
||||
text-shadow: 0px 1px rgba(0, 0, 0, 0.31);
|
||||
-webkit-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset;
|
||||
-moz-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset;
|
||||
-ms-box-shadow: 0px 1px 2px rgb(63, 66, 139) inset;
|
||||
box-shadow: 0px 1px 2px rgb(63, 66, 139) inset;
|
||||
}
|
||||
|
||||
/* c) The session buttons */
|
||||
|
|
|
@ -55,7 +55,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
'selectedOrder': null,
|
||||
});
|
||||
|
||||
this.get('orders').bind('remove', function(){ self.on_removed_order(); });
|
||||
this.get('orders').bind('remove', function(order,_unused_,options){
|
||||
self.on_removed_order(order,options.index,options.reason);
|
||||
});
|
||||
|
||||
// We fetch the backend data on the server asynchronously. this is done only when the pos user interface is launched,
|
||||
// Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched.
|
||||
|
@ -239,11 +241,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
|
||||
// this is called when an order is removed from the order collection. It ensures that there is always an existing
|
||||
// order and a valid selected order
|
||||
on_removed_order: function(removed_order){
|
||||
if( this.get('orders').isEmpty()){
|
||||
this.add_new_order();
|
||||
on_removed_order: function(removed_order,index,reason){
|
||||
if(reason === 'abandon' && this.get('orders').size() > 0){
|
||||
// when we intentionally remove an unfinished order, and there is another existing one
|
||||
this.set({'selectedOrder' : this.get('orders').at(index) || this.get('orders').last()});
|
||||
}else{
|
||||
this.set({ selectedOrder: this.get('orders').last() });
|
||||
// when the order was automatically removed after completion,
|
||||
// or when we intentionally delete the only concurrent order
|
||||
this.add_new_order();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -254,6 +259,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
this.set('selectedOrder', order);
|
||||
},
|
||||
|
||||
//removes the current order
|
||||
delete_current_order: function(){
|
||||
this.get('selectedOrder').destroy({'reason':'abandon'});
|
||||
console.log('coucou!');
|
||||
},
|
||||
|
||||
// saves the order locally and try to send it to the backend.
|
||||
// it returns a deferred that succeeds after having tried to send the order and all the other pending orders.
|
||||
push_order: function(order) {
|
||||
|
|
|
@ -362,28 +362,23 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.order = options.order;
|
||||
this.order.bind('destroy',function(){ self.destroy(); });
|
||||
this.order.bind('change', function(){ self.renderElement(); });
|
||||
this.pos.bind('change:selectedOrder', _.bind( function(pos) {
|
||||
var selectedOrder;
|
||||
selectedOrder = pos.get('selectedOrder');
|
||||
if (this.order === selectedOrder) {
|
||||
this.setButtonSelected();
|
||||
}
|
||||
}, this));
|
||||
this.pos.bind('change:selectedOrder', function() {
|
||||
self.renderElement();
|
||||
}, this);
|
||||
},
|
||||
renderElement:function(){
|
||||
this._super();
|
||||
this.$('button.select-order').off('click').click(_.bind(this.selectOrder, this));
|
||||
this.$('button.close-order').off('click').click(_.bind(this.closeOrder, this));
|
||||
if( this.order === this.pos.get('selectedOrder') ){
|
||||
this.$el.addClass('selected-order');
|
||||
}
|
||||
},
|
||||
selectOrder: function(event) {
|
||||
this.pos.set({
|
||||
selectedOrder: this.order
|
||||
});
|
||||
},
|
||||
setButtonSelected: function() {
|
||||
$('.selected-order').removeClass('selected-order');
|
||||
this.$el.addClass('selected-order');
|
||||
},
|
||||
closeOrder: function(event) {
|
||||
this.order.destroy();
|
||||
},
|
||||
|
@ -848,6 +843,8 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.leftpane_width = '440px';
|
||||
this.cashier_controls_visible = true;
|
||||
this.image_cache = new module.ImageCache(); // for faster products image display
|
||||
|
||||
$('.oe_tooltip').remove(); // remove tooltip from the start session button
|
||||
},
|
||||
|
||||
start: function() {
|
||||
|
@ -859,6 +856,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
self.$('.neworder-button').click(function(){
|
||||
self.pos.add_new_order();
|
||||
});
|
||||
|
||||
self.$('.deleteorder-button').click(function(){
|
||||
self.pos.delete_current_order();
|
||||
});
|
||||
|
||||
//when a new order is created, add an order button widget
|
||||
self.pos.get('orders').bind('add', function(new_order){
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
</div>
|
||||
<div id="rightheader">
|
||||
<div id="order-selector">
|
||||
<button class="neworder-button">+</button>
|
||||
<button class="neworder-button square">➕</button>
|
||||
<button class="deleteorder-button square">➖</button>
|
||||
<ol id="orders"></ol>
|
||||
</div>
|
||||
<!-- here goes header buttons -->
|
||||
|
|
Loading…
Reference in New Issue