app/assets/javascripts/admin/promotions.js in spree_promo-0.70.7 vs app/assets/javascripts/admin/promotions.js in spree_promo-1.0.0.rc1
- old
+ new
@@ -1,11 +1,11 @@
var initProductRuleSourceField = function(){
$products_source_field = jQuery('.products_rule_products_source_field input');
$products_source_field.click(function() {
- $rule_container = jQuery(this).parents('.promotion_rule');
+ $rule_container = jQuery(this).parents('.promotion-rule');
if(this.checked){
if(this.value == 'manual'){
$rule_container.find('.products_rule_products').show();
$rule_container.find('.products_rule_product_group').hide();
} else {
@@ -46,30 +46,10 @@
//
// CreateLineItems Promotion Action
//
( function(){
- // Autocomplete product and populate variant select
- if($('.promotion_action.create_line_items ').is('*')){
- $(".promotion_action.create_line_items input[name='add_product_name']").autocomplete("/admin/products.json?authenticity_token=" + $('meta[name=csrf-token]').attr("content"), {
- parse: prep_product_autocomplete_data,
- formatItem: function(item) {
- return format_product_autocomplete(item);
- }
- }).result(function(event, data, formatted) {
- if(data){
- if(data['variant']==undefined){
- // product
- $('#add_line_item_variant_id').val(data['product']['master']['id']);
- }else{
- // variant
- $('#add_line_item_variant_id').val(data['variant']['id']);
- }
- }
- });
- }
-
var hideOrShowItemTables = function(){
$('.promotion_action table').each(function(){
if($(this).find('td').length == 0){
$(this).hide();
} else {
@@ -94,13 +74,13 @@
hideOrShowItemTables();
});
};
setupRemoveLineItems();
// Add line item to list
- $(".promotion_action.create_line_items button.add").live('click',function(){
+ $(".promotion_action.create_line_items button.add").live('click',function(e){
var $container = $(this).parents('.promotion_action');
var product_name = $container.find("input[name='add_product_name']").val();
- var variant_id = $container.find("input[name='add_line_item_variant_id']").val();
+ var variant_id = $container.find("input[name='add_variant_id']").val();
var quantity = $container.find("input[name='add_quantity']").val();
if(variant_id){
// Add to the table
var newRow = "<tr><td>" + product_name + "</td><td>" + quantity + "</td><td><img src='/assets/admin/icons/cross.png' /></td></tr>";
$container.find('table').append(newRow);