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-4.4.2 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.4.1 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.4.0 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.3.4 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.2.4 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.1.5 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.3.3 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.3.2 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.1.4 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.3.1 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.3.0 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.2.3 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.1.3 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.0.4 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.4.6 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.0.3 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.1.2 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.2.2 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-3.4.5 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
solidus_backend-4.2.1 app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js