-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use selectable.js code on return items.
This commit updates the JS and HTML code related to return items, to use the selectable.js code. You can see the code working on: /admin/orders/ORDER_NUMBER/customer_returns/new /admin/orders/ORDER_NUMBER/return_authorizations/new return_item_selection.js file is removed in favor of HBS template.
- Loading branch information
1 parent
214c9d9
commit ea23be2
Showing
11 changed files
with
63 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
backend/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Backbone.on('selectableTable:init', function(selectableTable){ | ||
if(selectableTable.$el.hasClass('return-items-table')) { | ||
new Spree.Views.Tables.ReturnItems({el: selectableTable.el, model: selectableTable.model}); | ||
} | ||
}) |
35 changes: 0 additions & 35 deletions
35
backend/app/assets/javascripts/spree/backend/returns/return_item_selection.js
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
backend/app/assets/javascripts/spree/backend/templates/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
backend/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<tr class="selectable-header"> | ||
<th class="selectable-table-summary" colspan="2"> | ||
</th> | ||
<td colspan="7" class="text-right"> | ||
{{total_pre_tax_refund}} <span id="total_pre_tax_refund">{{total_selected_item_amount}}</span> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
backend/app/assets/javascripts/spree/backend/views/tables/return_items.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Spree.Views.Tables.ReturnItems = Backbone.View.extend({ | ||
initialize: function() { | ||
if(this.$el.hasClass('return-items-table')) { | ||
var tfoot = document.createElement('tfoot') | ||
new Spree.Views.Tables.SelectableTable.SumReturnItemAmount({el: tfoot, model: this.model}); | ||
this.$el.append(tfoot); | ||
} | ||
}, | ||
}) |
32 changes: 32 additions & 0 deletions
32
.../assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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.00; | ||
var selectedItems = []; | ||
|
||
if(this.model.get('allSelected')) { | ||
selectedItems = $('.selectable'); | ||
} else { | ||
selectedItems = $(this.model.attributes.selectedItems); | ||
} | ||
selectedItems.each(function(_, selectedItem){ | ||
totalAmount += $(selectedItem).data('price'); | ||
}) | ||
|
||
return totalAmount; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters