Revision 98404f3e
Von Tamino Steinert vor 8 Monaten hinzugefügt
js/kivi.Part.js | ||
---|---|---|
453 | 453 |
this.last_dummy = this.$dummy.val(); |
454 | 454 |
this.timer = undefined; |
455 | 455 |
this.dialog = undefined; |
456 |
// for different popups on same page |
|
456 | 457 |
this.multiple_default = this.o.multiple; |
458 |
this.variants_list_default = this.o.variants_list; |
|
457 | 459 |
|
458 | 460 |
this.init(); |
459 | 461 |
}; |
... | ... | |
625 | 627 |
} |
626 | 628 |
}, |
627 | 629 |
open_dialog: function() { |
628 |
if (this.o.multiple) { |
|
630 |
if (this.o.variants_list) { |
|
631 |
this.o.variants_list = this.variants_list_default; |
|
632 |
this.dialog = new ns.PickerMultiVariantPopup(this); |
|
633 |
} else if (this.o.multiple) { |
|
629 | 634 |
this.o.multiple = this.multiple_default; |
630 | 635 |
this.dialog = new ns.PickerMultiPopup(this); |
631 | 636 |
} else { |
... | ... | |
906 | 911 |
} |
907 | 912 |
}; |
908 | 913 |
|
914 |
ns.PickerMultiVariantPopup = function(pp) { |
|
915 |
this.pp = pp; |
|
916 |
this.open_dialog(); |
|
917 |
}; |
|
918 |
|
|
919 |
ns.PickerMultiVariantPopup.prototype = { |
|
920 |
open_dialog: function() { |
|
921 |
var self = this; |
|
922 |
$('#row_table_id thead a img').remove(); |
|
923 |
|
|
924 |
kivi.popup_dialog({ |
|
925 |
url: 'controller.pl?action=Part/show_multi_variants_dialog', |
|
926 |
data: $.extend({ |
|
927 |
real_id: self.pp.real_id, |
|
928 |
show_pos_input: self.pp.o.multiple_pos_input, |
|
929 |
}, self.pp.ajax_data(this.pp.$dummy.val())), |
|
930 |
id: 'jq_multi_variants_dialog', |
|
931 |
dialog: { |
|
932 |
title: kivi.t8('Add multiple variants'), |
|
933 |
width: 800, |
|
934 |
height: 800 |
|
935 |
}, |
|
936 |
load: function() { |
|
937 |
self.init_search(); |
|
938 |
} |
|
939 |
}); |
|
940 |
return true; |
|
941 |
}, |
|
942 |
init_search: function() { |
|
943 |
|
|
944 |
var self = this; |
|
945 |
$('#multi_items_filter_table select').keydown(function(event) { |
|
946 |
if(event.which == KEY.ENTER) { |
|
947 |
event.preventDefault(); |
|
948 |
self.update_results(); |
|
949 |
return false; |
|
950 |
} |
|
951 |
}); |
|
952 |
|
|
953 |
// reset picker for parent_variant |
|
954 |
kivi.run_once_for('input.part_autocomplete', 'part_picker', function(elt) { |
|
955 |
if (!$(elt).data('part_picker')) |
|
956 |
$(elt).data('part_picker', new kivi.Part.Picker($(elt))); |
|
957 |
}); |
|
958 |
$('#multi_items_filter_parent_variant_id_name').focus(); |
|
959 |
$('#multi_items_filter_button').click(function(){ self.update_results(); }); |
|
960 |
$('#multi_items_filter_reset').click(function(){ |
|
961 |
$("#multi_items_form").resetForm(); |
|
962 |
$("#multi_variants_parent_variant_properties").html(''); |
|
963 |
$("#old_parent_variant_id").val(''); |
|
964 |
$("#multi_items_result").html(''); |
|
965 |
}); |
|
966 |
$('#continue_button').click(function(){ self.add_multi_items(); }); |
|
967 |
}, |
|
968 |
update_results: function() { |
|
969 |
var self = this; |
|
970 |
var data = $('#multi_items_form').serializeArray(); |
|
971 |
data.push({ name: 'action', value: 'Part/multi_variants_update_result' }); |
|
972 |
data.push({ name: 'type', value: self.pp.type }); |
|
973 |
data.push({ name: 'limit', value: self.pp.o.multiple_limit }); |
|
974 |
var ppdata = self.pp.ajax_data(function(){ |
|
975 |
var val = $('#multi_items_filter').val(); |
|
976 |
return val === undefined ? '' : val; |
|
977 |
}); |
|
978 |
$.each(Object.keys(ppdata), function() {data.push({ name: 'multi_items.' + this, value: ppdata[this]});}); |
|
979 |
|
|
980 |
$.post( |
|
981 |
"controller.pl", |
|
982 |
data, |
|
983 |
function(data){ |
|
984 |
kivi.eval_json_result(data); |
|
985 |
self.init_results(); |
|
986 |
self.enable_continue(); |
|
987 |
} |
|
988 |
); |
|
989 |
}, |
|
990 |
set_qty_to_one: function(clicked) { |
|
991 |
if ($(clicked).val() === '') { |
|
992 |
$(clicked).val(kivi.format_amount(1.00, -2)); |
|
993 |
} |
|
994 |
$(clicked).select(); |
|
995 |
}, |
|
996 |
init_results: function() { |
|
997 |
var self = this; |
|
998 |
$('#multi_items_all_qty').change(function(event){ |
|
999 |
$('.multi_items_qty').val($(event.target).val()); |
|
1000 |
}); |
|
1001 |
$('.multi_items_qty').focus(function(){ self.set_qty_to_one(this); }); |
|
1002 |
}, |
|
1003 |
result_timer: function() { |
|
1004 |
}, |
|
1005 |
close_dialog: function() { |
|
1006 |
$('#jq_multi_variants_dialog').dialog('close'); |
|
1007 |
}, |
|
1008 |
disable_continue: function() { |
|
1009 |
$('#multi_items_result input, #multi_items_position').off("keydown"); |
|
1010 |
$('#continue_button').prop('disabled', true); |
|
1011 |
}, |
|
1012 |
enable_continue: function() { |
|
1013 |
var self = this; |
|
1014 |
$('#multi_items_result input, #multi_items_position').keydown(function(event) { |
|
1015 |
if(event.keyCode == KEY.ENTER) { |
|
1016 |
event.preventDefault(); |
|
1017 |
self.add_multi_items(); |
|
1018 |
return false; |
|
1019 |
} |
|
1020 |
}); |
|
1021 |
$('#continue_button').prop('disabled', false); |
|
1022 |
}, |
|
1023 |
add_multi_items: function() { |
|
1024 |
// rows at all |
|
1025 |
var n_rows = $('.multi_items_qty').length; |
|
1026 |
if ( n_rows === 0) { return; } |
|
1027 |
|
|
1028 |
// filled rows |
|
1029 |
n_rows = $('.multi_items_qty').filter(function() { |
|
1030 |
return $(this).val().length > 0; |
|
1031 |
}).length; |
|
1032 |
if (n_rows === 0) { return; } |
|
1033 |
|
|
1034 |
this.disable_continue(); |
|
1035 |
|
|
1036 |
var data = $('#multi_items_form').serializeArray(); |
|
1037 |
this.pp.set_multi_items(data); |
|
1038 |
} |
|
1039 |
}; |
|
1040 |
|
|
909 | 1041 |
ns.reinit_widgets = function() { |
910 | 1042 |
kivi.run_once_for('input.part_autocomplete', 'part_picker', function(elt) { |
911 | 1043 |
if (!$(elt).data('part_picker')) |
Auch abrufbar als: Unified diff
Varianten: PartPicker: mehrere Varianten eines Stammartikel hinzufügen