Skip to content

Commit

Permalink
Add dynamic VAT field to stock record in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bitrut committed May 29, 2012
1 parent da2889b commit 2428a5f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
21 changes: 21 additions & 0 deletions oscar/static/oscar/js/oscar/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ oscar.dashboard = {
init: function() {
$('input[name^="date"], input[name$="date"]').datepicker({dateFormat: 'yy-mm-dd'});
},
catalogue: {
init: function() {
var price_excl_tax = $('#id_price_excl_tax');
var price_retail = $('#id_price_retail');
var vat_recalc = function(elem){
elem.val(price_retail.val() - price_excl_tax.val());
}
var price_excl_tax_field = price_excl_tax.parent().parent();
var cloned = price_excl_tax_field.clone();
var input = $('input', cloned).attr('id', 'id_vat').attr('disabled', 'disabled');
$('label', cloned).text('VAT').attr('for', input.attr('id'));
vat_recalc(input);
price_excl_tax_field.after(cloned);
price_excl_tax.blur(function(){
vat_recalc(input);
});
price_retail.blur(function(){
vat_recalc(input);
});
}
},
ranges: {
init: function() {
$('[data-behaviours~="remove"]').click(function() {
Expand Down
14 changes: 9 additions & 5 deletions oscar/templates/dashboard/catalogue/product_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ <h3 class="app-ico ico_expand icon">Product information</h3>
{% endif %}
{% endfor %}
</div>
<div class="well form-inline">

<div class="well form-inline">
<div class="sub-header">
<h3 class="app-ico ico_home icon">Category information</h3>
</div>
Expand All @@ -84,7 +84,7 @@ <h3 class="app-ico ico_home icon">Category information</h3>
<hr/>
{% endfor %}
</div>

<div class="well form-inline">
<div class="sub-header">
<h3 class="app-ico ico_favourite icon">Images</h3>
Expand All @@ -95,7 +95,7 @@ <h3 class="app-ico ico_favourite icon">Images</h3>
<hr/>
{% endfor %}
</div>

<div class="well fields-full">
<div class="sub-header">
<h3 class="app-ico ico_shop_bag icon">Stock and price information</h3>
Expand Down Expand Up @@ -129,11 +129,15 @@ <h3 class="app-ico ico_shop_bag icon">Stock and price information</h3>
{% endblock %}
</div>
<div class="form-actions">
<button class="btn btn-primary btn-large" type="submit">Save Product</button> or
<button class="btn btn-primary btn-large" type="submit">Save Product</button> or
<a href="{% url dashboard:catalogue-product-list %}">cancel</a>
{% if product %}
<a class="btn btn-success btn-large pull-right" href="{{ product.get_absolute_url }}">View on site</a>
{% endif %}
</div>
</form>
{% endblock dashboard_content %}

{% block onbodyload %}
oscar.dashboard.catalogue.init();
{% endblock %}

0 comments on commit 2428a5f

Please sign in to comment.