Add websocket support to ArticleManager

This commit is contained in:
Ludovic Stephan 2017-03-18 22:06:30 -03:00
parent 565a054323
commit fc3e86aea6
2 changed files with 6 additions and 7 deletions

View file

@ -415,9 +415,10 @@ class ArticleManager {
this.list.fromAPI({}, this.display_list.bind(this), $.noop) ;
}
//TODO: filter articles before ?
update_data(data) {
for (let article_dict of data) {
article = this.list.find('article', article_dict['id']);
for (let article_dict of data.articles) {
var article = this.list.find('article', article_dict['id']);
// For now, article additions are disregarded
if (article) {

View file

@ -799,11 +799,9 @@ $(document).ready(function() {
displayCheckoutData();
}
}
for (var i=0; i<data['articles'].length; i++) {
var article = data['articles'][i];
articles_container.find('#data-article-'+article['id']+' .stock')
.text(article['stock']);
}
kpsul.article_manager.update_data(data);
if (data['addcost']) {
Config.set('addcost_for', data['addcost']['for']);
Config.set('addcost_amount', data['addcost']['amount']);