Sha256: 098e42631f44b5aa84340c8cda97f8601423c6496edcf51c2d52d4ecf817fe01

Contents?: true

Size: 1.18 KB

Versions: 80

Compression:

Stored size: 1.18 KB

Contents

Spree.Views.Tables.SelectableTable.SumReturnItemAmount = Backbone.View.extend({
  initialize: function(options) {
    this.listenTo(this.model, 'change', this.render);

    this.render();
  },

  render: function() {
    var html = HandlebarsTemplates['tables/return_item_sum_amount']({
      total_pre_tax_refund: Spree.t("total_pre_tax_refund"),
      total_selected_item_amount: this.totalSelectedReturnItemAmount()
    });

    this.$el.html(html);
  },

  totalSelectedReturnItemAmount: function () {
    var totalAmount = 0;
    var selectedItems = [];
    var decimals = 0;
    var separator = Spree.t('currency_separator');
    var amount, decimalAmount;

    if(this.model.get('allSelected')) {
      selectedItems = $('.selectable');
    } else {
      selectedItems = $(this.model.attributes.selectedItems);
    }
    selectedItems.each(function(_, selectedItem){
      amount = $(selectedItem).data('price');
      decimalAmount = amount.toString().split(separator)[1] || '';
      decimals = Math.max(decimals, decimalAmount.length);

      totalAmount += parseFloat(amount);
    })

    return accounting.formatNumber(totalAmount, decimals, Spree.t('currency_delimiter'), separator);
  },
});

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
solidus_backend-3.3.0 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.5 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.4 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.3 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.1.8 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.0.8 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.2 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.1 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.0 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.2.0.alpha app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.0.7 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-2.11.17 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.1.7 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-2.11.16 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.0.6 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.1.6 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-2.11.15 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-2.11.14 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.0.5 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.1.5 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js