WIP: Aureplop/kpsul js refactor #501
3 changed files with 9 additions and 9 deletions
|
@ -502,6 +502,10 @@ class Article extends ModelObject {
|
||||||
// API currently returns a string object (serialization of Decimal type within Django)
|
// API currently returns a string object (serialization of Decimal type within Django)
|
||||||
get price() { return this._price; }
|
get price() { return this._price; }
|
||||||
set price(v) { this._price = floatCheck(v); }
|
set price(v) { this._price = floatCheck(v); }
|
||||||
|
|
||||||
|
is_low_stock(nb) {
|
||||||
|
return (-5 <= this.stock - nb && this.stock - nb <= 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class AccountManager {
|
||||||
$('#id_on_acc').val(this.account.id);
|
$('#id_on_acc').val(this.account.id);
|
||||||
this.display();
|
this.display();
|
||||||
|
|
||||||
kpsul.article_manager.focus();
|
kpsul.focus();
|
||||||
kpsul._env.updateBasketAmount();
|
kpsul._env.updateBasketAmount();
|
||||||
kpsul._env.updateBasketRel();
|
kpsul._env.updateBasketRel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
commentDialog.open({
|
commentDialog.open({
|
||||||
callback: confirm_callback,
|
callback: confirm_callback,
|
||||||
next_focus: kpsul.article_manager,
|
next_focus: kpsul,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ $(document).ready(function() {
|
||||||
else
|
else
|
||||||
displayErrors(getErrorsHtml(response));
|
displayErrors(getErrorsHtml(response));
|
||||||
},
|
},
|
||||||
next_focus: kpsul.article_manager,
|
next_focus: kpsul,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,17 +312,13 @@ $(document).ready(function() {
|
||||||
.find('.name').text(article.name).end()
|
.find('.name').text(article.name).end()
|
||||||
.find('.amount').text(amountToUKF(amount_euro, kpsul.account_manager.account.is_cof));
|
.find('.amount').text(amountToUKF(amount_euro, kpsul.account_manager.account.is_cof));
|
||||||
basket_container.prepend(article_basket_html);
|
basket_container.prepend(article_basket_html);
|
||||||
if (is_low_stock(article, nb))
|
if (article.is_low_stock(nb))
|
||||||
article_basket_html.find('.lowstock')
|
article_basket_html.find('.lowstock')
|
||||||
.show();
|
.show();
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_low_stock(article, nb) {
|
|
||||||
return (-5 <= article.stock - nb && article.stock - nb <= 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addDeposit(amount) {
|
function addDeposit(amount) {
|
||||||
var deposit_basket_html = $(item_basket_default_html);
|
var deposit_basket_html = $(item_basket_default_html);
|
||||||
var amount = parseFloat(amount).toFixed(2);
|
var amount = parseFloat(amount).toFixed(2);
|
||||||
|
@ -481,7 +477,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_low_stock(article, nb_after))
|
if (article.is_low_stock(nb_after))
|
||||||
article_html.find('.lowstock')
|
article_html.find('.lowstock')
|
||||||
.show();
|
.show();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue